@abgov/adsp-sdk-mcp-server 1.20.2 → 1.21.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.
Files changed (55) hide show
  1. package/README.md +5 -0
  2. package/assets/docs/platform/deployment.md +0 -1
  3. package/assets/docs/platform/getting-started.md +0 -1
  4. package/assets/docs/platform/operations.md +0 -1
  5. package/assets/docs/platform/platform-django-sdk.md +0 -1
  6. package/assets/docs/platform/platform-dotnet-sdk.md +0 -1
  7. package/assets/docs/platform/platform-flask-sdk.md +0 -1
  8. package/assets/docs/platform/platform-node-sdk.md +0 -1
  9. package/assets/docs/platform/platform-spring-sdk.md +0 -1
  10. package/assets/docs/services/access-service-backup-disaster-recovery.md +0 -1
  11. package/assets/docs/services/access-service.md +0 -1
  12. package/assets/docs/services/agent-service.md +0 -1
  13. package/assets/docs/services/cache-service.md +111 -24
  14. package/assets/docs/services/calendar-service.md +96 -18
  15. package/assets/docs/services/comment-service.md +179 -49
  16. package/assets/docs/services/configuration-service.md +0 -1
  17. package/assets/docs/services/directory-service.md +129 -16
  18. package/assets/docs/services/event-service.md +0 -1
  19. package/assets/docs/services/export-service.md +135 -0
  20. package/assets/docs/services/feedback-service.md +46 -10
  21. package/assets/docs/services/file-service.md +0 -1
  22. package/assets/docs/services/form-service.md +0 -1
  23. package/assets/docs/services/notification-service.md +0 -1
  24. package/assets/docs/services/pdf-service.md +113 -44
  25. package/assets/docs/services/pii-service.md +0 -1
  26. package/assets/docs/services/project-planner-service.md +215 -43
  27. package/assets/docs/services/push-service.md +159 -73
  28. package/assets/docs/services/status-service.md +0 -1
  29. package/assets/docs/services/task-service.md +262 -99
  30. package/assets/docs/services/tenant-service.md +113 -2
  31. package/assets/docs/services/token-handler.md +0 -1
  32. package/assets/docs/services/value-service.md +13 -1
  33. package/assets/docs/services/verify-service.md +60 -36
  34. package/assets/docs/tutorials/access-service/access-service.md +0 -1
  35. package/assets/docs/tutorials/feedback-service/feedback-service.md +0 -1
  36. package/assets/docs/tutorials/file-service/file-service.md +0 -1
  37. package/assets/docs/tutorials/form-service/form-service.md +0 -1
  38. package/assets/docs/tutorials/notification-service/notification-service.md +0 -1
  39. package/assets/docs/tutorials/pdf-service/building-a-template.md +2 -2
  40. package/assets/docs/tutorials/pdf-service/generate-a-pdf.md +17 -10
  41. package/assets/docs/tutorials/pdf-service/pdf-service.md +0 -1
  42. package/assets/docs/tutorials/status-service/status-service.md +0 -1
  43. package/assets/docs/tutorials/task-service/introduction.md +1 -1
  44. package/assets/docs/tutorials/task-service/task-definitions.md +1 -1
  45. package/assets/docs/tutorials/task-service/task-queues.md +13 -11
  46. package/assets/docs/tutorials/task-service/task-service.md +0 -1
  47. package/package.json +1 -1
  48. package/src/http.d.ts +10 -0
  49. package/src/http.js +105 -0
  50. package/src/http.js.map +1 -0
  51. package/src/main.js +4 -82
  52. package/src/main.js.map +1 -1
  53. package/src/server.d.ts +6 -0
  54. package/src/server.js +17 -6
  55. package/src/server.js.map +1 -1
@@ -1,61 +1,85 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Verify service
4
- nav_order: 10
5
4
  parent: Services
6
5
  ---
7
6
 
8
7
  # Verify service
8
+
9
9
  Verify service provides time limited random codes that can be used for validation purposes. For example, generated codes can be sent to a user by email and requested from an application to verify user access to the email inbox.
10
10
 
11
11
  ## Client roles
12
+
12
13
  client `urn:ads:platform:verify-service`
13
14
 
14
- | name | description |
15
- |:-|:-|
15
+ | name | description |
16
+ | :------------- | :---------------------------------------------------------------------------------------------------------- |
16
17
  | code-generator | Code generator role for verify service. This role allows a service account to generate a new code at a key. |
