@abgov/adsp-sdk-mcp-server 1.13.0 → 1.15.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.
@@ -13,16 +13,24 @@ Value service provides an append only time series data store. It serves as the u
13
13
 
14
14
  client `urn:ads:platform:value-service`
15
15
 
16
- | name | description |
17
- | :----------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18
- | value-reader | Reader role for value service. This role is used to allow users to read values from the values. It is part of the tenant-admin composite role and allows tenant administrators to read and search the event log. |
19
- | value-writer | Writer role for value service. This role is used to allow service accounts to write values to the value service. |
16
+ | name | description |
17
+ | :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18
+ | value-reader | Reader role for value service. This role is used to allow users to read values and value definitions. It is part of the tenant-admin composite role and allows tenant administrators to read and search the event log. |
19
+ | value-writer | Writer role for value service. This role is used to allow service accounts to write values to the value service. It also allows users to create, update and delete value definitions, and to read them, since a user with the writer role can also read. |
20
20
 
21
21
  ## Concepts
22
22
 
23
23
  ### Value definition
24
24
 
25
- Value definition is an optional metadata description for a particular _value_ (identified by a specific namespace and name). The definition provides write-time validation via json schema. Value definitions are configured in the [configuration service](configuration-service.md) under the `platform:value-service` namespace and name.
25
+ Value definition is an optional metadata description for a particular _value_ (identified by a specific namespace and name). The definition provides write-time validation via json schema, and can enable a `value-written` event on each write with `sendWriteEvent`.
26
+
27
+ Value definitions are managed through the value service definitions API (`/value/v1/definitions`). The value service checks the user's roles and then stores the definitions in the [configuration service](configuration-service.md) under the `platform:value-service` namespace and name, using its own service account. Clients do not need configuration service roles to manage value definitions.
28
+
29
+ - Reading definitions requires `value-reader` or `value-writer`. Listing returns tenant and core definitions separately; getting a single definition returns the tenant definition if one exists, otherwise the core definition, with `isCore` indicating which.
30
+ - Creating, updating and deleting definitions requires `value-writer` and applies to tenant definitions only. Core definitions are read-only through this API.
31
+ - The `jsonSchema` of a created or updated definition must be a valid JSON schema, otherwise the request is rejected with a 400.
32
+ - Creating a definition adds its namespace if it does not exist, and fails with a 409 if a tenant or core definition with the same namespace and name already exists.
33
+ - Deleting the last definition in a namespace removes the namespace.
26
34
 
27
35
  ### Value
28
36
 
@@ -32,27 +40,35 @@ A value represents a particular time series stream. Each write results in a new
32
40
 
33
41
  Metrics are numeric values that can be included in value writes. The are automatically included in time interval aggregations and can be used for basic KPIs.
34
42
 
35
- ### Continuous aggregate backfill
43
+ ### Metric interval rollups
36
44
 
37
- Metric continuous aggregates are created without historical data so that service deployment does not trigger an unbounded database refresh. After deploying the migration, populate each aggregate in windows of no more than 31 days:
45
+ Reading a metric interval aggregates the `metrics` table on every request, which gets slow as history grows. The `metric_interval_rollups` table stores each interval's buckets so those reads become a keyed lookup, and a scheduled job keeps it current.
38
46
 
39
- ```sql
40
- CALL backfill_metric_continuous_aggregate(
41
- 'metrics_daily_continuous',
42
- '2026-01-01T00:00:00Z',
43
- '2026-02-01T00:00:00Z'
44
- );
45
- ```
47
+ The job runs every five minutes and moves one interval's coverage by at most a chunk in each direction: forward from where coverage ended, so recent buckets stay fresh, and backward through history, so an interval that has never been rolled up fills in over successive runs. Both windows touch the existing coverage, which keeps `metric_interval_rollup_coverage` a single contiguous span per interval.
48
+
49
+ Reads consult that coverage. A request whose window falls entirely inside it is served from the rollups; anything reaching outside falls back to a live aggregate of the raw `metrics` table, which is slower but always complete, so rollups can be populated progressively without the API losing data in the meantime.
50
+
51
+ The end of a requested window is first snapped back to the start of the interval in progress, so only whole periods are ever served: a `monthly` request made on 17 September returns August as its most recent bucket rather than seventeen days of September, and the bound actually used comes back as `page.intervalMax` so a shortened window is distinguishable from one that simply holds no data. Snapping is what lets coverage satisfy a request reaching up to "now" — a composed interval's rollup can never contain its own open bucket, so without it every such read missed on the trailing edge and fell back to a live aggregate of the whole window.
52
+
53
+ Each interval is aggregated from the next finer one, and only `one_minute` reads the raw `metrics` table. `sum`, `count`, `min` and `max` all compose — a month's sum is the sum of its days' sums, its min the least of their mins — so a monthly bucket is built from about thirty daily rows rather than a month of raw metrics. That is why the rollups store those four and derive the average on read: an average of averages would not compose. Both `weekly` and `monthly` build from `daily`, because a week can straddle a month boundary and so does not nest inside one.
46
54
 
