@abgov/adsp-sdk-mcp-server 1.1.0 → 1.2.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 +25 -1
- package/package.json +2 -1
- package/src/server.js +7 -1
- package/src/server.js.map +1 -1
- package/src/tools/registerServiceRolesTool.d.ts +2 -0
- package/src/tools/registerServiceRolesTool.js +58 -0
- package/src/tools/registerServiceRolesTool.js.map +1 -0
- package/src/tools/types.d.ts +12 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ An MCP (Model Context Protocol) server that gives an AI coding assistant grounde
|
|
|
5
5
|
(`@abgov/adsp-service-sdk`), instead of guessing.
|
|
6
6
|
|
|
7
7
|
It bundles the ADSP documentation site content and a curated reference of every `@abgov/adsp-service-sdk` export,
|
|
8
|
-
and exposes them over stdio via
|
|
8
|
+
and exposes them over stdio via five tools:
|
|
9
9
|
|
|
10
10
|
- `search_adsp_docs` — keyword search across ADSP platform docs (getting started, architecture, service concepts,
|
|
11
11
|
tutorials).
|
|
@@ -15,6 +15,10 @@ and exposes them over stdio via four tools:
|
|
|
15
15
|
- `get_platform_quickstart` — the canonical `initializeService` usage pattern (the common case for a tenant service
|
|
16
16
|
built on top of ADSP) and a capabilities summary, for the most common question: how to start using ADSP from a
|
|
17
17
|
Node service.
|
|
18
|
+
- `list_service_roles` — **the one tool that talks to a real ADSP environment**, not bundled/offline data. Reads
|
|
19
|
+
every platform service's registered RBAC role live from tenant-service configuration, so an agent can pick a
|
|
20
|
+
least-privileged role instead of defaulting to an admin role. Requires logging in first (see below) — everything
|
|
21
|
+
else in this package works fully offline with no setup.
|
|
18
22
|
|
|
19
23
|
This package covers the Node SDK only. Other language SDKs (`.NET`, Django, Flask, Spring) are out of scope for now.
|
|
20
24
|
|
|
@@ -38,6 +42,26 @@ Add it to your MCP client's server config, run via `npx`:
|
|
|
38
42
|
}
|
|
39
43
|
```
|
|
40
44
|
|
|
45
|
+
### Using `list_service_roles`
|
|
46
|
+
|
|
47
|
+
That one tool needs a real ADSP environment and a logged-in session (via `@abgov/adsp-cli`, a separate package this
|
|
48
|
+
one depends on). One-time setup — no MCP client config changes needed:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx @abgov/adsp-cli login --tenant "My Tenant"
|
|
52
|
+
# or --realm <realm> if you already know it, or no args to pick interactively from the full tenant list
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`login` persists the resolved realm, so the MCP server just works after that — no `env` block required in the MCP
|
|
56
|
+
client config. `ADSP_TENANT_REALM` remains available as an optional override (e.g. CI, or switching contexts).
|
|
57
|
+
|
|
58
|
+
The same role data is also available directly from a terminal, without an MCP client at all: `npx @abgov/adsp-cli
|
|
59
|
+
service-roles`.
|
|
60
|
+
|
|
61
|
+
If `list_service_roles` is called without a valid login, it returns a clear, actionable error (telling you to run
|
|
62
|
+
`npx @abgov/adsp-cli login`) rather than failing silently or hanging — it never opens a browser or blocks waiting for
|
|
63
|
+
one itself.
|
|
64
|
+
|
|
41
65
|
## Development
|
|
42
66
|
|
|
43
67
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/adsp-sdk-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"adsp-sdk-mcp-server": "./src/main.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@abgov/adsp-cli": "^1.0.0",
|
|
11
12
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
12
13
|
"tslib": "^2.3.0",
|
|
13
14
|
"zod": "^3.25.76"
|
package/src/server.js
CHANGED
|
@@ -7,12 +7,18 @@ const path_1 = require("path");
|
|
|
7
7
|
const docsRepository_1 = require("./docs/docsRepository");
|
|
8
8
|
const registerDocsTools_1 = require("./tools/registerDocsTools");
|
|
9
9
|
const registerQuickstartTool_1 = require("./tools/registerQuickstartTool");
|
|
10
|
+
const registerServiceRolesTool_1 = require("./tools/registerServiceRolesTool");
|
|
10
11
|
const registerSdkTools_1 = require("./tools/registerSdkTools");
|
|
11
12
|
function createAdspMcpServer(options = {}) {
|
|
12
13
|
// Compiled output places this file under dist/.../src/, while the docs asset copy lands one level up at dist/.../assets/docs.
|
|
13
14
|
const docsRoot = options.docsRoot ?? (0, path_1.join)(__dirname, '..', 'assets', 'docs');
|
|
14
15
|
const docs = new docsRepository_1.DocsRepository(docsRoot);
|
|
15
|
-
const tools = [
|
|
16
|
+
const tools = [
|
|
17
|
+
...(0, registerDocsTools_1.createDocsTools)(docs),
|
|
18
|
+
...(0, registerSdkTools_1.createSdkTools)(),
|
|
19
|
+
...(0, registerQuickstartTool_1.createQuickstartTool)(),
|
|
20
|
+
...(0, registerServiceRolesTool_1.createServiceRolesTools)(),
|
|
21
|
+
];
|
|
16
22
|
const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
17
23
|
// Deliberately using the low-level Server (McpServer is recommended for typical cases) rather than an oversight:
|
|
18
24
|
// this workspace hoists multiple physical copies of zod (root zod@3.x plus nested zod@4.x/3.x under unrelated
|
package/src/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/server.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/server.ts"],"names":[],"mappings":";;AAcA,kDAsCC;AApDD,wEAAmE;AACnE,iEAAmG;AACnG,+BAA4B;AAC5B,0DAAuD;AACvD,iEAA4D;AAC5D,2EAAsE;AACtE,+EAA2E;AAC3E,+DAA0D;AAO1D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M,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;QACtG,CAAC;QAED,sHAAsH;QACtH,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createServiceRolesTools = createServiceRolesTools;
|
|
4
|
+
const adsp_cli_1 = require("@abgov/adsp-cli");
|
|
5
|
+
function describeError(err) {
|
|
6
|
+
if (err instanceof adsp_cli_1.ServiceNotInDirectoryError) {
|
|
7
|
+
return err.message;
|
|
8
|
+
}
|
|
9
|
+
if (err instanceof adsp_cli_1.HttpRequestError) {
|
|
10
|
+
if (err.status === 401) {
|
|
11
|
+
return 'Access token was rejected (401). Run `npx @abgov/adsp-cli login` again to refresh it.';
|
|
12
|
+
}
|
|
13
|
+
if (err.status === 403) {
|
|
14
|
+
return ('Access denied (403) reading tenant-service configuration. This is more likely the wrong tenant realm ' +
|
|
15
|
+
'or environment than a missing role — check ADSP_TENANT_REALM and ADSP_ENV.');
|
|
16
|
+
}
|
|
17
|
+
if (err.status >= 500) {
|
|
18
|
+
return `The ADSP platform returned an error (${err.status}). It may be experiencing an outage — try again shortly.`;
|
|
19
|
+
}
|
|
20
|
+
return `Request failed with status ${err.status}.`;
|
|
21
|
+
}
|
|
22
|
+
if (err instanceof TypeError) {
|
|
23
|
+
return `Could not reach the ADSP platform (${err.message}). Check ADSP_ENV/ADSP_DIRECTORY_SERVICE_URL and your network connection.`;
|
|
24
|
+
}
|
|
25
|
+
return err instanceof Error ? err.message : String(err);
|
|
26
|
+
}
|
|
27
|
+
function createServiceRolesTools() {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
name: 'list_service_roles',
|
|
31
|
+
description: 'List every ADSP platform service\'s registered RBAC role (role name, description, whether it is part of ' +
|
|
32
|
+
'the tenant-admin composite role), read live from tenant-service configuration. Use this to pick the ' +
|
|
33
|
+
'least-privileged role for a service account or user, rather than defaulting to an admin role. Requires ' +
|
|
34
|
+
'login: run `npx @abgov/adsp-cli login` once in a terminal first (no other setup needed).',
|
|
35
|
+
inputSchema: { type: 'object', properties: {} },
|
|
36
|
+
handler: async () => {
|
|
37
|
+
const tokenResult = await (0, adsp_cli_1.getAccessToken)();
|
|
38
|
+
if (tokenResult.status === 'not-authenticated') {
|
|
39
|
+
return {
|
|
40
|
+
isError: true,
|
|
41
|
+
content: [
|
|
42
|
+
{ type: 'text', text: 'Not authenticated. Run `npx @abgov/adsp-cli login` in a terminal, then retry.' },
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const directoryServiceUrl = (0, adsp_cli_1.getDirectoryServiceUrl)();
|
|
48
|
+
const roles = await (0, adsp_cli_1.getServiceRoles)(tokenResult.token, directoryServiceUrl);
|
|
49
|
+
return { content: [{ type: 'text', text: JSON.stringify(roles, null, 2) }] };
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
return { isError: true, content: [{ type: 'text', text: describeError(err) }] };
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=registerServiceRolesTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerServiceRolesTool.js","sourceRoot":"","sources":["../../../../../libs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AAE,CAAC;oBAC/C,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE;4BACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,+EAA+E,EAAE;yBACxG;qBACF,CAAC;gBACJ,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,mBAAmB,GAAG,IAAA,iCAAsB,GAAE,CAAC;oBACrD,MAAM,KAAK,GAAG,MAAM,IAAA,0BAAe,EAAC,WAAW,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;oBAC5E,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC/E,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAClF,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/src/tools/types.d.ts
CHANGED
|
@@ -16,3 +16,15 @@ export interface ToolDefinition {
|
|
|
16
16
|
*/
|
|
17
17
|
handler: (args: Record<string, unknown>) => Promise<CallToolResult> | CallToolResult;
|
|
18
18
|
}
|
|
19
|
+
export interface LiveToolDefinition {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
inputSchema: JsonSchemaObject;
|
|
23
|
+
/**
|
|
24
|
+
* Unlike ToolDefinition.handler, this MAY make network calls and read local files (e.g. an
|
|
25
|
+
* ADSP API call authenticated via a cached CLI login token) — it is not required to be a pure,
|
|
26
|
+
* side-effect-free lookup. Kept as a distinct type so that invariant stays true and checkable
|
|
27
|
+
* for every ToolDefinition-typed tool in this package.
|
|
28
|
+
*/
|
|
29
|
+
handler: (args: Record<string, unknown>) => Promise<CallToolResult> | CallToolResult;
|
|
30
|
+
}
|