17
- | code-verifier | Code verifier role for verify service. This role allows a service account to verify a code against a key. |
18
+ | code-verifier | Code verifier role for verify service. This role allows a service account to verify a code against a key. |
19
+
20
+ ## Tenancy
21
+
22
+ - **Which tenant is used.** Tenant users and service accounts generate and verify codes in the tenant of their token, and need the role in that tenant. Core (platform) users with the role in the core realm use a separate core namespace. Verify service doesn't support the `tenantId` query parameter.
23
+ - **Isolation.** Keys are unique within a tenant, so two tenants can use the same key without conflict. A code generated in one tenant can't be verified from another tenant; the verification responds 200 with `verified: false`, as it does for a key that has no code.
24
+
25
+ ## API overview
26
+
27
+ All endpoints are under `https://verify-service.adsp.alberta.ca/verify/v1`. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
28
+
29
+ | Endpoint | Purpose | Required role |
30
+ | :---------------------------- | :--------------------------------------------- | :--------------- |
31
+ | `POST /verify/v1/codes/{key}` | Generate a new code at a key (no `code` sent). | `code-generator` |
32
+ | `POST /verify/v1/codes/{key}` | Verify a code at a key (`code` in the body). | `code-verifier` |
33
+
34
+ ## Concepts
35
+
36
+ ### Key
37
+
38
+ A key identifies what a code verifies, for example an email address or SMS number of a user. Keys are 1 to 50 characters and unique within a tenant. Generating a code at a key replaces any existing code at that key.
39
+
40
+ ### Code
41
+
42
+ A code is a random 6 character string of characters that are easy to tell apart. A code is valid for 10 minutes by default; set the `expireIn` query parameter to the number of minutes it should be valid for. Each failed verification is counted, and the code is cleared after 10 failed verifications. After a code expires or is cleared, verifications respond with `verified: false` until a new code is generated at the key.
43
+
44
+ ## Events
45
+
46
+ Verify service does not send or consume domain events.
18
47
 
19
48
  ## Code examples
49
+
20
50
  ### Generate a code
51
+
21
52
  Generate a time limited code at a particular key with an optional valid duration query parameter.
22
53
 
23
54
  ```typescript
24
- const response = await fetch(
25
- `https://verify-service.adsp.alberta.ca/verify/v1/codes/${codeKey}?expireIn=${validMinutes}`,
26
- {
27
- method: 'POST',
28
- headers: {
29
- 'Authorization': `Bearer ${accessToken}`,
30
- },
31
- }
32
- );
33
-
34
- const {
35
- key,
36
- code,
37
- expiresAt,
38
- } = await response.json();
55
+ const response = await fetch(
56
+ `https://verify-service.adsp.alberta.ca/verify/v1/codes/${codeKey}?expireIn=${validMinutes}`,
57
+ {
58
+ method: 'POST',
59
+ headers: {
60
+ Authorization: `Bearer ${accessToken}`,
61
+ },
62
+ },
63
+ );
64
+
65
+ const { key, code, expiresAt } = await response.json();
39
66
  ```
40
67
 
41
68
  ### Verify a code
42
- Post the key to the API to verify that it is valid. Note that multiple failed verifications will cause a code to be cleared. In that case a new code should be generated at the same key to continue attempts.
69
+
70
+ Post the code to the API to verify that it is valid. Note that multiple failed verifications will cause a code to be cleared. In that case a new code should be generated at the same key to continue attempts.
43
71
 
44
72
  ```typescript