47
- Run windows from the oldest metric timestamp forward for each of `metrics_one_minute_continuous`, `metrics_five_minutes_continuous`, `metrics_hourly_continuous`, `metrics_daily_continuous`, `metrics_weekly_continuous`, and `metrics_monthly_continuous`. Completed windows are recorded and skipped when called again:
55
+ An interval can only advance as far as its source has been rolled up, so coverage fills from the finest interval outwards and a coarse interval waits, logging at debug, until its source has something to build from.
56
+
57
+ `METRIC_INTERVAL_ROLLUP_MAX_CHUNK_HOURS` caps every interval's window, and defaults to a week. It cannot cut a window below a single bucket, since an interval whose chunk is narrower than its bucket would never finish backfilling. A composed interval's read cost follows the number of rollup rows rather than the span of time it covers, but what it writes does not: the upsert groups by namespace, name, tenant and metric as well as the bucket, so a wide window can still write one row per bucket per distinct series in a single statement — enough, on a tenant-heavy deployment, to exhaust the database's shared lock table even though no relation the query touches is itself large. Capping every interval's window keeps that upsert bounded the same way it keeps `one_minute`'s raw scan bounded.
58
+
59
+ Intervals advance one at a time, each in its own transaction under a Postgres advisory lock, so of the replicas that all schedule the job, whichever gets the lock advances that interval and the rest skip it; within a replica, a tick arriving while the last run is still going is skipped as well. Committing per interval is what keeps the job making progress: an interval that exceeds `METRIC_INTERVAL_ROLLUP_STATEMENT_TIMEOUT_MS` rolls back only itself and is logged by name, while the intervals that already succeeded stay committed. `DB_POOL_MAX` bounds how many connections a replica can hold at all — worth setting deliberately, since it is multiplied by the replica count against one database.
60
+
61
+ Coverage is recorded in whole buckets: both edges are snapped down to a bucket boundary, so the bucket currently being written to is never advertised as rolled up. Reads of a window that includes it fall back to the `metrics_*` views, which is what keeps a partially totalled bucket from being served as a complete one.
62
+
63
+ Set `METRIC_INTERVAL_ROLLUP_JOB_ENABLED=false` to stop the job. Reads keep working — they fall back to the views — but the rollups stop advancing and stale coverage will gradually stop matching incoming requests.
48
64
 
49
65
  ```sql
50
- SELECT *
51
- FROM metric_continuous_aggregate_backfills
52
- ORDER BY aggregate_name, window_start;
66
+ SELECT "interval", covered_from, covered_to, updated_at
67
+ FROM metric_interval_rollup_coverage
68
+ ORDER BY "interval";
53
69
  ```
54
70
 
55
- Before continuing with the next window, monitor the database load and compare aggregate values against the equivalent `time_bucket` query over `metrics`. Automatic refresh policies keep recent completed buckets current; they do not replace the historical backfill.
71
+ Rollups store `sum` and `count` rather than an average, because an average of averages is not the average; the read path divides the two.
56
72
 
57
73
  ## Code examples
58
74
 
