@abgov/adsp-sdk-mcp-server 1.26.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -7
- package/assets/api-specs/agent-service.json +1 -0
- package/assets/api-specs/audit-service.json +1 -0
- package/assets/api-specs/cache-service.json +1 -0
- package/assets/api-specs/calendar-service.json +1 -0
- package/assets/api-specs/comment-service.json +1 -0
- package/assets/api-specs/configuration-service.json +1 -0
- package/assets/api-specs/directory-service.json +1 -0
- package/assets/api-specs/event-service.json +1 -0
- package/assets/api-specs/export-service.json +1 -0
- package/assets/api-specs/feedback-service.json +1 -0
- package/assets/api-specs/file-service.json +1 -0
- package/assets/api-specs/form-service.json +1 -0
- package/assets/api-specs/index.json +186 -0
- package/assets/api-specs/notification-service.json +1 -0
- package/assets/api-specs/pdf-service.json +1 -0
- package/assets/api-specs/pii-service.json +1 -0
- package/assets/api-specs/project-planner-service.json +1 -0
- package/assets/api-specs/push-service.json +1 -0
- package/assets/api-specs/status-service.json +1 -0
- package/assets/api-specs/task-service.json +1 -0
- package/assets/api-specs/tenant-management-api.json +1 -0
- package/assets/api-specs/token-handler.json +1 -0
- package/assets/api-specs/value-service.json +1 -0
- package/assets/api-specs/verify-service.json +1 -0
- package/assets/docs/services/agent-service.md +31 -0
- package/assets/docs/services/form-service.md +301 -233
- package/assets/docs/services/notification-service.md +23 -0
- package/assets/docs/services/value-service.md +16 -0
- package/package.json +1 -1
- package/provenance.json +4 -4
- package/src/api-specs/apiSpecsRepository.d.ts +44 -0
- package/src/api-specs/apiSpecsRepository.js +113 -0
- package/src/api-specs/apiSpecsRepository.js.map +1 -0
- package/src/config.d.ts +2 -0
- package/src/config.js +7 -0
- package/src/config.js.map +1 -1
- package/src/hosted.d.ts +20 -0
- package/src/hosted.js +30 -0
- package/src/hosted.js.map +1 -0
- package/src/http.d.ts +4 -1
- package/src/http.js +22 -1
- package/src/http.js.map +1 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/lifecycle.d.ts +18 -0
- package/src/lifecycle.js +52 -0
- package/src/lifecycle.js.map +1 -0
- package/src/main.js +2 -22
- package/src/main.js.map +1 -1
- package/src/metrics.js +7 -1
- package/src/metrics.js.map +1 -1
- package/src/server.d.ts +2 -0
- package/src/server.js +13 -3
- package/src/server.js.map +1 -1
- package/src/tools/registerApiTools.d.ts +7 -0
- package/src/tools/registerApiTools.js +110 -0
- package/src/tools/registerApiTools.js.map +1 -0
|
@@ -90,6 +90,29 @@ The notification service sends the following domain events under the `notificati
|
|
|
90
90
|
| `subscription-set` | A subscription was created or its criteria changed. |
|
|
91
91
|
| `subscription-deleted` | A subscription was deleted. |
|
|
92
92
|
|
|
93
|
+
## Audit
|
|
94
|
+
Notification service records audit events in the `notification-service` namespace of the [audit service](/adsp-monorepo/services/audit-service.html). Records are written to the tenant of the subscriber, subscription, notification type or notification. All actions are version 1.
|
|
95
|
+
|
|
96
|
+
| Action | Category | Severity | Retention class | Recorded when |
|
|
97
|
+
|:-|:-|:-|:-|:-|
|
|
98
|
+
| `subscriber.created` | administrative | info | standard | A subscriber is created, including when a user first subscribes. |
|
|
99
|
+
| `subscriber.updated` | administrative | info | standard | The name or channels of a subscriber are changed, or a subscriber channel is verified. |
|
|
100
|
+
| `subscriber.deleted` | administrative | warning | compliance | A subscriber and its subscriptions are deleted. |
|
|
101
|
+
| `subscription.created` | administrative | info | standard | A subscriber is subscribed to a notification type. |
|
|
102
|
+
| `subscription.updated` | administrative | info | standard | The criteria of a subscription are changed or one criteria is removed. |
|
|
103
|
+
| `subscription.deleted` | administrative | info | standard | A subscriber is unsubscribed from a notification type. |
|
|
104
|
+
| `notification.sent` | runtime | info | standard | A notification is sent to a subscriber through a channel provider. |
|
|
105
|
+
| `notification.send-failed` | runtime | warning | standard | A notification to a subscriber could not be sent after all retries, with the `error` message in the metadata. |
|
|
106
|
+
| `notification.direct-sent` | runtime | info | standard | A notification of a direct type (with an `addressPath`) is sent to the address in the event. |
|
|
107
|
+
| `notification.direct-send-failed` | runtime | warning | standard | A notification of a direct type could not be sent after all retries, with the `error` message in the metadata. |
|
|
108
|
+
| `notification-type.created` | administrative | info | compliance | A tenant notification type is created through the notification API. |
|
|
109
|
+
| `notification-type.updated` | administrative | warning | compliance | A tenant notification type is changed, or a platform type is customized (`customizesCoreType: true`). |
|
|
110
|
+
| `notification-type.deleted` | administrative | warning | compliance | A tenant notification type or a platform type customization is deleted (`revertsToCoreType: true`). |
|
|
111
|
+
|
|
112
|
+
Subscriber and subscription changes record the user or service account (ID, name and roles, without the email address) as the actor. Subscriber records include only the channel types and whether each is verified; channel addresses are not recorded. Sent and failed notifications are recorded with the system actor `notification-service-job` and the event correlation ID. Notifications to subscribers are recorded against the subscription (`<type ID>:<subscriber ID>`), and notifications of direct types are recorded against the notification type with the `direct-` actions. The recipient address, message content and context values are not recorded (only the context keys).
|
|
113
|
+
|
|
114
|
+
Contact information changes and notification type changes made directly in the configuration service are not recorded by notification service. Notifications can be high volume, so audit events are sent in batches of up to 100 events. Audit failures are logged and do not fail the operation. The service account of notification service needs the `audit-writer` role of `urn:ads:platform:audit-service`. Set `NOTIFICATION_AUDIT_ENABLED` to `false` to disable recording; when unset it follows the SDK `AUDIT_ENABLED` variable (on by default).
|
|
115
|
+
|
|
93
116
|
## Code examples
|
|
94
117
|
### Create a notification type
|
|
95
118
|
Users with the subscription-admin or configuration-admin role can create notification types for their tenant. The definition is validated, including its channels, events, and templates. The service responds `409` if a type with the ID already exists.
|
|
@@ -48,6 +48,7 @@ All endpoints are under `https://value-service.adsp.alberta.ca/value/v1`. See th
|
|
|
48
48
|
| `GET /value/v1/{namespace}/values/{name}/metrics/{metric}` | Read interval aggregates of one metric. | `value-reader` |
|
|
49
49
|
| `GET /value/v1/{namespace}/values/{name}/platform-metrics` | Read a value's metrics across all tenants. | `value-platform-metrics-reader` (core users only) |
|
|
50
50
|
| `POST /value/v1/service-metric-rollups/run` | Run the service metric rollup for completed days. | `value-writer` |
|
|
51
|
+
| `GET /value/v1/event-resources/distinct-count` | Count the distinct resources events named over a period. | `value-reader` |
|
|
51
52
|
| `GET /value/v1/definitions` | List tenant and core value definitions. | `value-reader` or `value-writer` |
|
|
52
53
|
| `POST /value/v1/definitions` | Create a tenant value definition. | `value-writer` |
|
|
53
54
|
| `GET /value/v1/definitions/{namespace}/{name}` | Get a value definition (tenant, otherwise core). | `value-reader` or `value-writer` |
|
|
@@ -126,6 +127,21 @@ ORDER BY "interval";
|
|
|
126
127
|
|
|
127
128
|
Rollups store `sum` and `count` rather than an average, because an average of averages is not the average; the read path divides the two.
|
|
128
129
|
|
|
130
|
+
### Event resource rollups
|
|
131
|
+
|
|
132
|
+
Reports count how many distinct resources a tenant's events named over a period, such as the PDF templates behind `pdf-service` events. Reading that from the event log means reading every event in the period. The `event_resource_rollups` table instead records, per day, which resources each tenant's events named: one row per day, tenant, event and resource, with the number of events. A distinct count does not add up across days the way a sum does — a template used on two days is still one template — so the rollup keeps the resources themselves, and a period's count is a distinct count over its days.
|
|
133
|
+
|
|
134
|
+
The resources rolled up are the `resource` entries of the service metric rollup mappings: `templateId` for `pdf-service` and `definitionId` for `form-service` events.
|
|
135
|
+
|
|
136
|
+
The job runs alongside the metric interval rollups, under `METRIC_INTERVAL_ROLLUP_JOB_ENABLED`, `METRIC_INTERVAL_ROLLUP_MAX_CHUNK_HOURS` (bounded to between a day and a week) and `METRIC_INTERVAL_ROLLUP_STATEMENT_TIMEOUT_MS`, on ticks offset two minutes from theirs and under its own advisory lock. It moves each source's coverage forward over closed days — a day is rolled up an hour after it ends, so events timestamped just before midnight land in it — and backward through history, recorded in `event_resource_rollup_coverage`. Walking back starts from the newest event log chunk below coverage, read from chunk metadata, so a span of years with no data at all, such as between a stray old event and the rest of the log, is crossed in a single step.
|
|
137
|
+
|
|
138
|
+
`GET /value/v1/event-resources/distinct-count` reads the count for a `namespace`, `contextKey`, optional comma separated `names` (defaulting to every event rolled up for the namespace) and a period from `intervalMin` (inclusive) to `intervalMax` (exclusive), at most 731 days. Whole days inside coverage come from the rollup; the current day, and any history the backfill has not reached yet, are read from the event log for that span alone, and the two are combined before counting. Only the sources above and their own events are accepted, since the rollup has no rows for anything else and would undercount.
|
|
139
|
+
|
|
140
|
+
```sql
|
|
141
|
+
SELECT namespace, context_key, covered_from, covered_to, updated_at
|
|
142
|
+
FROM event_resource_rollup_coverage;
|
|
143
|
+
```
|
|
144
|
+
|
|
129
145
|
### Service metric rollups
|
|
130
146
|
|
|
131
147
|
A daily job summarises tenant activity for `pdf-service`, `form-service` and `notification-service` into the `service_metric_rollups` table: one row per day, tenant and service, with counts of initiated, succeeded and failed operations, duration totals, and the number of distinct resources (for example PDF templates or form definitions). The rows are derived from the event log and the services' metrics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/adsp-sdk-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - MCP server for ADSP documentation and Node SDK reference lookup.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|
package/provenance.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"kind": "release",
|
|
3
|
-
"builtAt": "2026-11-
|
|
4
|
-
"sourceCommit": "
|
|
5
|
-
"latestRelease": "1.
|
|
6
|
-
"docsCommit": "
|
|
3
|
+
"builtAt": "2026-11-16T15:02:42.094Z",
|
|
4
|
+
"sourceCommit": "74a53192ad29f707c522e61a3d31d74dde54a126",
|
|
5
|
+
"latestRelease": "1.27.0",
|
|
6
|
+
"docsCommit": "74a53192ad29f707c522e61a3d31d74dde54a126",
|
|
7
7
|
"sdk": {
|
|
8
8
|
"version": "2.36.1",
|
|
9
9
|
"commit": "dd58a2b854c4406b42c0604dba3fa4b941038d6c",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** One entry of api-specs/index.json, written by scripts/api-specs.mjs. */
|
|
2
|
+
export interface ApiServiceSummary {
|
|
3
|
+
app: string;
|
|
4
|
+
urn: string;
|
|
5
|
+
name: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
operations: number;
|
|
8
|
+
file: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiEndpointSummary {
|
|
11
|
+
service: string;
|
|
12
|
+
method: string;
|
|
13
|
+
path: string;
|
|
14
|
+
summary?: string;
|
|
15
|
+
deprecated: boolean;
|
|
16
|
+
/** Sentences of the description that state who may call it (roles, tenancy, anonymous access). */
|
|
17
|
+
access: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface ApiEndpoint extends ApiEndpointSummary {
|
|
20
|
+
serviceUrn: string;
|
|
21
|
+
operationId?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
tags: string[];
|
|
24
|
+
parameters: unknown[];
|
|
25
|
+
requestBody?: unknown;
|
|
26
|
+
responses: Record<string, unknown>;
|
|
27
|
+
security?: unknown;
|
|
28
|
+
}
|
|
29
|
+
/** The bundled OpenAPI specs (api-specs/), indexed for listing, keyword search and reading one endpoint. */
|
|
30
|
+
export declare class ApiSpecsRepository {
|
|
31
|
+
private readonly services;
|
|
32
|
+
private readonly operations;
|
|
33
|
+
constructor(apiSpecsRoot: string);
|
|
34
|
+
list(): ApiServiceSummary[];
|
|
35
|
+
/** The service named by its app folder, URN or display name; case-insensitive. */
|
|
36
|
+
findService(nameOrUrn: string): ApiServiceSummary | undefined;
|
|
37
|
+
search(query: string, options?: {
|
|
38
|
+
service?: ApiServiceSummary;
|
|
39
|
+
limit?: number;
|
|
40
|
+
}): ApiEndpointSummary[];
|
|
41
|
+
read(service: ApiServiceSummary, method: string, path: string): ApiEndpoint | undefined;
|
|
42
|
+
/** Paths of a service, for suggesting the right one when a read misses. */
|
|
43
|
+
paths(service: ApiServiceSummary): string[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiSpecsRepository = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const textSearch_1 = require("../search/textSearch");
|
|
7
|
+
const HTTP_METHODS = ['get', 'put', 'post', 'delete', 'patch', 'options', 'head', 'trace'];
|
|
8
|
+
const ACCESS_SENTENCE = /\b(roles?|anonymous|authenticated|public)\b/i;
|
|
9
|
+
/** $refs nested deeper than this stay as `{ $ref }`, which keeps one endpoint's output bounded. */
|
|
10
|
+
const MAX_REF_DEPTH = 4;
|
|
11
|
+
function accessSentences(description = '') {
|
|
12
|
+
return description
|
|
13
|
+
.split(/(?<=\.)\s+/)
|
|
14
|
+
.map((sentence) => sentence.trim())
|
|
15
|
+
.filter((sentence) => ACCESS_SENTENCE.test(sentence));
|
|
16
|
+
}
|
|
17
|
+
/** Inlines local `#/...` references, up to MAX_REF_DEPTH and never into a reference already being expanded. */
|
|
18
|
+
function resolveRefs(value, spec, expanding = []) {
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return value.map((item) => resolveRefs(item, spec, expanding));
|
|
21
|
+
}
|
|
22
|
+
if (!value || typeof value !== 'object') {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
const { $ref, ...rest } = value;
|
|
26
|
+
if (typeof $ref === 'string' && $ref.startsWith('#/')) {
|
|
27
|
+
if (expanding.includes($ref) || expanding.length >= MAX_REF_DEPTH) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
const target = $ref
|
|
31
|
+
.slice(2)
|
|
32
|
+
.split('/')
|
|
33
|
+
.reduce((node, key) => node?.[key], spec);
|
|
34
|
+
return target === undefined ? value : resolveRefs(target, spec, [...expanding, $ref]);
|
|
35
|
+
}
|
|
36
|
+
return Object.fromEntries(Object.entries(rest).map(([key, item]) => [key, resolveRefs(item, spec, expanding)]));
|
|
37
|
+
}
|
|
38
|
+
function indexOperations(service, spec) {
|
|
39
|
+
const paths = (spec.paths ?? {});
|
|
40
|
+
return Object.entries(paths).flatMap(([path, item]) => HTTP_METHODS.filter((method) => item[method]).map((method) => {
|
|
41
|
+
const operation = item[method];
|
|
42
|
+
const description = operation.description;
|
|
43
|
+
const summary = operation.summary;
|
|
44
|
+
const tags = operation.tags ?? [];
|
|
45
|
+
const operationId = operation.operationId;
|
|
46
|
+
const endpoint = {
|
|
47
|
+
service: service.app,
|
|
48
|
+
serviceUrn: service.urn,
|
|
49
|
+
method: method.toUpperCase(),
|
|
50
|
+
path,
|
|
51
|
+
summary,
|
|
52
|
+
deprecated: operation.deprecated === true,
|
|
53
|
+
access: accessSentences(description),
|
|
54
|
+
operationId,
|
|
55
|
+
description,
|
|
56
|
+
tags,
|
|
57
|
+
parameters: resolveRefs([...(item.parameters ?? []), ...(operation.parameters ?? [])], spec),
|
|
58
|
+
requestBody: resolveRefs(operation.requestBody, spec),
|
|
59
|
+
responses: resolveRefs(operation.responses ?? {}, spec),
|
|
60
|
+
security: operation.security ?? spec.security,
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
endpoint,
|
|
64
|
+
strongCounts: (0, textSearch_1.countTerms)((0, textSearch_1.tokenize)(`${path} ${summary ?? ''} ${operationId ?? ''} ${tags.join(' ')}`)),
|
|
65
|
+
bodyCounts: (0, textSearch_1.countTerms)((0, textSearch_1.tokenize)(`${service.name} ${service.app} ${description ?? ''}`)),
|
|
66
|
+
};
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
function toSummary({ service, method, path, summary, deprecated, access }) {
|
|
70
|
+
return { service, method, path, summary, deprecated, access };
|
|
71
|
+
}
|
|
72
|
+
/** The bundled OpenAPI specs (api-specs/), indexed for listing, keyword search and reading one endpoint. */
|
|
73
|
+
class ApiSpecsRepository {
|
|
74
|
+
services;
|
|
75
|
+
operations;
|
|
76
|
+
constructor(apiSpecsRoot) {
|
|
77
|
+
this.services = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(apiSpecsRoot, 'index.json'), 'utf8'));
|
|
78
|
+
this.operations = this.services.flatMap((service) => indexOperations(service, JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(apiSpecsRoot, service.file), 'utf8'))));
|
|
79
|
+
}
|
|
80
|
+
list() {
|
|
81
|
+
return this.services;
|
|
82
|
+
}
|
|
83
|
+
/** The service named by its app folder, URN or display name; case-insensitive. */
|
|
84
|
+
findService(nameOrUrn) {
|
|
85
|
+
const wanted = nameOrUrn.trim().toLowerCase();
|
|
86
|
+
return this.services.find((s) => [s.app, s.urn, s.name].some((value) => value.toLowerCase() === wanted));
|
|
87
|
+
}
|
|
88
|
+
search(query, options = {}) {
|
|
89
|
+
const terms = (0, textSearch_1.queryTerms)(query);
|
|
90
|
+
return this.operations
|
|
91
|
+
.filter(({ endpoint }) => !options.service || endpoint.service === options.service.app)
|
|
92
|
+
.map((operation) => ({
|
|
93
|
+
operation,
|
|
94
|
+
score: (0, textSearch_1.scoreByTermFrequency)(terms, operation.strongCounts) * 3 + (0, textSearch_1.scoreByTermFrequency)(terms, operation.bodyCounts),
|
|
95
|
+
}))
|
|
96
|
+
.filter(({ score }) => score > 0)
|
|
97
|
+
.sort((a, b) => b.score - a.score)
|
|
98
|
+
.slice(0, options.limit ?? 10)
|
|
99
|
+
.map(({ operation }) => toSummary(operation.endpoint));
|
|
100
|
+
}
|
|
101
|
+
read(service, method, path) {
|
|
102
|
+
const wantedMethod = method.toUpperCase();
|
|
103
|
+
return this.operations.find(({ endpoint }) => endpoint.service === service.app && endpoint.method === wantedMethod && endpoint.path === path)?.endpoint;
|
|
104
|
+
}
|
|
105
|
+
/** Paths of a service, for suggesting the right one when a read misses. */
|
|
106
|
+
paths(service) {
|
|
107
|
+
return this.operations
|
|
108
|
+
.filter(({ endpoint }) => endpoint.service === service.app)
|
|
109
|
+
.map(({ endpoint }) => `${endpoint.method} ${endpoint.path}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.ApiSpecsRepository = ApiSpecsRepository;
|
|
113
|
+
//# sourceMappingURL=apiSpecsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiSpecsRepository.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/api-specs/apiSpecsRepository.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,+BAA4B;AAC5B,qDAA8F;AAyC9F,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3F,MAAM,eAAe,GAAG,8CAA8C,CAAC;AACvE,mGAAmG;AACnG,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,SAAS,eAAe,CAAC,WAAW,GAAG,EAAE;IACvC,OAAO,WAAW;SACf,KAAK,CAAC,YAAY,CAAC;SACnB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;SAClC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,+GAA+G;AAC/G,SAAS,WAAW,CAAC,KAAc,EAAE,IAAmB,EAAE,YAAsB,EAAE;IAChF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,KAAsB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I,KAAK,IAAI,CACjH,EAAE,QAAQ,CAAC;IACd,CAAC;IAED,2EAA2E;IAC3E,KAAK,CAAC,OAA0B;QAC9B,OAAO,IAAI,CAAC,UAAU;aACnB,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC;aAC1D,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAjDD,gDAiDC"}
|
package/src/config.d.ts
CHANGED
|
@@ -7,5 +7,7 @@ export interface McpServerConfig {
|
|
|
7
7
|
/** Passed to Express `trust proxy`. */
|
|
8
8
|
trustedProxy: boolean | number | string;
|
|
9
9
|
corsOrigins: '*' | string[];
|
|
10
|
+
shutdownDelayMs: number;
|
|
11
|
+
shutdownTimeoutMs: number;
|
|
10
12
|
}
|
|
11
13
|
export declare function readConfig(env?: NodeJS.ProcessEnv): McpServerConfig;
|
package/src/config.js
CHANGED
|
@@ -35,6 +35,11 @@ function readCorsOrigins(env) {
|
|
|
35
35
|
return '*';
|
|
36
36
|
}
|
|
37
37
|
function readConfig(env = process.env) {
|
|
38
|
+
const shutdownDelayMs = readInteger(env, 'MCP_SHUTDOWN_DELAY_MS', 5000, 0);
|
|
39
|
+
const shutdownTimeoutMs = readInteger(env, 'MCP_SHUTDOWN_TIMEOUT_MS', 30000, 1);
|
|
40
|
+
if (shutdownDelayMs >= shutdownTimeoutMs) {
|
|
41
|
+
throw new Error(`MCP_SHUTDOWN_DELAY_MS (${shutdownDelayMs}) must be shorter than MCP_SHUTDOWN_TIMEOUT_MS (${shutdownTimeoutMs}).`);
|
|
42
|
+
}
|
|
38
43
|
return {
|
|
39
44
|
maxInFlight: readInteger(env, 'MCP_MAX_IN_FLIGHT', 64, 1),
|
|
40
45
|
inFlightWaitMs: readInteger(env, 'MCP_IN_FLIGHT_WAIT_MS', 1000, 0),
|
|
@@ -42,6 +47,8 @@ function readConfig(env = process.env) {
|
|
|
42
47
|
liveToolMaxConcurrent: readInteger(env, 'MCP_LIVE_TOOL_MAX_CONCURRENT', 8, 1),
|
|
43
48
|
trustedProxy: readTrustedProxy(env),
|
|
44
49
|
corsOrigins: readCorsOrigins(env),
|
|
50
|
+
shutdownDelayMs,
|
|
51
|
+
shutdownTimeoutMs,
|
|
45
52
|
};
|
|
46
53
|
}
|
|
47
54
|
//# sourceMappingURL=config.js.map
|
package/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/config.ts"],"names":[],"mappings":";;AAiDA,gCAmBC;AAvDD,SAAS,WAAW,CAAC,GAAsB,EAAE,IAAY,EAAE,YAAoB,EAAE,OAAe;IAC9F,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,mCAAmC,OAAO,aAAa,GAAG,IAAI,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAsB;IAC9C,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;IACzC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,aAAa,CAAC;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B,EAAE,EAAE,EAAE,CAAC,CAAC;QACzD,cAAc,EAAE,WAAW,CAAC,GAAG,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,kBAAkB,EAAE,WAAW,CAAC,GAAG,EAAE,2BAA2B,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1E,qBAAqB,EAAE,WAAW,CAAC,GAAG,EAAE,8BAA8B,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7E,YAAY,EAAE,gBAAgB,CAAC,GAAG,CAAC;QACnC,WAAW,EAAE,eAAe,CAAC,GAAG,CAAC;QACjC,eAAe;QACf,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
package/src/hosted.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Server as HttpServer } from 'http';
|
|
2
|
+
import { McpServerConfig } from './config';
|
|
3
|
+
import type { CreateAdspMcpServerOptions } from './server';
|
|
4
|
+
export interface StartMcpHttpServerOptions extends CreateAdspMcpServerOptions {
|
|
5
|
+
/** Defaults to `PORT`, then 3000. */
|
|
6
|
+
port?: number;
|
|
7
|
+
host?: string;
|
|
8
|
+
env?: NodeJS.ProcessEnv;
|
|
9
|
+
/** Defaults to `readConfig(env)`. */
|
|
10
|
+
config?: McpServerConfig;
|
|
11
|
+
/** Where SIGTERM and SIGINT arrive; defaults to `process`. */
|
|
12
|
+
signals?: NodeJS.EventEmitter;
|
|
13
|
+
exit?: (code: number) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface StartedMcpHttpServer {
|
|
16
|
+
httpServer: HttpServer;
|
|
17
|
+
port: number;
|
|
18
|
+
}
|
|
19
|
+
/** Runs the hosted HTTP server: metrics, the app, request deadlines, readiness and the graceful drain on signals. */
|
|
20
|
+
export declare function startMcpHttpServer({ port, host, env, config, signals, exit, ...serverOptions }?: StartMcpHttpServerOptions): Promise<StartedMcpHttpServer>;
|
package/src/hosted.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startMcpHttpServer = startMcpHttpServer;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const http_1 = require("./http");
|
|
6
|
+
const lifecycle_1 = require("./lifecycle");
|
|
7
|
+
const metrics_1 = require("./metrics");
|
|
8
|
+
/** Runs the hosted HTTP server: metrics, the app, request deadlines, readiness and the graceful drain on signals. */
|
|
9
|
+
async function startMcpHttpServer({ port, host, env = process.env, config = (0, config_1.readConfig)(env), signals = process, exit = (code) => process.exit(code), ...serverOptions } = {}) {
|
|
10
|
+
// Started before the app so the docs index build, which the app triggers, is recorded.
|
|
11
|
+
const metrics = await (0, metrics_1.startMetricsFromEnv)(env);
|
|
12
|
+
const lifecycle = (0, lifecycle_1.createLifecycle)();
|
|
13
|
+
const app = (0, http_1.createMcpHttpApp)({ ...serverOptions, config, lifecycle });
|
|
14
|
+
const httpServer = (0, http_1.createMcpHttpServer)(app);
|
|
15
|
+
await new Promise((resolveListening) => httpServer.listen(port ?? parseInt(env['PORT'] ?? '3000', 10), host, resolveListening));
|
|
16
|
+
const listeningPort = httpServer.address().port;
|
|
17
|
+
console.error(`[adsp-sdk-mcp-server] HTTP server listening on :${listeningPort}`);
|
|
18
|
+
const shutdown = (0, lifecycle_1.createGracefulShutdown)({
|
|
19
|
+
httpServer,
|
|
20
|
+
lifecycle,
|
|
21
|
+
delayMs: config.shutdownDelayMs,
|
|
22
|
+
timeoutMs: config.shutdownTimeoutMs,
|
|
23
|
+
flush: () => metrics?.shutdown() ?? Promise.resolve(),
|
|
24
|
+
exit,
|
|
25
|
+
});
|
|
26
|
+
signals.on('SIGTERM', shutdown);
|
|
27
|
+
signals.on('SIGINT', shutdown);
|
|
28
|
+
return { httpServer, port: listeningPort };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=hosted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted.js","sourceRoot":"","sources":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AAG,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE;QACrD,IAAI;KACL,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AAC7C,CAAC"}
|
package/src/http.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { Server as HttpServer } from 'http';
|
|
3
3
|
import { McpServerConfig } from './config';
|
|
4
|
+
import { ServerLifecycle } from './lifecycle';
|
|
4
5
|
import { CreateAdspMcpServerOptions } from './server';
|
|
5
6
|
export interface McpHttpAppOptions extends CreateAdspMcpServerOptions {
|
|
6
7
|
/** Defaults to `readConfig()` over `process.env`. */
|
|
7
8
|
config?: McpServerConfig;
|
|
9
|
+
/** Drives `/ready`; shutdown flips it. */
|
|
10
|
+
lifecycle?: ServerLifecycle;
|
|
8
11
|
}
|
|
9
|
-
export declare function createMcpHttpApp({ config, ...serverOptions }?: McpHttpAppOptions): express.Express;
|
|
12
|
+
export declare function createMcpHttpApp({ config, lifecycle, ...serverOptions }?: McpHttpAppOptions): express.Express;
|
|
10
13
|
export interface McpHttpServerOptions {
|
|
11
14
|
requestTimeoutMs?: number;
|
|
12
15
|
headersTimeoutMs?: number;
|
package/src/http.js
CHANGED
|
@@ -8,6 +8,7 @@ const http_1 = require("http");
|
|
|
8
8
|
const perf_hooks_1 = require("perf_hooks");
|
|
9
9
|
const config_1 = require("./config");
|
|
10
10
|
const guards_1 = require("./guards");
|
|
11
|
+
const lifecycle_1 = require("./lifecycle");
|
|
11
12
|
const metrics_1 = require("./metrics");
|
|
12
13
|
const semaphore_1 = require("./semaphore");
|
|
13
14
|
const server_1 = require("./server");
|
|
@@ -63,15 +64,35 @@ function methodNotAllowed(_req, res) {
|
|
|
63
64
|
.set('Allow', 'POST')
|
|
64
65
|
.json({ jsonrpc: '2.0', error: { code: -32000, message: 'Method not allowed.' }, id: null });
|
|
65
66
|
}
|
|
66
|
-
function createMcpHttpApp({ config = (0, config_1.readConfig)(), ...serverOptions } = {}) {
|
|
67
|
+
function createMcpHttpApp({ config = (0, config_1.readConfig)(), lifecycle = (0, lifecycle_1.createLifecycle)(), ...serverOptions } = {}) {
|
|
67
68
|
(0, server_1.loadAdspMcpTools)(serverOptions);
|
|
68
69
|
(0, liveToolLimit_1.configureLiveToolLimit)({ maxConcurrent: config.liveToolMaxConcurrent, waitMs: config.inFlightWaitMs });
|
|
69
70
|
// No express.json(): the transport reads the body so parse and size errors come back as JSON-RPC.
|
|
70
71
|
const app = express();
|
|
71
72
|
app.set('trust proxy', config.trustedProxy);
|
|
73
|
+
app.use((_req, res, next) => {
|
|
74
|
+
// Decided when the head is written, not on arrival, so a request already running when draining starts also tells
|
|
75
|
+
// its client not to reuse a socket that is about to close.
|
|
76
|
+
const writeHead = res.writeHead;
|
|
77
|
+
res.writeHead = function (...args) {
|
|
78
|
+
if (lifecycle.draining && !this.headersSent) {
|
|
79
|
+
this.setHeader('Connection', 'close');
|
|
80
|
+
}
|
|
81
|
+
return writeHead.apply(this, args);
|
|
82
|
+
};
|
|
83
|
+
next();
|
|
84
|
+
});
|
|
72
85
|
app.get('/health', (_req, res) => {
|
|
73
86
|
res.json({ status: 'ok' });
|
|
74
87
|
});
|
|
88
|
+
// The server listens only after the docs index is built, so this also fails while the index is loading.
|
|
89
|
+
app.get('/ready', (_req, res) => {
|
|
90
|
+
if (lifecycle.draining) {
|
|
91
|
+
res.status(503).json({ status: 'draining' });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
res.json({ status: 'ready' });
|
|
95
|
+
});
|
|
75
96
|
app.use('/mcp', (0, guards_1.createCorsAndOriginGuard)(config.corsOrigins));
|
|
76
97
|
app.post('/mcp', (0, guards_1.createRateLimit)(config.rateLimitPerMinute), (0, guards_1.createInFlightGate)(new semaphore_1.Semaphore(config.maxInFlight, { maxWaiters: config.maxInFlight }), config.inFlightWaitMs), createStatelessPostHandler(serverOptions));
|
|
77
98
|
app.get('/mcp', methodNotAllowed);
|
package/src/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/http.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/http.ts"],"names":[],"mappings":";;AA2EA,4CAiDC;AAYD,kDASC;AAjJD,0FAAmG;AACnG,mCAAmC;AACnC,+BAA0D;AAC1D,2CAAyC;AACzC,qCAAuD;AACvD,qCAAyF;AACzF,2CAA+D;AAC/D,uCAAwD;AACxD,2CAAwC;AACxC,qCAA6F;AAC7F,yDAA+D;AAE/D,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;AAS3C,SAAS,0BAA0B,CAAC,OAAmC;IACrE,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACxB,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAA,oBAAU,GAAE,CAAC;QAC7B,IAAI,MAAM,GAAG,UAAU,CAAC;QACxB,IAAI,YAAY,GAAG,CAAC,CAAC;QAErB,MAAM,MAAM,GAAG,IAAA,4BAAmB,EAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,IAAI,iDAA6B,CAAC;YAClD,kBAAkB,EAAE,SAAS;YAC7B,kBAAkB,EAAE,IAAI;YACxB,kBAAkB,EAAE,sBAAsB;SAC3C,CAAC,CAAC;QACH,kGAAkG;QAClG,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACnB,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,M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C1F,OAAO,IAAA,mBAAY,EACjB;QACE,cAAc,EAAE,OAAO,CAAC,gBAAgB,IAAI,MAAM;QAClD,cAAc,EAAE,OAAO,CAAC,gBAAgB,IAAI,MAAM;QAClD,2BAA2B,EAAE,OAAO,CAAC,6BAA6B,IAAI,KAAK;KAC5E,EACD,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -3,3 +3,5 @@ export type { AdspDoc, AdspDocSearchResult } from './docs/docsRepository';
|
|
|
3
3
|
export { SDK_REFERENCE } from './sdk-reference/reference';
|
|
4
4
|
export type { SdkSymbolDoc, SdkSymbolKind } from './sdk-reference/reference';
|
|
5
5
|
export { searchSdkReference } from './sdk-reference/search';
|
|
6
|
+
export { ApiSpecsRepository } from './api-specs/apiSpecsRepository';
|
|
7
|
+
export type { ApiEndpoint, ApiEndpointSummary, ApiServiceSummary } from './api-specs/apiSpecsRepository';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchSdkReference = exports.SDK_REFERENCE = exports.loadDocs = exports.DocsRepository = void 0;
|
|
3
|
+
exports.ApiSpecsRepository = exports.searchSdkReference = exports.SDK_REFERENCE = exports.loadDocs = exports.DocsRepository = void 0;
|
|
4
4
|
var docsRepository_1 = require("./docs/docsRepository");
|
|
5
5
|
Object.defineProperty(exports, "DocsRepository", { enumerable: true, get: function () { return docsRepository_1.DocsRepository; } });
|
|
6
6
|
Object.defineProperty(exports, "loadDocs", { enumerable: true, get: function () { return docsRepository_1.loadDocs; } });
|
|
@@ -8,4 +8,6 @@ var reference_1 = require("./sdk-reference/reference");
|
|
|
8
8
|
Object.defineProperty(exports, "SDK_REFERENCE", { enumerable: true, get: function () { return reference_1.SDK_REFERENCE; } });
|
|
9
9
|
var search_1 = require("./sdk-reference/search");
|
|
10
10
|
Object.defineProperty(exports, "searchSdkReference", { enumerable: true, get: function () { return search_1.searchSdkReference; } });
|
|
11
|
+
var apiSpecsRepository_1 = require("./api-specs/apiSpecsRepository");
|
|
12
|
+
Object.defineProperty(exports, "ApiSpecsRepository", { enumerable: true, get: function () { return apiSpecsRepository_1.ApiSpecsRepository; } });
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAiE;AAAxD,gHAAA,cAAc,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAEjC,uDAA0D;AAAjD,0GAAA,aAAa,OAAA;AAEtB,iDAA4D;AAAnD,4GAAA,kBAAkB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAiE;AAAxD,gHAAA,cAAc,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAEjC,uDAA0D;AAAjD,0GAAA,aAAa,OAAA;AAEtB,iDAA4D;AAAnD,4GAAA,kBAAkB,OAAA;AAC3B,qEAAoE;AAA3D,wHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Server as HttpServer } from 'http';
|
|
2
|
+
export interface ServerLifecycle {
|
|
3
|
+
readonly draining: boolean;
|
|
4
|
+
beginDrain(): void;
|
|
5
|
+
}
|
|
6
|
+
export declare function createLifecycle(): ServerLifecycle;
|
|
7
|
+
export interface GracefulShutdownOptions {
|
|
8
|
+
httpServer: HttpServer;
|
|
9
|
+
lifecycle: ServerLifecycle;
|
|
10
|
+
/** How long to keep serving after readiness fails, while the router stops sending traffic. */
|
|
11
|
+
delayMs: number;
|
|
12
|
+
/** Hard deadline from the signal to exit, even if a request never finishes. */
|
|
13
|
+
timeoutMs: number;
|
|
14
|
+
flush?: () => Promise<void>;
|
|
15
|
+
exit: (code: number) => void;
|
|
16
|
+
log?: (message: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function createGracefulShutdown({ httpServer, lifecycle, delayMs, timeoutMs, flush, exit, log, }: GracefulShutdownOptions): () => void;
|
package/src/lifecycle.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLifecycle = createLifecycle;
|
|
4
|
+
exports.createGracefulShutdown = createGracefulShutdown;
|
|
5
|
+
const IDLE_SWEEP_MS = 100;
|
|
6
|
+
function createLifecycle() {
|
|
7
|
+
let draining = false;
|
|
8
|
+
return {
|
|
9
|
+
get draining() {
|
|
10
|
+
return draining;
|
|
11
|
+
},
|
|
12
|
+
beginDrain() {
|
|
13
|
+
draining = true;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function createGracefulShutdown({ httpServer, lifecycle, delayMs, timeoutMs, flush = () => Promise.resolve(), exit, log = (message) => console.error(`[adsp-sdk-mcp-server] ${message}`), }) {
|
|
18
|
+
let started = false;
|
|
19
|
+
let exited = false;
|
|
20
|
+
let deadline;
|
|
21
|
+
const exitOnce = (code) => {
|
|
22
|
+
if (!exited) {
|
|
23
|
+
exited = true;
|
|
24
|
+
clearTimeout(deadline);
|
|
25
|
+
exit(code);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return () => {
|
|
29
|
+
if (started) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
started = true;
|
|
33
|
+
lifecycle.beginDrain();
|
|
34
|
+
log(`Shutting down: readiness off, draining for up to ${timeoutMs} ms.`);
|
|
35
|
+
deadline = setTimeout(() => {
|
|
36
|
+
log('Shutdown deadline reached with requests still running; exiting.');
|
|
37
|
+
exitOnce(1);
|
|
38
|
+
}, timeoutMs).unref();
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
// close() only drops connections idle right now; one whose request finishes later stays open as keep-alive.
|
|
41
|
+
const closeIdle = setInterval(() => httpServer.closeIdleConnections(), IDLE_SWEEP_MS).unref();
|
|
42
|
+
httpServer.close(() => {
|
|
43
|
+
clearInterval(closeIdle);
|
|
44
|
+
flush()
|
|
45
|
+
.catch(() => undefined)
|
|
46
|
+
.then(() => exitOnce(0));
|
|
47
|
+
});
|
|
48
|
+
httpServer.closeIdleConnections();
|
|
49
|
+
}, delayMs).unref();
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/lifecycle.ts"],"names":[],"mappings":";;AASA,0CAUC;AAcD,wDA4CC;AA3ED,MAAM,aAAa,GAAG,GAAG,CAAC;AAO1B,SAAgB,eAAe;IAC7B,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO;QACL,IAAI,QAAQ;YACV,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,UAAU;YACR,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC;AAcD,SAAgB,sBAAsB,CAAC,EACrC,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,EACT,KAAK,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAC/B,IAAI,EACJ,GAAG,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,yBAAyB,OAAO,EAAE,CAAC,GAC5C;IACxB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAoC,CAAC;IACzC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE;QAChC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,CAAC;YACd,YAAY,CAAC,QAAQ,CAAC,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,GAAG,EAAE;QACV,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO;QACT,CAAC;QACD,OAAO,GAAG,IAAI,CAAC;QACf,SAAS,CAAC,UAAU,EAAE,CAAC;QACvB,GAAG,CAAC,oDAAoD,SAAS,MAAM,CAAC,CAAC;QACzE,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;YACzB,GAAG,CAAC,iEAAiE,CAAC,CAAC;YACvE,QAAQ,CAAC,CAAC,CAAC,CAAC;QACd,CAAC,EAAE,SAAS,CAAC,CAAC,KAAK,EAAE,CAAC;QAEtB,UAAU,CAAC,GAAG,EAAE;YACd,4GAA4G;YAC5G,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,oBAAoB,EAAE,EAAE,aAAa,CAAC,CAAC,KAAK,EAAE,CAAC;YAC9F,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE;gBACpB,aAAa,CAAC,SAAS,CAAC,CAAC;gBACzB,KAAK,EAAE;qBACJ,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;qBACtB,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;YACH,UAAU,CAAC,oBAAoB,EAAE,CAAC;QACpC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
package/src/main.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
5
5
|
const config_1 = require("./config");
|
|
6
|
-
const
|
|
7
|
-
const metrics_1 = require("./metrics");
|
|
6
|
+
const hosted_1 = require("./hosted");
|
|
8
7
|
const server_1 = require("./server");
|
|
9
8
|
const liveToolLimit_1 = require("./tools/liveToolLimit");
|
|
10
9
|
function resolveTransport() {
|
|
@@ -19,7 +18,7 @@ async function main() {
|
|
|
19
18
|
const config = (0, config_1.readConfig)();
|
|
20
19
|
console.error(`[adsp-sdk-mcp-server] transport=${transport}`);
|
|
21
20
|
if (transport === 'http') {
|
|
22
|
-
await
|
|
21
|
+
await (0, hosted_1.startMcpHttpServer)({ config });
|
|
23
22
|
}
|
|
24
23
|
else {
|
|
25
24
|
(0, liveToolLimit_1.configureLiveToolLimit)({ maxConcurrent: config.liveToolMaxConcurrent, waitMs: config.inFlightWaitMs });
|
|
@@ -27,25 +26,6 @@ async function main() {
|
|
|
27
26
|
await server.connect(new stdio_js_1.StdioServerTransport());
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
async function startHttp(config) {
|
|
31
|
-
const port = parseInt(process.env['PORT'] ?? '3000', 10);
|
|
32
|
-
// Started before the app so the docs index build, which the app triggers, is recorded.
|
|
33
|
-
const metrics = await (0, metrics_1.startMetricsFromEnv)();
|
|
34
|
-
const app = (0, http_1.createMcpHttpApp)({ config });
|
|
35
|
-
return new Promise((resolve) => {
|
|
36
|
-
const httpServer = (0, http_1.createMcpHttpServer)(app).listen(port, () => {
|
|
37
|
-
console.error(`[adsp-sdk-mcp-server] HTTP server listening on :${port}`);
|
|
38
|
-
resolve();
|
|
39
|
-
});
|
|
40
|
-
function shutdown() {
|
|
41
|
-
const flushed = metrics?.shutdown().catch(() => undefined) ?? Promise.resolve();
|
|
42
|
-
httpServer.close(() => flushed.then(() => process.exit(0)));
|
|
43
|
-
setTimeout(() => process.exit(1), 5_000).unref();
|
|
44
|
-
}
|
|
45
|
-
process.on('SIGTERM', shutdown);
|
|
46
|
-
process.on('SIGINT', shutdown);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
29
|
main().catch((err) => {
|
|
50
30
|
console.error('Failed to start adsp-sdk-mcp-server:', err);
|
|
51
31
|
process.exit(1);
|
package/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/main.ts"],"names":[],"mappings":";;;AACA,wEAAiF;AACjF,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/main.ts"],"names":[],"mappings":";;;AACA,wEAAiF;AACjF,qCAAsC;AACtC,qCAA8C;AAC9C,qCAA+C;AAC/C,yDAA+D;AAI/D,SAAS,gBAAgB;IACvB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC;IACpD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,GAAG,CAAC;IAClD,OAAO,CAAC,KAAK,CAAC,gDAAgD,GAAG,oDAAoD,CAAC,CAAC;IACvH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,OAAO,CAAC,KAAK,CAAC,mCAAmC,SAAS,EAAE,CAAC,CAAC;IAE9D,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,IAAA,2BAAkB,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,IAAA,sCAAsB,EAAC,EAAE,aAAa,EAAE,MAAM,CAAC,qBAAqB,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QACvG,MAAM,MAAM,GAAG,IAAA,4BAAmB,GAAE,CAAC;QACrC,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,+BAAoB,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAA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