45
- const response = await fetch(
46
- `https://verify-service.adsp.alberta.ca/verify/v1/codes/${codeKey}`,
47
- {
48
- method: 'POST',
49
- headers: {
50
- 'Authorization': `Bearer ${accessToken}`,
51
- },
52
- body: {
53
- code: codeToVerify,
54
- },
55
- }
56
- );
57
-
58
- const {
59
- verified,
60
- } = await response.json();
73
+ const response = await fetch(`https://verify-service.adsp.alberta.ca/verify/v1/codes/${codeKey}`, {
74
+ method: 'POST',
75
+ headers: {
76
+ Authorization: `Bearer ${accessToken}`,
77
+ 'Content-Type': 'application/json',
78
+ },
79
+ body: JSON.stringify({
80
+ code: codeToVerify,
81
+ }),
82
+ });
83
+
84
+ const { verified } = await response.json();
61
85
  ```
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Access Service
4
- nav_order: 1
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Feedback Service
4
- nav_order: 8
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: File Service
4
- nav_order: 1
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Form Service
4
- nav_order: 7
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Notification Service
4
- nav_order: 1
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
@@ -16,9 +16,9 @@ The PDF service is ideal for these kinds of requirements, as it enables develope
16
16
  - generate fully customized PDF documents on demand, and
17
17
  - present the final document for the user to view or download.
18
18
 
19
- A template -  consisting of page headers, page footers, some boiler-plate text, placeholders for customization - is built via the [Template Editor](https://adsp-uat.alberta.ca) within the PDF service, using HTML and CSS for page formatting.  Proficiency in those technologies is necessary for anyone wanting to build anything more than a trivial template.
19
+ A template -  consisting of page headers, page footers, some boiler-plate text, placeholders for customization - is built via the [Template Editor](https://adsp.alberta.ca) within the PDF service, using HTML and CSS for page formatting.  Proficiency in those technologies is necessary for anyone wanting to build anything more than a trivial template.
20
20
 
21
- Generating the final document, and providing access to it, is done through a series of RESTful API calls to the [PDF service](https://api.adsp.alberta.ca/autotest/?urls.primaryName=PDF%20service) in the language of your choice.  The examples given here are written with NodeJS.
21
+ Generating the final document, and providing access to it, is done through a series of RESTful API calls to the [PDF service](https://api.adsp.alberta.ca/platform/?urls.primaryName=PDF%20service) in the language of your choice.  The examples given here are written with NodeJS.
22
22
 
23
23
  You will also need to have access to GOA's Keycloak platform.  These are needed
24
24
 
@@ -8,7 +8,7 @@ grand_parent: Tutorials
8
8
 
9
9
  ## Getting Started
10
10
 
11
- The PDF Service allows you to automatically build a customized PDF document from an HTML template and some template variables. You can use the PDF Service's [Template Editor](/adsp-monorepo/templates/pdf/building-a-template.html) to build one interactively, and once it's in the system you can start using it in your application to generate downloadable PDF documents for your end users.
11
+ The PDF Service allows you to automatically build a customized PDF document from an HTML template and some template variables. You can use the PDF Service's [Template Editor](/adsp-monorepo/tutorials/pdf-service/building-a-template.html) to build one interactively, and once it's in the system you can start using it in your application to generate downloadable PDF documents for your end users.
12
12
 
13
13
  PDF generation is accomplished through a series of API calls that create the PDF and store it within the [File Service](/adsp-monorepo/services/file-service.html), where you have access to it through a file ID. The main steps are:
14
14
 
@@ -21,9 +21,9 @@ Although you can call the API's from any language, the tutorial examples are wri
21
21
 
22
22
  The API calls to the Platform Service require authentication, via Keycloak. See the instructions for [setting up a tenant and getting access tokens](/adsp-monorepo/tutorials/access-service/introduction.html) for details on how to do this.
23
23
 
24
- Continuing on from the tutorial on how to [build a template](/adsp-monorepo/tutorials/building-a-template.html) with the PDF service, our examples will be based on the template set up there for the Child Service's Intervention Record Check. Familiarity with that particular template is not necessary to follow along here, but the information will be useful if you want to understand how the pieces relate to each other.
24
+ Continuing on from the tutorial on how to [build a template](/adsp-monorepo/tutorials/pdf-service/building-a-template.html) with the PDF service, our examples will be based on the template set up there for the Child Service's Intervention Record Check. Familiarity with that particular template is not necessary to follow along here, but the information will be useful if you want to understand how the pieces relate to each other.
25
25
 
26
- See the [PDF Service](https://api.adsp-uat.alberta.ca/autotest/?urls.primaryName=PDF%20service) Swagger documentation for detailed descriptions of the APIs.
26
+ See the [PDF Service](https://api.adsp.alberta.ca/platform/?urls.primaryName=PDF%20service) Swagger documentation for detailed descriptions of the APIs.
27
27
 
28
28
  ## Submit a PDF Generator Job
29
29
 
@@ -99,7 +99,7 @@ where the first three properties are as described above, and the _result_ proper
99
99
 
100
100
  - _id_ the id of the PDF file generated, which can be used to access the file along with the [File Service](/adsp-monorepo/services/file-service.html)
101
101
  - _filename_ the name of the file generated
102
- - _urn_ the [Universal Resource Name](https://en.wikipedia.org/wiki/Uniform_Resource_Name) of the PDF file that you can use along with the [File Service](/adsp-monorepo/services/directory-service.html) to lookup the URL to use for downloading it.
102
+ - _urn_ the [Universal Resource Name](https://en.wikipedia.org/wiki/Uniform_Resource_Name) of the PDF file that you can use along with the [Directory Service](/adsp-monorepo/services/directory-service.html) to lookup the URL to use for downloading it.
103
103
 
104
104
  Polling forces the application developer to manage retrying and sleeping between tries, however. A less fussy approach would be to use the [Push Service](/adsp-monorepo/services/push-service.html). It enables applications to connect to a socket and listen for events of a specific type, such as "pdf-generated". The latter occurs when a Job successfully creates a PDF. You can connect to a Push Service socket as follows:
105
105
 
@@ -115,7 +115,7 @@ const socket = io(
115
115
  );
116
116
 
117
117
  socket.on('pdf-service:pdf-generated', (pdfEvent) => {
118
- If (pdfEvent.jobId === jobID ) {
118
+ if (pdfEvent.payload.jobId === jobId) {
119
119
  // Handle the event.
120
120
  }
121
121
  });
@@ -125,14 +125,21 @@ The listener will pick up on all pdf-generated events for your tenant, so you wi
125
125
 
126
126
  ```typescript
