@abgov/adsp-sdk-mcp-server 1.9.0 → 1.11.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/package.json +2 -2
- package/src/server.js +2 -0
- package/src/server.js.map +1 -1
- package/src/tools/registerConfigurationSchemaTool.d.ts +2 -0
- package/src/tools/registerConfigurationSchemaTool.js +70 -0
- package/src/tools/registerConfigurationSchemaTool.js.map +1 -0
- package/src/tools/registerQuickstartTool.js +71 -5
- package/src/tools/registerQuickstartTool.js.map +1 -1
- package/src/tools/registerServiceRolesTool.js +31 -5
- package/src/tools/registerServiceRolesTool.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/adsp-sdk-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.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,7 +8,7 @@
|
|
|
8
8
|
"adsp-sdk-mcp-server": "./src/main.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@abgov/adsp-cli": "^1.
|
|
11
|
+
"@abgov/adsp-cli": "^1.7.0",
|
|
12
12
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
13
13
|
"tslib": "^2.3.0",
|
|
14
14
|
"zod": "^3.25.76"
|
package/src/server.js
CHANGED
|
@@ -5,6 +5,7 @@ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
|
5
5
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const docsRepository_1 = require("./docs/docsRepository");
|
|
8
|
+
const registerConfigurationSchemaTool_1 = require("./tools/registerConfigurationSchemaTool");
|
|
8
9
|
const registerDocsTools_1 = require("./tools/registerDocsTools");
|
|
9
10
|
const registerQuickstartTool_1 = require("./tools/registerQuickstartTool");
|
|
10
11
|
const registerServiceRolesTool_1 = require("./tools/registerServiceRolesTool");
|
|
@@ -18,6 +19,7 @@ function createAdspMcpServer(options = {}) {
|
|
|
18
19
|
...(0, registerSdkTools_1.createSdkTools)(),
|
|
19
20
|
...(0, registerQuickstartTool_1.createQuickstartTool)(),
|
|
20
21
|
...(0, registerServiceRolesTool_1.createServiceRolesTools)(),
|
|
22
|
+
...(0, registerConfigurationSchemaTool_1.createConfigurationSchemaTools)(),
|
|
21
23
|
];
|
|
22
24
|
const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
23
25
|
// Deliberately using the low-level Server (McpServer is recommended for typical cases) rather than an oversight:
|
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":";;AAeA,kDAuCC;AAtDD,wEAAmE;AACnE,iEAAmG;AACnG,+BAA4B;AAC5B,0DAAuD;AACvD,6FAAyF;AACzF,iEAA4D;AAC5D,2EAAsE;AACtE,+EAA2E;AAC3E,+DAA0D;AAO1D,SAAgB,mBAAmB,CAAC,UAAsC,EAAE;IAC1E,8HAA8H;IAC9H,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,IAAI,+BAAc,CAAC,QAAQ,CAAC,CAAC;IAE1C,MAAM,KAAK,GAAG;QACZ,GAAG,IAAA,mCAAe,EAAC,IAAI,CAAC;QACxB,GAAG,IAAA,iCAAc,GAAE;QACnB,GAAG,IAAA,6CAAoB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C,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConfigurationSchemaTools = createConfigurationSchemaTools;
|
|
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 configuration-service schemas. 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 createConfigurationSchemaTools() {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
name: 'get_service_configuration_schema',
|
|
31
|
+
description: 'Returns the configuration schema(s) for ADSP platform services, read live from configuration-service. ' +
|
|
32
|
+
'Use this to determine the correct shape for `serviceConfigurations` entries in `initializeService` when ' +
|
|
33
|
+
'registering with a service that does not have a named field in `ServiceRegistration` (e.g. form-service, ' +
|
|
34
|
+
'task-service). Pass a `serviceId` URN to get one service\'s schema; omit to list all registered schemas. ' +
|
|
35
|
+
'Requires authentication: run `npx @abgov/adsp-cli login` once in a terminal (interactive), or set ' +
|
|
36
|
+
'ADSP_CLIENT_ID and ADSP_CLIENT_SECRET environment variables for non-interactive/CI use.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
serviceId: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'Optional ADSP service URN to filter to (e.g. "urn:ads:platform:form-service").',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
handler: async (args) => {
|
|
47
|
+
const tokenResult = await (0, adsp_cli_1.getAccessToken)();
|
|
48
|
+
if (tokenResult.status === 'not-authenticated') {
|
|
49
|
+
return {
|
|
50
|
+
isError: true,
|
|
51
|
+
content: [
|
|
52
|
+
{ type: 'text', text: 'Not authenticated. Run `npx @abgov/adsp-cli login` in a terminal, then retry.' },
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const directoryServiceUrl = (0, adsp_cli_1.getDirectoryServiceUrl)();
|
|
58
|
+
const schemas = await (0, adsp_cli_1.getServiceConfigurationSchemas)(tokenResult.token, directoryServiceUrl, args.serviceId);
|
|
59
|
+
return {
|
|
60
|
+
content: [{ type: 'text', text: JSON.stringify(schemas, null, 2) }],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
return { isError: true, content: [{ type: 'text', text: describeError(err) }] };
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=registerConfigurationSchemaTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerConfigurationSchemaTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerConfigurationSchemaTool.ts"],"names":[],"mappings":";;AAqCA,wEAgDC;AArFD,8CAMyB;AAGzB,SAAS,aAAa,CAAC,GAAY;IACjC,IAAI,GAAG,YAAY,qCAA0B,EAAE,CAAC;QAC9C,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,IAAI,GAAG,YAAY,2BAAgB,EAAE,CAAC;QACpC,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,uFAAuF,CAAC;QACjG,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvB,OAAO,CACL,wGAAwG;gBACxG,4EAA4E,CAC7E,CAAC;QACJ,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YACtB,OAAO,wCAAwC,GAAG,CAAC,MAAM,0DAA0D,CAAC;QACtH,CAAC;QACD,OAAO,8BAA8B,GAAG,CAAC,MAAM,GAAG,CAAC;IACrD,CAAC;IAED,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;QAC7B,OAAO,sCAAsC,GAAG,CAAC,OAAO,2EAA2E,CAAC;IACtI,CAAC;IAED,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,SAAgB,8BAA8B;IAC5C,OAAO;QACL;YACE,IAAI,EAAE,kCAAkC;YACxC,WAAW,EACT,wGAAwG;gBACxG,0GAA0G;gBAC1G,2GAA2G;gBAC3G,2GAA2G;gBAC3G,oGAAoG;gBACpG,yFAAyF;YAC3F,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,gFAAgF;qBAC9F;iBACF;aACF;YACD,OAAO,EAAE,KAAK,EAAE,IAA4B,EAAE,EAAE;gBAC9C,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAc,GAAE,CAAC;gBAE3C,IAAI,WAAW,CAAC,MAAM,KAAK,mBAAmB,EAAE,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,OAAO,GAAG,MAAM,IAAA,yCAA8B,EAClD,WAAW,CAAC,KAAK,EACjB,mBAAmB,EACnB,IAAI,CAAC,SAAS,CACf,CAAC;oBACF,OAAO;wBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;qBACpE,CAAC;gBACJ,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"}
|
|
@@ -62,17 +62,83 @@ many tenants and needs to resolve which one a request belongs to.)
|
|
|
62
62
|
|
|
63
63
|
## 3. Registering what your service needs
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
object (see the \`ServiceRegistration\` SDK reference entry) and the SDK registers them with the relevant platform
|
|
67
|
-
services (configuration-service, event-service, tenant-service, push-service, file-service, notification-service,
|
|
68
|
-
value-service) automatically on startup.
|
|
65
|
+
The \`ServiceRegistration\` fields in the options object tell the SDK what to declare at startup.
|
|
69
66
|
|
|
70
|
-
|
|
67
|
+
**Registration is how platform services learn about your service's resources.** Most ADSP services store
|
|
68
|
+
their resource definitions (file types, event types, form definitions, task queues, etc.) as configuration in
|
|
69
|
+
configuration-service. Registering them at startup is what creates those resources — without registration
|
|
70
|
+
they do not exist, and API calls to those services will fail regardless of whether Keycloak roles are
|
|
71
|
+
correctly assigned. Always register the definitions for every ADSP service your code depends on.
|
|
72
|
+
|
|
73
|
+
| Service you call | Registration field | What the SDK registers |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| configuration-service | \`configuration\` (configurationSchema) | Your config schema; enables \`req.getConfiguration()\` |
|
|
76
|
+
| event-service | \`events\` | Event definitions; events appear in the event log and can be subscribed to |
|
|
77
|
+
| file-service | \`fileTypes\` | File type definitions controlling storage, access, and scan rules |
|
|
78
|
+
| notification-service | \`notifications\` | Notification type definitions triggered by events |
|
|
79
|
+
| push-service | \`eventStreams\` | Event stream definitions for WebSocket delivery to clients |
|
|
80
|
+
| value-service | \`values\` | Value definitions for time-series data |
|
|
81
|
+
| tenant-service | \`roles\` | RBAC roles users can be assigned; roles appear in \`req.user.roles\` |
|
|
82
|
+
| any other service | \`serviceConfigurations\` | Generic: posts a configuration object to that service's namespace |
|
|
83
|
+
|
|
84
|
+
All fields are optional — only include the ones your service actually uses. Every named field above is a
|
|
85
|
+
convenience wrapper around the same underlying mechanism: the SDK PATCHes configuration-service under the
|
|
86
|
+
target service's namespace. \`serviceConfigurations\` exposes that mechanism directly for any service not
|
|
87
|
+
covered by a named field:
|
|
88
|
+
|
|
89
|
+
\`\`\`typescript
|
|
90
|
+
serviceConfigurations: [
|
|
91
|
+
{
|
|
92
|
+
serviceId: AdspId.parse('urn:ads:platform:<target-service>'),
|
|
93
|
+
// Plain object when the service uses a single configuration document:
|
|
94
|
+
configuration: { /* shape matching the target service's configuration schema */ },
|
|
95
|
+
// — OR — NamedConfiguration[] when the service uses namespace mode
|
|
96
|
+
// (one named document per resource definition, e.g. one entry per form):
|
|
97
|
+
// configuration: [{ name: '<resource-id>', configuration: { /* schema shape */ } }],
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
\`\`\`
|
|
101
|
+
|
|
102
|
+
To find the correct \`configuration\` shape for a service: call \`get_service_configuration_schema\` with
|
|
103
|
+
the service's URN (e.g. \`urn:ads:platform:form-service\`) — it returns the live JSON Schema registered by
|
|
104
|
+
that service, which is exactly the shape required here. Use \`search_sdk_reference\` for the full
|
|
105
|
+
\`ServiceRegistration\` type and the \`NamedConfiguration\` variant.
|
|
106
|
+
|
|
107
|
+
## 4. Keycloak setup for service-to-service calls
|
|
108
|
+
|
|
109
|
+
When your service makes HTTP requests to another ADSP service (e.g. uploads files via file-service, sends
|
|
110
|
+
notifications via notification-service), **two Keycloak changes are required on your service's client** — one
|
|
111
|
+
is NOT enough:
|
|
112
|
+
|
|
113
|
+
### Step 1 — Add an audience mapper
|
|
114
|
+
|
|
115
|
+
Every ADSP service validates that its own URN appears in the \`aud\` (audience) claim of the incoming token.
|
|
116
|
+
Your service's token will not carry that URN by default, so every call will be rejected with 401 unless you
|
|
117
|
+
add an audience mapper.
|
|
118
|
+
|
|
119
|
+
In Keycloak admin console: **Clients → {your-client-id} → Client Scopes → {your-client-id}-dedicated →
|
|
120
|
+
Add mapper → By configuration → Audience** → set "Included Client Audience" to the target service's URN
|
|
121
|
+
(e.g. \`urn:ads:platform:file-service\`). Repeat for each service you call.
|
|
122
|
+
|
|
123
|
+
### Step 2 — Assign the service account role
|
|
124
|
+
|
|
125
|
+
Your service's token must also carry the role the target service requires for the operation. Use
|
|
126
|
+
\`list_service_roles\` to find the least-privileged role, then assign it.
|
|
127
|
+
|
|
128
|
+
In Keycloak admin console: **Clients → {your-client-id} → Service Account Roles → Client Roles** → select
|
|
129
|
+
the target service's URN from the dropdown → assign the role (e.g. \`file-service-user\`). Repeat for each
|
|
130
|
+
service you call.
|
|
131
|
+
|
|
132
|
+
Both steps are always required. The audience mapper makes your token acceptable to the target service; the
|
|
133
|
+
role controls what that service will permit your service account to do.
|
|
134
|
+
|
|
135
|
+
## 5. Next steps
|
|
71
136
|
|
|
72
137
|
- Use \`search_adsp_docs\` for platform concepts (multi-tenancy, service discovery, configuration, domain events) and
|
|
73
138
|
service-specific docs.
|
|
74
139
|
- Use \`search_sdk_reference\` for details on any specific SDK symbol (e.g. \`EventService\`, \`ConfigurationService\`,
|
|
75
140
|
\`authorize\`).
|
|
141
|
+
- Use \`list_service_roles\` to find the exact role name to assign in Step 2 above.
|
|
76
142
|
- Read the full getting-started guide with \`read_adsp_doc\` on path \`getting-started.md\`, the Node SDK page at
|
|
77
143
|
\`platform/platform-node-sdk.md\`, and the architecture overview at \`architecture.md\`.
|
|
78
144
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerQuickstartTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerQuickstartTool.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"registerQuickstartTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerQuickstartTool.ts"],"names":[],"mappings":";;AAgJA,oDAaC;AA3JD,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4IlB,CAAC;AAEF,SAAgB,oBAAoB;IAClC,OAAO;QACL;YACE,IAAI,EAAE,yBAAyB;YAC/B,WAAW,EACT,yGAAyG;gBACzG,2GAA2G;gBAC3G,4GAA4G;gBAC5G,2BAA2B;YAC7B,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;YAC/C,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;SACnE;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -24,14 +24,38 @@ function describeError(err) {
|
|
|
24
24
|
}
|
|
25
25
|
return err instanceof Error ? err.message : String(err);
|
|
26
26
|
}
|
|
27
|
+
const SERVICE_ROLES_PREAMBLE = `## How to use these roles
|
|
28
|
+
|
|
29
|
+
This list covers every ADSP platform service. For each service your service needs to call, complete
|
|
30
|
+
**both** of the following Keycloak steps — one without the other is not enough:
|
|
31
|
+
|
|
32
|
+
1. **Add an audience mapper** on your service's client so its tokens carry the target service's URN in the
|
|
33
|
+
\`aud\` claim (target services reject tokens that don't include their URN):
|
|
34
|
+
Keycloak admin → Clients → {your-client-id} → Client Scopes → {your-client-id}-dedicated →
|
|
35
|
+
Add mapper → By configuration → Audience → set "Included Client Audience" to the \`serviceId\`
|
|
36
|
+
(e.g. \`urn:ads:platform:file-service\`).
|
|
37
|
+
|
|
38
|
+
2. **Assign the role** to your service account:
|
|
39
|
+
Keycloak admin → Clients → {your-client-id} → Service Account Roles → Client Roles →
|
|
40
|
+
select \`serviceId\` from the dropdown → assign the role.
|
|
41
|
+
|
|
42
|
+
Roles where \`inTenantAdmin: true\` are automatically granted to tenant admin users, but service accounts
|
|
43
|
+
always need explicit assignment regardless of that flag.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
`;
|
|
27
48
|
function createServiceRolesTools() {
|
|
28
49
|
return [
|
|
29
50
|
{
|
|
30
51
|
name: 'list_service_roles',
|
|
31
|
-
description: 'List every ADSP platform service\'s registered RBAC role (role name, description, whether it is
|
|
32
|
-
'the tenant-admin composite role), read live from tenant-service configuration. Use this to
|
|
33
|
-
'least-privileged role
|
|
34
|
-
'
|
|
52
|
+
description: 'List every ADSP platform service\'s registered RBAC role (role name, description, whether it is ' +
|
|
53
|
+
'part of the tenant-admin composite role), read live from tenant-service configuration. Use this to ' +
|
|
54
|
+
'identify the least-privileged role when your service needs to call another ADSP service. After ' +
|
|
55
|
+
'identifying the role, two Keycloak steps are required: (1) add an audience mapper for the service\'s ' +
|
|
56
|
+
'URN on your client, and (2) assign the role to your service account — both are needed. Requires ' +
|
|
57
|
+
'authentication: run `npx @abgov/adsp-cli login` once in a terminal (interactive), or set ' +
|
|
58
|
+
'ADSP_CLIENT_ID and ADSP_CLIENT_SECRET environment variables for non-interactive/CI use.',
|
|
35
59
|
inputSchema: { type: 'object', properties: {} },
|
|
36
60
|
handler: async () => {
|
|
37
61
|
const tokenResult = await (0, adsp_cli_1.getAccessToken)();
|
|
@@ -46,7 +70,9 @@ function createServiceRolesTools() {
|
|
|
46
70
|
try {
|
|
47
71
|
const directoryServiceUrl = (0, adsp_cli_1.getDirectoryServiceUrl)();
|
|
48
72
|
const roles = await (0, adsp_cli_1.getServiceRoles)(tokenResult.token, directoryServiceUrl);
|
|
49
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
content: [{ type: 'text', text: SERVICE_ROLES_PREAMBLE + JSON.stringify(roles, null, 2) }],
|
|
75
|
+
};
|
|
50
76
|
}
|
|
51
77
|
catch (err) {
|
|
52
78
|
return { isError: true, content: [{ type: 'text', text: describeError(err) }] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerServiceRolesTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerServiceRolesTool.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"registerServiceRolesTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerServiceRolesTool.ts"],"names":[],"mappings":";;AA2DA,0DAqCC;AAhGD,8CAMyB;AAGzB,SAAS,aAAa,CAAC,GAAY;IACjC,IAAI,GAAG,YAAY,qCAA0B,EAAE,CAAC;QAC9C,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,IAAI,GAAG,YAAY,2BAAgB,EAAE,CAAC;QACpC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