@@ -94,3 +110,69 @@ const response = await fetch(`https://value-service.adsp.alberta.ca/value/v1/${n
94
110
 
95
111
  const { results, page } = await response.json();
96
112
  ```
113
+
114
+ ### Create a value definition
115
+
116
+ ```typescript
117
+ const response = await fetch('https://value-service.adsp.alberta.ca/value/v1/definitions', {
118
+ method: 'POST',
119
+ headers: {
120
+ Authorization: `Bearer ${accessToken}`,
121
+ 'Content-Type': 'application/json',
122
+ },
123
+ body: JSON.stringify({
124
+ namespace: 'support',
125
+ name: 'application-stats',
126
+ description: 'Statistics for support applications.',
127
+ jsonSchema: {
128
+ type: 'object',
129
+ properties: { property: { type: 'number' } },
130
+ },
131
+ sendWriteEvent: false,
132
+ }),
133
+ });
134
+
135
+ const { namespace, name, jsonSchema, isCore } = await response.json();
136
+ ```
137
+
138
+ ### Read value definitions
139
+
140
+ ```typescript
141
+ const response = await fetch('https://value-service.adsp.alberta.ca/value/v1/definitions', {
142
+ method: 'GET',
143
+ headers: { Authorization: `Bearer ${accessToken}` },
144
+ });
145
+
146
+ // Each is a map of namespace name to { name, definitions }.
147
+ const { tenant, core } = await response.json();
148
+ ```
149
+
150
+ ### Update a value definition
151
+
152
+ Properties not included in the request are left unchanged.
153
+
154
+ ```typescript
155
+ const namespace = 'support';
156
+ const name = 'application-stats';
157
+ const response = await fetch(`https://value-service.adsp.alberta.ca/value/v1/definitions/${namespace}/${name}`, {
158
+ method: 'PATCH',
159
+ headers: {
160
+ Authorization: `Bearer ${accessToken}`,
161
+ 'Content-Type': 'application/json',
162
+ },
163
+ body: JSON.stringify({ description: 'Updated statistics for support applications.' }),
164
+ });
165
+ ```
166
+
167
+ ### Delete a value definition
168
+
169
+ ```typescript
170
+ const namespace = 'support';
171
+ const name = 'application-stats';
172
+ const response = await fetch(`https://value-service.adsp.alberta.ca/value/v1/definitions/${namespace}/${name}`, {
173
+ method: 'DELETE',
174
+ headers: { Authorization: `Bearer ${accessToken}` },
175
+ });
176
+
177
+ const { deleted } = await response.json();
178
+ ```
@@ -32,6 +32,12 @@ Sometimes a specific answer to a question will influence the flow of the form. A
32
32
 
33
33
  Jsonforms automatically handles basic input validation, such as ensuring required fields are filled in, dates are formatted correctly, or that numbers are, indeed, numbers. More sophisticated validation is also possible; you can add [custom error messages](https://jsonforms.io/docs/validation/) or even [integrate a custom AJV validator](https://jsonforms.io/docs/validation/) to [harness the full power of AJV](https://ajv.js.org/), which gives you complete control over validation.
34
34
 
35
+ ### Text input format patterns
36
+
37
+ Text fields can format values with a mask while the user types, or only on blur. Built-in named formats (`phone`, `sin`, `postalCode`, `driverId`, `mvid`) are selected with JSON schema `format`. For any other layout, add a custom `mask` on the UI schema control (and keep a JSON schema `pattern` for validation). Set `inPlace: true` to show the fill-in template in the field.
38
+
39
+ See [Text Input Control Options](/adsp-monorepo/tutorials/form-service/cheat-sheet.html#text-input-control-options) for named formats, custom mask examples, in-place behaviour, and how to register a new named format in code.
40
+
35
41
  #### Required Fields
36
42
 
37
43
  There is a known issue in jsonforms that allows an empty string to satisfy the required validation rule. To work around this, you should also add a minimum length of 1 to required string fields, e.g.
@@ -411,6 +411,147 @@ The date control supports these options to restrict date selection:
411
411
  </tr>
412
412
  </table>
413
413
 
414
+ #### Text Input Control Options
415
+
416
+ Text inputs can format values with a mask. A mask is a template: placeholder characters (`#`, `*`, or `_`) each consume one letter or digit from the input, and every other character is inserted as a literal (spaces, dashes, parentheses).
417
+
418
+ There are three ways to apply a mask. Use a built-in named format when one already matches the field. Use a custom `mask` when you need a different layout. Use `formatPattern` only when you want formatting on blur and not while the user is typing.
419
+
420
+ <table>
421
+ <tr>
422
+ <th>Option</th>
423
+ <th>Location</th>
424
+ <th>Behavior</th>
425
+ <th>Default</th>
426
+ </tr>
427
+ <tr>
428
+ <td><code>format</code></td>
429
+ <td>JSON schema</td>
430
+ <td>Selects a built-in named format (<code>phone</code>, <code>sin</code>, <code>postalCode</code>, <code>driverId</code>, <code>mvid</code>). The control formats as the user types, restricts allowed keys, and validates against the named pattern.</td>
431
+ <td>Not set</td>
432
+ </tr>
433
+ <tr>
434
+ <td><code>mask</code></td>
435
+ <td>UI schema <code>options</code></td>
436
+ <td>A custom mask template applied while typing, e.g. <code>####-##</code>. Use this when the field is not one of the built-in formats. A named <code>schema.format</code> takes precedence over this option.</td>
437
+ <td>Not set</td>
438
+ </tr>
439
+ <tr>
440
+ <td><code>inPlace</code></td>
441
+ <td>UI schema <code>options</code></td>
442
+ <td>When <code>true</code> and a mask is present, the field shows the fill-in template (for example <code>(###) ###-####</code>) and keeps the caret in place. Extra characters are rejected once every placeholder is filled. In-place fields do not use <code>maxLength</code> because the template is already full length.</td>
443
+ <td><code>false</code></td>
444
+ </tr>
445
+ <tr>
446
+ <td><code>formatPattern</code></td>
447
+ <td>UI schema <code>options</code></td>
448
+ <td>A mask template applied only when the field loses focus (on blur), e.g. <code>(###) ###-####</code>. Formatting only; validation is still driven by the JSON schema <code>pattern</code>.</td>
449
+ <td>Not set</td>
450
+ </tr>
451
+ </table>
452
+
453
+ ##### Built-in named formats
454
+
455
+ Set <code>format</code> on the JSON schema property. The control then uses the matching mask, allowed keys, and validation pattern.
456
+
457
+ | `schema.format` | Mask | Allowed input | Example value |
458
+ | --------------- | ---------------- | ------------------ | ---------------- |
459
+ | `phone` | `(###) ###-####` | Digits | `(403) 555-1212` |
460
+ | `sin` | `### ### ###` | Digits | `123 456 789` |
461
+ | `postalCode` | `### ###` | Letters and digits | `T2P 1A1` |
462
+ | `driverId` | `######-###` | Digits | `123456-789` |
463
+ | `mvid` | `####-#####` | Digits | `1234-56789` |
464
+
465
+ ```json
466
+ {
467
+ "driverLicence": {
468
+ "type": "string",
469
+ "format": "driverId"
470
+ }
471
+ }
472
+ ```
473
+
474
+ ```json
475
+ {
476
+ "type": "Control",
477
+ "scope": "#/properties/driverLicence",
478
+ "options": {
479
+ "inPlace": true
480
+ }
481
+ }
482
+ ```
483
+
484
+ ##### Custom mask (not a built-in format)
485
+
486
+ Add a <code>mask</code> on the UI schema control when the value should be formatted while typing but is not one of the named formats. Keep a JSON schema <code>pattern</code> (and optional <code>errorMessage</code>) so the formatted value is still validated.
487
+
488
+ ```json
489
+ {
490
+ "accountNumber": {
491
+ "type": "string",
492
+ "pattern": "^[0-9]{4}-[0-9]{2}$",
493
+ "errorMessage": "Must be in format 0000-00"
494
+ }
495
+ }
496
+ ```
497
+
498
+ ```json
499
+ {
500
+ "type": "Control",
501
+ "scope": "#/properties/accountNumber",
502
+ "options": {
503
+ "mask": "####-##",
504
+ "inPlace": true
505
+ }
506
+ }
507
+ ```
508
+
509
+ Mask rules:
510
+
511
+ - Placeholders `#`, `*`, and `_` each take one letter or digit.
512
+ - Any other character in the mask is a literal separator.
513
+ - Extra content beyond the number of placeholders is discarded (in-place fields restore the previous value instead of keeping the extra character).
514
+ - Named formats also restrict keystrokes (digits only, or letters and digits for postal code). A custom `mask` without a named format does not restrict which characters can be typed; use `schema.pattern` for validation.
515
+
516
+ ##### Format on blur only
517
+
518
+ Use <code>formatPattern</code> when the field should stay unformatted while typing and only apply the mask when it loses focus. Validation still comes from the JSON schema <code>pattern</code>.
519
+
520
+ | Mask (`formatPattern`) | User enters | Formatted on blur |
521
+ | ---------------------- | ------------ | ----------------- |
522
+ | `(###) ###-####` | `7801234567` | `(780) 123-4567` |
523
+ | `######-###` | `123456789` | `123456-789` |
524
+ | `### ###` | `A1A1A1` | `A1A 1A1` |
525
+ | `### ### ###` | `123456789` | `123 456 789` |
526
+
527
+ ```json
528
+ {
529
+ "type": "Control",
530
+ "scope": "#/properties/phone",
531
+ "options": {
532
+ "formatPattern": "(###) ###-####"
533
+ }
534
+ }
535
+ ```
536
+
537
+ ##### Adding a new named format in code
538
+
539
+ Form definitions can only use the built-in names above or a per-field <code>mask</code>. To register a new reusable named format for all forms, add it to <code>DEFAULT_PATTERNS</code> in <code>libs/jsonforms-components/src/lib/util/patternForm.ts</code>:
540
+
541
+ ```ts
542
+ export const DEFAULT_PATTERNS: Record<string, MaskPattern> = {
543
+ // ...
544
+ accountNumber: {
545
+ mask: '####-##',
546
+ pattern: /^\d{4}-\d{2}$/,
547
+ error: 'Must be in format 0000-00',
548
+ allowedKeys: /[0-9]/,
549
+ },
550
+ };
551
+ ```
552
+
553
+ `createDefaultAjv` registers every `DEFAULT_PATTERNS` key as a JSON schema format automatically. After that, form definitions can set `"format": "accountNumber"` the same way as `phone` or `driverId`.
554
+
414
555
  #### Calculation Control
415
556
 
416
557
  The calculation control is rendered when the JSON schema field uses <code>"format": "computed"</code>. The expression is defined in <code>schema.description</code>, evaluated against current form data, and the result is written back to the control path automatically. The rendered field is read-only.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/adsp-sdk-mcp-server",
3
- "version": "1.13.0",
3
+ "version": "1.15.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",
@@ -10,6 +10,7 @@
10
10
  "dependencies": {
11
11
  "@abgov/adsp-cli": "^1.7.0",
12
12
  "@modelcontextprotocol/sdk": "^1.29.0",
13
+ "express": "^4.21.0",
13
14
  "tslib": "^2.3.0",
14
15
  "zod": "^3.25.76"
15
16
  },
package/src/main.js CHANGED
@@ -2,14 +2,123 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
5
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
6
+ const express = require("express");
7
+ const crypto_1 = require("crypto");
5
8
  const server_1 = require("./server");
9
+ function resolveTransport() {
10
+ const raw = process.env['MCP_TRANSPORT'] ?? 'stdio';
11
+ if (raw === 'stdio' || raw === 'http')
12
+ return raw;
13
+ console.error(`[adsp-sdk-mcp-server] Unknown MCP_TRANSPORT="${raw}". Valid values: stdio, http. Defaulting to stdio.`);
14
+ return 'stdio';
15
+ }
6
16
  async function main() {
7
- const server = (0, server_1.createAdspMcpServer)();
8
- const transport = new stdio_js_1.StdioServerTransport();
9
- await server.connect(transport);
17
+ const transport = resolveTransport();
18
+ console.error(`[adsp-sdk-mcp-server] transport=${transport} sessionTtlMs=${SESSION_TTL_MS}`);
19
+ if (transport === 'http') {
20
+ await startHttp();
21
+ }
22
+ else {
23
+ const server = (0, server_1.createAdspMcpServer)();
24
+ await server.connect(new stdio_js_1.StdioServerTransport());
25
+ }
26
+ }
27
+ const SESSION_TTL_MS = parseInt(process.env['SESSION_TTL_MINUTES'] ?? '30', 10) * 60 * 1000;
28
+ async function startHttp() {
29
+ const port = parseInt(process.env['PORT'] ?? '3000', 10);
30
+ const app = express();
31
+ app.use(express.json({ limit: '1mb' }));
32
+ app.use((_req, res, next) => {
33
+ res.setHeader('Access-Control-Allow-Origin', process.env['CORS_ORIGIN'] ?? '*');
34
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
35
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, mcp-session-id');
36
+ res.setHeader('Access-Control-Expose-Headers', 'mcp-session-id');
37
+ if (_req.method === 'OPTIONS') {
38
+ res.sendStatus(204);
39
+ return;
40
+ }
41
+ next();
42
+ });
43
+ app.get('/health', (_req, res) => {
44
+ res.json({ status: 'ok' });
45
+ });
46
+ const sessions = new Map();
47
+ const cleanupTimer = setInterval(() => {
48
+ const now = Date.now();
49
+ for (const [id, entry] of sessions) {
50
+ if (now - entry.lastActivity > SESSION_TTL_MS) {
51
+ sessions.delete(id);
52
+ entry.server.close();
53
+ }
54
+ }
55
+ }, 60_000);
56
+ cleanupTimer.unref();
57
+ app.post('/mcp', async (req, res) => {
58
+ const sessionId = req.headers['mcp-session-id'];
59
+ if (sessionId && sessions.has(sessionId)) {
60
+ const entry = sessions.get(sessionId);
61
+ entry.lastActivity = Date.now();
62
+ await entry.transport.handleRequest(req, res, req.body);
63
+ return;
64
+ }
65
+ const newId = (0, crypto_1.randomUUID)();
66
+ const sessionServer = (0, server_1.createAdspMcpServer)();
67
+ const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
68
+ sessionIdGenerator: () => newId,
69
+ onsessioninitialized: (id) => {
70
+ sessions.set(id, { server: sessionServer, transport, lastActivity: Date.now() });
71
+ },
72
+ });
73
+ transport.onclose = () => {
74
+ const found = [...sessions.entries()].find(([, e]) => e.transport === transport);
75
+ if (found) {
76
+ sessions.delete(found[0]);
77
+ found[1].server.close();
78
+ }
79
+ };
80
+ await sessionServer.connect(transport);
81
+ await transport.handleRequest(req, res, req.body);
82
+ });
83
+ app.get('/mcp', async (req, res) => {
84
+ const sessionId = req.headers['mcp-session-id'];
85
+ if (!sessionId || !sessions.has(sessionId)) {
86
+ res.status(400).json({ error: 'Invalid or missing session ID' });
87
+ return;
88
+ }
89
+ const entry = sessions.get(sessionId);
90
+ entry.lastActivity = Date.now();
91
+ await entry.transport.handleRequest(req, res);
92
+ });
93
+ app.delete('/mcp', async (req, res) => {
94
+ const sessionId = req.headers['mcp-session-id'];
95
+ if (!sessionId || !sessions.has(sessionId)) {
96
+ res.status(400).json({ error: 'Invalid or missing session ID' });
97
+ return;
98
+ }
99
+ const entry = sessions.get(sessionId);
100
+ sessions.delete(sessionId);
101
+ await entry.transport.handleRequest(req, res);
102
+ });
103
+ return new Promise((resolve) => {
104
+ const httpServer = app.listen(port, () => {
105
+ console.error(`[adsp-sdk-mcp-server] HTTP server listening on :${port}`);
106
+ resolve();
107
+ });
108
+ function shutdown() {
109
+ clearInterval(cleanupTimer);
110
+ for (const [id, entry] of sessions) {
111
+ sessions.delete(id);
112
+ entry.server.close();
113
+ }
114
+ httpServer.close(() => process.exit(0));
115
+ setTimeout(() => process.exit(1), 5_000).unref();
116
+ }
117
+ process.on('SIGTERM', shutdown);
118
+ process.on('SIGINT', shutdown);
119
+ });
10
120
  }
11
121
  main().catch((err) => {
12
- // eslint-disable-next-line no-console
13
122
  console.error('Failed to start adsp-sdk-mcp-server:', err);
14
123
  process.exit(1);
15
124
  });
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,qCAA+C;AAE/C,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAA,4BAAmB,GAAE,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/main.ts"],"names":[],"mappings":";;;AACA,wEAAiF;AACjF,0FAAmG;AAEnG,mCAAmC;AACnC,mCAAoC;AACpC,qCAA+C;AAI/C,SAAS,gBAAgB;IACvB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC;IACpD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,MAA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