127
127
  {
128
- jobId,
129
- templateId,
130
- file: { id, filename, urn },
131
- requestedBy
128
+ namespace: 'pdf-service',
129
+ name: 'pdf-generated',
130
+ correlationId, // the job ID
131
+ context,
132
+ timestamp,
133
+ payload: {
134
+ jobId,
135
+ templateId,
136
+ file: { id, filename, urn },
137
+ requestedBy
138
+ }
132
139
  }
133
140
  ```
134
141
 
135
- Whichever method you use, the important part is the file ID you get upon successful generation. This identifies the PDF document in the [File Service](/adsp-monorepo/services/file-service.html) which you can use to access it. Job information is cached and has a finite TTL of about 12 hours. Please be sure your application accesses the file ID before the job information expires.
142
+ Whichever method you use, the important part is the file ID you get upon successful generation. This identifies the PDF document in the [File Service](/adsp-monorepo/services/file-service.html) which you can use to access it. Job information is cached and has a finite TTL of about 24 hours after its last update. Please be sure your application accesses the file ID before the job information expires.
136
143
 
137
144
  ## Download a PDF File
138
145
 
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: PDF Service
4
- nav_order: 1
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Status Service
4
- nav_order: 1
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
@@ -10,7 +10,7 @@ grand_parent: Tutorials
10
10
 
11
11
  The _Task Service_ is designed to assist applications in creating a persistent, ordered, and prioritized set of tasks for later processing. For the purposes of this service, a task is defined as an abstract work item that can be assigned to a user for completion. For example, it could involve reviewing a recent _Application for a Farmer’s Market License_. When an end user submits an application, the intake system generates a new review task, which another application can pick up as needed. The key benefit is that applications can easily decouple task creation from task processing, enabling asynchronous processing, load balancing, and improved scalability.
12
12
 
13
- The service is based on message queues, and consists of a set of APIs that allow developers to create and manage task queues. In addition, there is also a generic _Task Application_ that can be used to process certain pre-defined tasks, such as [form submissions](/adsp-monorepo/tutorials/form-service/introduction.html).
13
+ Tasks are organized into queues that you configure for your tenant, and the service consists of a set of APIs that allow developers to create and manage the tasks in those queues. In addition, there is also a generic _Task Application_ that can be used to process certain pre-defined tasks, such as [form submissions](/adsp-monorepo/tutorials/form-service/introduction.html).
14
14
 
15
15
  As with most ADSP services, the task service is a highly scalable microservice deployed on the Government's ARO servers so that developers can use it with confidence.
16
16
 
@@ -46,4 +46,4 @@ There are several [API endpoints](https://api.adsp-uat.alberta.ca/autotest/?urls
46
46
  - setting task priority
47
47
  - managing task status
48
48
 
49
- as well as the basic CRU operations for adding, updating, and retrieving the data. Note: tasks cannot be deleted, then can only be cancelled or completed.
49
+ as well as the basic CRUD operations for adding, updating, retrieving, and deleting tasks. Tasks are normally completed or cancelled rather than deleted; only users with the task-admin role can delete them.
@@ -10,7 +10,7 @@ grand_parent: Tutorials
10
10
 
11
11
  Task queues hold time-ordered sets of information that require processing, either by individuals or computer algorithms. Tasks can be scheduled, prioritized, and assigned to owners. Larger tasks might include subtasks or milestones. However, the task queue itself does not specify the type of data it contains; any type of data can be pushed onto a queue. It is the responsibility of the application developer to [define the data types](/adsp-monorepo/tutorials/task-service/task-definitions.html) and ensure the consistency of the queue's contents.
12
12
 
13
- The service uses [RabbitMQ](https://www.rabbitmq.com/) for task management. The latter is not exposed to developers; however, it is managed by an abstract set of API wrappers that ensure easy, fault-tolerant, access to the underlying message queuing framework.
13
+ Queues are part of your tenant's task service configuration, and the tasks in them are stored by the service. You work with both through the task service APIs.
14
14
 
15
15
  To start using the service, login to the ADSP Tenant-management-webapp and select the _Task Service_. There you will be able to create your first _task queue_. Queues are identified by a _namespace:name_ pair which you specify when creating one. There is no particular significance to the naming convention, it just gives you a means to help organize things when the number of queues in your tenant are large.
16
16
 
@@ -18,30 +18,30 @@ To start using the service, login to the ADSP Tenant-management-webapp and selec
18
18
 
19
19
  Several queue metrics are tracked by the Task Service, including
20
20
 
21
- - the average, min, and max size of the queue
22
- - the number of tasks created, completed, and cancelled since queue creation
23
21
  - the number of tasks with a given status
24
22
  - the number of tasks with a given priority
25
- - the average, minimum, and maximum number of active tasks
23
+ - the number of tasks assigned to each user
24
+ - the average, minimum, and maximum time tasks wait in the queue before they are started, and take from start to completion, over the last week
25
+ - the number of tasks created, completed, and cancelled in the last 7 days
26
26
 
27
- The metrics can be filtered by active tasks only, and the information restricted to just status and priority metrics.
27
+ The counts can be restricted to active tasks only (tasks that are not completed or cancelled), and the time and rate metrics are only included when requested.
28
28
 
29
29
  ## Security
30
30
 
31
31
  Developers must assign access roles to each _queue_ created. The _Task Service_ defines two types of users:
32
32
 
33
- - **Assigner**: Assigners are able to assign tasks to individuals for completion.
34
- - **Worker**: Workers are those that can complete a task.
33
+ - **Assigner**: Assigners are able to view the queue's tasks, assign tasks to individuals for completion, and set task priority.
34
+ - **Worker**: Workers are able to view the queue's tasks, assign tasks to themselves, and start and complete them.
35
35
 
36
36
  In the Tenant-Management-Webapp developers can assign user types to one or more tenant-defined keycloak roles. Note: this security is important enough that this step is mandatory. If, when testing you find you are getting 403's, make sure your test user has the right tenant-defined roles. You can assign user types to these roles via the _Queue permissions_ pane in the Queue editor:
37
37
 
38
38
  ![](/adsp-monorepo/assets/task-service/queuePermissions.png){: width="800" }
39
39
 
40
- In addition to the _queue specific_ roles, users must have one or more of the following in order to access any task related data:
40
+ In addition to the _queue specific_ roles, the task service has the following roles, which apply across all queues:
41
41
 
42
- - **task-reader**: Users can see the task data, but are unable to update it.
43
- - **task-writer**: Users can update task data
44
- - **task-admin**: Users can assign tasks to other individuals.
42
+ - **task-reader**: Users can see the tasks of every queue, but are unable to update them.
43
+ - **task-writer**: Users and service accounts can create tasks, and update tasks they can see.
44
+ - **task-admin**: Users can see, update, assign, prioritize, and delete tasks in every queue.
45
45
 
46
46
  ## APIs
47
47
 
@@ -63,5 +63,7 @@ Various events are triggered throughout the lifecycle of a task. These events ca
63
63
  - task-priority-set
64
64
  - task-assigned
65
65
  - task-started
66
+ - task-data-updated
66
67
  - task-completed
67
68
  - task-cancelled
69
+ - task-deleted
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Task Service
4
- nav_order: 8
5
4
  parent: Tutorials
6
5
  has_children: true
7
6
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/adsp-sdk-mcp-server",
3
- "version": "1.20.2",
3
+ "version": "1.21.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/src/http.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import * as express from 'express';
2
+ import { CreateAdspMcpServerOptions } from './server';
3
+ export interface McpHttpAppOptions extends CreateAdspMcpServerOptions {
4
+ sessionTtlMs: number;
5
+ }
6
+ export interface McpHttpApp {
7
+ app: express.Express;
8
+ close(): void;
9
+ }
10
+ export declare function createMcpHttpApp(options: McpHttpAppOptions): McpHttpApp;
package/src/http.js ADDED
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMcpHttpApp = createMcpHttpApp;
4
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
5
+ const crypto_1 = require("crypto");
6
+ const express = require("express");
7
+ const server_1 = require("./server");
8
+ function applyCorsHeaders(req, res, next) {
9
+ res.setHeader('Access-Control-Allow-Origin', process.env['CORS_ORIGIN'] ?? '*');
10
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
11
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, mcp-session-id');
12
+ res.setHeader('Access-Control-Expose-Headers', 'mcp-session-id');
13
+ if (req.method === 'OPTIONS') {
14
+ res.sendStatus(204);
15
+ return;
16
+ }
17
+ next();
18
+ }
19
+ function startIdleSweep(sessions, sessionTtlMs) {
20
+ const timer = setInterval(() => {
21
+ const now = Date.now();
22
+ for (const [id, entry] of sessions) {
23
+ if (now - entry.lastActivity > sessionTtlMs) {
24
+ sessions.delete(id);
25
+ entry.server.close();
26
+ }
27
+ }
28
+ }, 60_000);
29
+ timer.unref();
30
+ return timer;
31
+ }
32
+ function createPostHandler(sessions, options) {
33
+ return async (req, res) => {
34
+ const sessionId = req.headers['mcp-session-id'];
35
+ if (sessionId && sessions.has(sessionId)) {
36
+ const entry = sessions.get(sessionId);
37
+ entry.lastActivity = Date.now();
38
+ await entry.transport.handleRequest(req, res, req.body);
39
+ return;
40
+ }
41
+ const newId = (0, crypto_1.randomUUID)();
42
+ const sessionServer = (0, server_1.createAdspMcpServer)(options);
43
+ const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
44
+ sessionIdGenerator: () => newId,
45
+ onsessioninitialized: (id) => {
46
+ sessions.set(id, { server: sessionServer, transport, lastActivity: Date.now() });
47
+ },
48
+ });
49
+ transport.onclose = () => {
50
+ const found = [...sessions.entries()].find(([, e]) => e.transport === transport);
51
+ if (found) {
52
+ sessions.delete(found[0]);
53
+ found[1].server.close();
54
+ }
55
+ };
56
+ await sessionServer.connect(transport);
57
+ await transport.handleRequest(req, res, req.body);
58
+ };
59
+ }
60
+ function findSession(sessions, req, res) {
61
+ const sessionId = req.headers['mcp-session-id'];
62
+ if (!sessionId || !sessions.has(sessionId)) {
63
+ res.status(400).json({ error: 'Invalid or missing session ID' });
64
+ return undefined;
65
+ }
66
+ return [sessionId, sessions.get(sessionId)];
67
+ }
68
+ function registerSessionRoutes(app, options) {
69
+ const sessions = new Map();
70
+ const cleanupTimer = startIdleSweep(sessions, options.sessionTtlMs);
71
+ app.post('/mcp', createPostHandler(sessions, options));
72
+ app.get('/mcp', async (req, res) => {
73
+ const found = findSession(sessions, req, res);
74
+ if (!found)
75
+ return;
76
+ found[1].lastActivity = Date.now();
77
+ await found[1].transport.handleRequest(req, res);
78
+ });
79
+ app.delete('/mcp', async (req, res) => {
80
+ const found = findSession(sessions, req, res);
81
+ if (!found)
82
+ return;
83
+ sessions.delete(found[0]);
84
+ await found[1].transport.handleRequest(req, res);
85
+ });
86
+ return () => {
87
+ clearInterval(cleanupTimer);
88
+ for (const [id, entry] of sessions) {
89
+ sessions.delete(id);
90
+ entry.server.close();
91
+ }
92
+ };
93
+ }
94
+ function createMcpHttpApp(options) {
95
+ (0, server_1.loadAdspMcpTools)(options);
96
+ const app = express();
97
+ app.use(express.json({ limit: '1mb' }));
98
+ app.use(applyCorsHeaders);
99
+ app.get('/health', (_req, res) => {
100
+ res.json({ status: 'ok' });
101
+ });
102
+ const close = registerSessionRoutes(app, options);
103
+ return { app, close };
104
+ }
105
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/http.ts"],"names":[],"mappings":";;AAwHA,4CAaC;AApID,0FAAmG;AACnG,mCAAoC;AACpC,mCAAmC;AACnC,qCAA6F;AAmB7F,SAAS,gBAAgB,CAAC,GAAoB,EAAE,GAAqB,EAAE,IAA0B;IAC/F,GAAG,CAAC,SAAS,CAAC,6BAA6B,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,CAAC;IAChF,GAAG,CAAC,SAAS,CAAC,8BAA8B,EAAE,4BAA4B,CAAC,CAAC;IAC5E,GAAG,CAAC,SAAS,CAAC,8BAA8B,EAAE,8BAA8B,CAAC,CAAC;IAC9E,GAAG,CAAC,SAAS,CAAC,+BAA+B,EAAE,gBAAgB,CAAC,CAAC;IACjE,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC7B,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACpB,OAAO;IACT,CAAC;IACD,IAAI,EAAE,CAAC;AACT,CAAC;AAED,SAAS,cAAc,CAAC,QAAkB,EAAE,YAAoB;IAC9D,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E,CAAC;QACvB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAA0B;IACzD,IAAA,yBAAgB,EAAC,OAAO,CAAC,CAAC;IAE1B,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxC,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAE1B,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAC/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAClD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACxB,CAAC"}
package/src/main.js CHANGED
@@ -2,9 +2,7 @@
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
+ const http_1 = require("./http");
8
6
  const server_1 = require("./server");
9
7
  function resolveTransport() {
10
8
  const raw = process.env['MCP_TRANSPORT'] ?? 'stdio';
@@ -27,90 +25,14 @@ async function main() {
27
25
  const SESSION_TTL_MS = parseInt(process.env['SESSION_TTL_MINUTES'] ?? '30', 10) * 60 * 1000;
28
26
  async function startHttp() {
29
27
  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
- });
28
+ const mcpApp = (0, http_1.createMcpHttpApp)({ sessionTtlMs: SESSION_TTL_MS });
103
29
  return new Promise((resolve) => {
104
- const httpServer = app.listen(port, () => {
30
+ const httpServer = mcpApp.app.listen(port, () => {
105
31
  console.error(`[adsp-sdk-mcp-server] HTTP server listening on :${port}`);
106
32
  resolve();
107
33
  });
108
34
  function shutdown() {
109
- clearInterval(cleanupTimer);
110
- for (const [id, entry] of sessions) {
111
- sessions.delete(id);
112
- entry.server.close();
113
- }
35
+ mcpApp.close();
114
36
  httpServer.close(() => process.exit(0));
115
37
  setTimeout(() => process.exit(1), 5_000).unref();
116
38
  }
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,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,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,OAAO,CAAC,KAAK,CAAC,mCAAmC,SAAS,iBAAiB,cAAc,EAAE,CAAC,CAAC;IAE7F,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM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AAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/src/server.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { LiveToolDefinition, ToolDefinition } from './tools/types';
2
3
  export interface CreateAdspMcpServerOptions {
3
4
  /** Root directory of bundled ADSP docs. Defaults to the assets copied alongside the built package. */
4
5
  docsRoot?: string;
5
6
  }
7
+ export interface AdspMcpTools {
8
+ tools: (ToolDefinition | LiveToolDefinition)[];
9
+ toolsByName: Map<string, ToolDefinition | LiveToolDefinition>;
10
+ }
11
+ export declare function loadAdspMcpTools(options?: CreateAdspMcpServerOptions): AdspMcpTools;
6
12
  export declare function createAdspMcpServer(options?: CreateAdspMcpServerOptions): Server;