@abgov/adsp-sdk-mcp-server 1.36.0 → 1.38.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 +88 -22
- package/assets/api-specs/form-service.json +1 -1
- package/assets/api-specs/index.json +1 -1
- package/assets/docs/services/event-service.md +16 -0
- package/assets/docs/services/form-service.md +7 -2
- package/package.json +3 -1
- package/provenance.json +4 -4
- package/src/auth.d.ts +34 -0
- package/src/auth.js +218 -0
- package/src/auth.js.map +1 -0
- package/src/config.d.ts +10 -0
- package/src/config.js +36 -0
- package/src/config.js.map +1 -1
- package/src/guards.js +2 -2
- package/src/guards.js.map +1 -1
- package/src/hosted.d.ts +1 -1
- package/src/hosted.js +1 -1
- package/src/hosted.js.map +1 -1
- package/src/http.d.ts +1 -1
- package/src/http.js +25 -3
- package/src/http.js.map +1 -1
- package/src/instructions.d.ts +2 -5
- package/src/instructions.js +17 -4
- package/src/instructions.js.map +1 -1
- package/src/main.js +1 -1
- package/src/main.js.map +1 -1
- package/src/metrics.d.ts +1 -1
- package/src/server.d.ts +8 -0
- package/src/server.js +35 -4
- package/src/server.js.map +1 -1
- package/src/tools/registerConfigurationSchemaTool.js +13 -4
- package/src/tools/registerConfigurationSchemaTool.js.map +1 -1
- package/src/tools/registerServiceRolesTool.js +13 -4
- package/src/tools/registerServiceRolesTool.js.map +1 -1
- package/src/tools/types.d.ts +9 -0
- package/src/tools/types.js +4 -0
- package/src/tools/types.js.map +1 -1
- package/src/tools/upstreamErrors.d.ts +1 -0
- package/src/tools/upstreamErrors.js +2 -0
- package/src/tools/upstreamErrors.js.map +1 -1
package/src/instructions.js
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SERVER_INSTRUCTIONS = void 0;
|
|
3
|
+
exports.OFFLINE_ENDPOINT_INSTRUCTIONS = exports.SERVER_INSTRUCTIONS = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Returned in the initialize result. Covers only what no single tool description can: which tool answers which
|
|
6
6
|
* kind of question, which tools need a login, and how fresh the bundled content is. Keep it short and never restate
|
|
7
7
|
* a tool description (server.spec.ts checks this); clients may truncate or ignore instructions.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
const TOOL_CHOICE = [
|
|
10
10
|
'Use this server to build services and apps on ADSP (Alberta Digital Service Platform). Pick the tool by the question:',
|
|
11
11
|
'- Before designing or building any capability of an ADSP app, call find_adsp_services with the need. If a result',
|
|
12
12
|
' has ask set, put its fitQuestions to the user rather than picking a service yourself. noMatch: no service fits.',
|
|
13
13
|
'- Platform concepts or how-tos: search_adsp_docs, then read_adsp_doc. Browse services/ with list_adsp_docs.',
|
|
14
14
|
'- Writing a Node service: get_platform_quickstart first, then search_sdk_reference for a specific symbol.',
|
|
15
15
|
"- Calling a service's REST API: search_service_endpoints, then read_service_endpoint.",
|
|
16
|
+
];
|
|
17
|
+
const CONTENT_FRESHNESS = [
|
|
18
|
+
'Bundled content can lag the platform. get_adsp_mcp_server_info says when and from which commit it was built;',
|
|
19
|
+
'mention that when a detail may be out of date.',
|
|
20
|
+
];
|
|
21
|
+
exports.SERVER_INSTRUCTIONS = [
|
|
22
|
+
...TOOL_CHOICE,
|
|
16
23
|
'- Roles a service account needs, or the configuration a platform service accepts from yours: list_service_roles,',
|
|
17
24
|
' get_service_configuration_schema. Only these two reach the live platform; the user must run',
|
|
18
25
|
' `npx @abgov/adsp-cli login` first. Every other tool answers offline from content bundled at build time.',
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
...CONTENT_FRESHNESS,
|
|
27
|
+
].join('\n');
|
|
28
|
+
/** For the hosted /mcp endpoint, which serves only the offline tools and never asks for a sign-in. */
|
|
29
|
+
exports.OFFLINE_ENDPOINT_INSTRUCTIONS = [
|
|
30
|
+
...TOOL_CHOICE,
|
|
31
|
+
'- Roles a service account needs, or the configuration a platform service accepts from yours, are read live and',
|
|
32
|
+
' need a sign-in: connect to /mcp/<tenant realm> on this server instead. Every tool here answers offline.',
|
|
33
|
+
...CONTENT_FRESHNESS,
|
|
21
34
|
].join('\n');
|
|
22
35
|
//# sourceMappingURL=instructions.js.map
|
package/src/instructions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/instructions.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/instructions.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAM,WAAW,GAAG;IAClB,uHAAuH;IACvH,kHAAkH;IAClH,mHAAmH;IACnH,6GAA6G;IAC7G,2GAA2G;IAC3G,uFAAuF;CACxF,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,8GAA8G;IAC9G,gDAAgD;CACjD,CAAC;AAEW,QAAA,mBAAmB,GAAG;IACjC,GAAG,WAAW;IACd,kHAAkH;IAClH,+FAA+F;IAC/F,2GAA2G;IAC3G,GAAG,iBAAiB;CACrB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,sGAAsG;AACzF,QAAA,6BAA6B,GAAG;IAC3C,GAAG,WAAW;IACd,gHAAgH;IAChH,2GAA2G;IAC3G,GAAG,iBAAiB;CACrB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
package/src/main.js
CHANGED
|
@@ -15,7 +15,7 @@ function resolveTransport() {
|
|
|
15
15
|
}
|
|
16
16
|
async function main() {
|
|
17
17
|
const transport = resolveTransport();
|
|
18
|
-
const config = (0, config_1.readConfig)();
|
|
18
|
+
const config = transport === 'http' ? (0, config_1.readHostedConfig)() : (0, config_1.readConfig)();
|
|
19
19
|
console.error(`[adsp-sdk-mcp-server] transport=${transport}`);
|
|
20
20
|
if (transport === 'http') {
|
|
21
21
|
await (0, hosted_1.startMcpHttpServer)({ config });
|
package/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/main.ts"],"names":[],"mappings":";;;AACA,wEAAiF;AACjF,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../libs/adsp-sdk-mcp-server/src/main.ts"],"names":[],"mappings":";;;AACA,wEAAiF;AACjF,qCAAwD;AACxD,qCAA8C;AAC9C,qCAA+C;AAC/C,yDAA+D;AAI/D,SAAS,gBAAgB;IACvB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC;IACpD,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,GAAG,CAAC;IAClD,OAAO,CAAC,KAAK,CAAC,gDAAgD,GAAG,oDAAoD,CAAC,CAAC;IACvH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,IAAA,yBAAgB,GAAE,CAAC,CAAC,CAAC,IAAA,mBAAU,GAAE,CAAC;IACxE,OAAO,CAAC,KAAK,CAAC,mCAAmC,SAAS,EAAE,CAAC,CAAC;IAE9D,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,IAAA,2BAAkB,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,IAAA,sCAAsB,EAAC,EAAE,aAAa,EAAE,MAAM,CAAC,qBAAqB,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QACvG,MAAM,MAAM,GAAG,IAAA,4BAAmB,GAAE,CAAC;QACrC,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,+BAAoB,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,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/metrics.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MeterProvider } from '@opentelemetry/api';
|
|
2
|
-
export type RejectionReason = 'in_flight_cap' | 'rate_limit' | 'origin' | 'live_tool_cap';
|
|
2
|
+
export type RejectionReason = 'in_flight_cap' | 'rate_limit' | 'origin' | 'live_tool_cap' | 'auth' | 'auth_unavailable';
|
|
3
3
|
export type ToolErrorType = 'tool_error' | 'exception' | 'unknown_tool' | 'busy';
|
|
4
4
|
export type UpstreamErrorType = 'http_4xx' | 'http_5xx' | 'network' | 'not_in_directory' | 'not_authenticated' | 'other';
|
|
5
5
|
export interface McpMetrics {
|
package/src/server.d.ts
CHANGED
|
@@ -5,12 +5,20 @@ export interface CreateAdspMcpServerOptions {
|
|
|
5
5
|
docsRoot?: string;
|
|
6
6
|
/** Root directory of bundled OpenAPI specs. Defaults to the assets copied alongside the built package. */
|
|
7
7
|
apiSpecsRoot?: string;
|
|
8
|
+
/** Hosted mode: live tools use each request's verified token and this directory, never the CLI login. */
|
|
9
|
+
hostedAuth?: {
|
|
10
|
+
directoryServiceUrl: string;
|
|
11
|
+
};
|
|
8
12
|
/** The capability catalog find_adsp_services ranks. Defaults to the one bundled with the package. */
|
|
9
13
|
capabilitiesPath?: string;
|
|
14
|
+
/** Serve only the tools that answer from bundled content, for callers that haven't signed in. */
|
|
15
|
+
offlineToolsOnly?: boolean;
|
|
10
16
|
}
|
|
11
17
|
export interface AdspMcpTools {
|
|
12
18
|
tools: (ToolDefinition | LiveToolDefinition)[];
|
|
13
19
|
toolsByName: Map<string, ToolDefinition | LiveToolDefinition>;
|
|
20
|
+
offlineTools: ToolDefinition[];
|
|
21
|
+
offlineToolsByName: Map<string, ToolDefinition>;
|
|
14
22
|
}
|
|
15
23
|
export declare function loadAdspMcpTools(options?: CreateAdspMcpServerOptions): AdspMcpTools;
|
|
16
24
|
export declare function createAdspMcpServer(options?: CreateAdspMcpServerOptions): Server;
|
package/src/server.js
CHANGED
|
@@ -20,6 +20,7 @@ const registerQuickstartTool_1 = require("./tools/registerQuickstartTool");
|
|
|
20
20
|
const registerServiceRolesTool_1 = require("./tools/registerServiceRolesTool");
|
|
21
21
|
const registerSdkTools_1 = require("./tools/registerSdkTools");
|
|
22
22
|
const registerServerInfoTool_1 = require("./tools/registerServerInfoTool");
|
|
23
|
+
const types_1 = require("./tools/types");
|
|
23
24
|
const version_1 = require("./version");
|
|
24
25
|
// Compiled output places this file under dist/.../src/, while the docs asset copy lands one level up at dist/.../assets/docs.
|
|
25
26
|
const DEFAULT_DOCS_ROOT = (0, path_1.join)(__dirname, '..', 'assets', 'docs');
|
|
@@ -52,13 +53,22 @@ function loadAdspMcpTools(options = {}) {
|
|
|
52
53
|
...(0, registerServerInfoTool_1.createServerInfoTool)(docs),
|
|
53
54
|
...(0, registerApiTools_1.createApiTools)(lazy(() => new apiSpecsRepository_1.ApiSpecsRepository(apiSpecsRoot))),
|
|
54
55
|
];
|
|
55
|
-
const
|
|
56
|
+
const offlineTools = tools.filter(types_1.isOfflineTool);
|
|
57
|
+
const loaded = {
|
|
58
|
+
tools,
|
|
59
|
+
toolsByName: new Map(tools.map((tool) => [tool.name, tool])),
|
|
60
|
+
offlineTools,
|
|
61
|
+
offlineToolsByName: new Map(offlineTools.map((tool) => [tool.name, tool])),
|
|
62
|
+
};
|
|
56
63
|
toolsByRoots.set(cacheKey, loaded);
|
|
57
64
|
(0, metrics_1.getMetrics)().recordDocsIndexBuild(secondsSince(started));
|
|
58
65
|
return loaded;
|
|
59
66
|
}
|
|
60
67
|
function createAdspMcpServer(options = {}) {
|
|
61
|
-
const
|
|
68
|
+
const loaded = loadAdspMcpTools(options);
|
|
69
|
+
const { tools, toolsByName } = options.offlineToolsOnly
|
|
70
|
+
? { tools: loaded.offlineTools, toolsByName: loaded.offlineToolsByName }
|
|
71
|
+
: loaded;
|
|
62
72
|
// Deliberately using the low-level Server (McpServer is recommended for typical cases) rather than an oversight:
|
|
63
73
|
// this workspace hoists multiple physical copies of zod (root zod@3.x plus nested zod@4.x/3.x under unrelated
|
|
64
74
|
// deps like @mastra/schema-compat). McpServer.registerTool's zod-compat generics reconcile our zod against the
|
|
@@ -67,7 +77,10 @@ function createAdspMcpServer(options = {}) {
|
|
|
67
77
|
// would fix it but risks changing runtime behavior for unrelated consumers (e.g. agent-service's Mastra agent
|
|
68
78
|
// config). Server + setRequestHandler avoids the SDK's zod-compat generics entirely; tools validate their own
|
|
69
79
|
// args with zod as a plain value (see tools/*.ts), never passing a schema through the SDK's type machinery.
|
|
70
|
-
const server = new index_js_1.Server({ name: 'adsp-sdk-mcp-server', version: (0, version_1.readPackageVersion)() }, {
|
|
80
|
+
const server = new index_js_1.Server({ name: 'adsp-sdk-mcp-server', version: (0, version_1.readPackageVersion)() }, {
|
|
81
|
+
capabilities: { tools: {} },
|
|
82
|
+
instructions: options.offlineToolsOnly ? instructions_1.OFFLINE_ENDPOINT_INSTRUCTIONS : instructions_1.SERVER_INSTRUCTIONS,
|
|
83
|
+
});
|
|
71
84
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
72
85
|
tools: tools.map((tool) => ({
|
|
73
86
|
name: tool.name,
|
|
@@ -80,14 +93,28 @@ function createAdspMcpServer(options = {}) {
|
|
|
80
93
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request, extra) => {
|
|
81
94
|
const started = perf_hooks_1.performance.now();
|
|
82
95
|
const tool = toolsByName.get(request.params.name);
|
|
96
|
+
if (!tool && loaded.toolsByName.has(request.params.name)) {
|
|
97
|
+
(0, metrics_1.getMetrics)().recordToolCall(request.params.name, secondsSince(started), 'tool_error');
|
|
98
|
+
return { isError: true, content: [{ type: 'text', text: liveToolNeedsSignIn(request.params.name) }] };
|
|
99
|
+
}
|
|
83
100
|
if (!tool) {
|
|
84
101
|
// The label is fixed so client-supplied names can't create new metric series.
|
|
85
102
|
(0, metrics_1.getMetrics)().recordToolCall('unknown', secondsSince(started), 'unknown_tool');
|
|
86
103
|
return { isError: true, content: [{ type: 'text', text: `Unknown tool: ${request.params.name}` }] };
|
|
87
104
|
}
|
|
105
|
+
let caller;
|
|
106
|
+
if (options.hostedAuth) {
|
|
107
|
+
const accessToken = extra.authInfo?.token;
|
|
108
|
+
// Refused rather than falling through, so a hosted server never acts with its own CLI login.
|
|
109
|
+
if (!accessToken) {
|
|
110
|
+
(0, metrics_1.getMetrics)().recordToolCall(tool.name, secondsSince(started), 'tool_error');
|
|
111
|
+
return { isError: true, content: [{ type: 'text', text: 'Sign-in required. Sign in from your MCP client.' }] };
|
|
112
|
+
}
|
|
113
|
+
caller = { accessToken, directoryServiceUrl: options.hostedAuth.directoryServiceUrl };
|
|
114
|
+
}
|
|
88
115
|
try {
|
|
89
116
|
// clean-code-ignore: 2.18 — ToolDefinition.handler is documented (tools/types.ts) as a pure, side-effect-free lookup.
|
|
90
|
-
const result = await tool.handler(request.params.arguments ?? {}, { signal: extra.signal });
|
|
117
|
+
const result = await tool.handler(request.params.arguments ?? {}, { signal: extra.signal, caller });
|
|
91
118
|
(0, metrics_1.getMetrics)().recordToolCall(tool.name, secondsSince(started), toolErrorType(result));
|
|
92
119
|
return result;
|
|
93
120
|
}
|
|
@@ -98,6 +125,10 @@ function createAdspMcpServer(options = {}) {
|
|
|
98
125
|
});
|
|
99
126
|
return server;
|
|
100
127
|
}
|
|
128
|
+
function liveToolNeedsSignIn(name) {
|
|
129
|
+
return (`${name} reads the live platform, so it needs a sign-in. Connect to /mcp/<tenant realm> on this server and ` +
|
|
130
|
+
'sign in, or run the server locally with npx @abgov/adsp-sdk-mcp-server.');
|
|
131
|
+
}
|
|
101
132
|
function toolErrorType(result) {
|
|
102
133
|
if ((0, liveToolLimit_1.isBusyResult)(result)) {
|
|
103
134
|
return 'busy';
|
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":";;AAsDA,4CAgCC;AAED,kDAoEC;AA5JD,wEAAmE;AACnE,iEAAmH;AACnH,+BAAqC;AACrC,2CAAyC;AACzC,uEAAoE;AACpE,oDAA+D;AAC/D,0DAAuD;AACvD,iDAAoF;AACpF,uCAAsD;AACtD,+DAA0D;AAC1D,6FAAyF;AACzF,yDAAqD;AACrD,iEAA4D;AAC5D,+EAA0E;AAC1E,2EAAsE;AACtE,+EAA2E;AAC3E,+DAA0D;AAC1D,2EAAsE;AACtE,yCAAgG;AAChG,uCAA+C;AAsB/C,8HAA8H;AAC9H,MAAM,iBAAiB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAClE,MAAM,sBAAsB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAC5E,2GAA2G;AAC3G,MAAM,yBAAyB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC;AAEvF,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwB,CAAC;AAErD,SAAS,IAAI,CAAI,MAAe;IAC9B,IAAI,KAAoB,CAAC;IACzB,OAAO,GAAG,EAAE,CAAC,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,gBAAgB,CAAC,UAAsC,EAAE;IACvE,MAA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,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,CACL,GAAG,IAAI,qGAAqG;QAC5G,yEAAyE,CAC1E,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAsB;IAC3C,IAAI,IAAA,4BAAY,EAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,CAAC,wBAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;AAC9C,CAAC"}
|
|
@@ -6,15 +6,22 @@ const metrics_1 = require("../metrics");
|
|
|
6
6
|
const types_1 = require("./types");
|
|
7
7
|
const liveToolLimit_1 = require("./liveToolLimit");
|
|
8
8
|
const upstreamErrors_1 = require("./upstreamErrors");
|
|
9
|
-
function describeError(err) {
|
|
9
|
+
function describeError(err, signedInCaller) {
|
|
10
10
|
if (err instanceof adsp_cli_1.ServiceNotInDirectoryError) {
|
|
11
11
|
return err.message;
|
|
12
12
|
}
|
|
13
13
|
if (err instanceof adsp_cli_1.HttpRequestError) {
|
|
14
14
|
if (err.status === 401) {
|
|
15
|
+
if (signedInCaller) {
|
|
16
|
+
return upstreamErrors_1.CALLER_SIGN_IN_REJECTED;
|
|
17
|
+
}
|
|
15
18
|
return 'Access token was rejected (401). Run `npx @abgov/adsp-cli login` again to refresh it.';
|
|
16
19
|
}
|
|
17
20
|
if (err.status === 403) {
|
|
21
|
+
if (signedInCaller) {
|
|
22
|
+
return ('Access denied (403) reading configuration-service schemas. This is more likely the wrong tenant realm ' +
|
|
23
|
+
'than a missing role — check the realm in your MCP server URL.');
|
|
24
|
+
}
|
|
18
25
|
return ('Access denied (403) reading configuration-service schemas. This is more likely the wrong tenant realm ' +
|
|
19
26
|
'or environment than a missing role — check ADSP_TENANT_REALM and ADSP_ENV.');
|
|
20
27
|
}
|
|
@@ -31,6 +38,7 @@ function describeError(err) {
|
|
|
31
38
|
function createConfigurationSchemaTools() {
|
|
32
39
|
return [
|
|
33
40
|
{
|
|
41
|
+
kind: 'live',
|
|
34
42
|
name: 'get_service_configuration_schema',
|
|
35
43
|
annotations: types_1.LIVE_TOOL_ANNOTATIONS,
|
|
36
44
|
description: 'Returns the configuration schema(s) for ADSP platform services, read live from configuration-service. ' +
|
|
@@ -49,7 +57,8 @@ function createConfigurationSchemaTools() {
|
|
|
49
57
|
},
|
|
50
58
|
},
|
|
51
59
|
handler: (args, context) => (0, liveToolLimit_1.withLiveToolPermit)(async () => {
|
|
52
|
-
const
|
|
60
|
+
const caller = context?.caller;
|
|
61
|
+
const tokenResult = caller ? { status: 'ok', token: caller.accessToken } : await (0, adsp_cli_1.getAccessToken)();
|
|
53
62
|
if (tokenResult.status === 'not-authenticated') {
|
|
54
63
|
(0, metrics_1.getMetrics)().recordUpstreamError('get_service_configuration_schema', 'not_authenticated');
|
|
55
64
|
return {
|
|
@@ -60,7 +69,7 @@ function createConfigurationSchemaTools() {
|
|
|
60
69
|
};
|
|
61
70
|
}
|
|
62
71
|
try {
|
|
63
|
-
const directoryServiceUrl = (0, adsp_cli_1.getDirectoryServiceUrl)();
|
|
72
|
+
const directoryServiceUrl = caller ? caller.directoryServiceUrl : (0, adsp_cli_1.getDirectoryServiceUrl)();
|
|
64
73
|
const schemas = await (0, adsp_cli_1.getServiceConfigurationSchemas)(tokenResult.token, directoryServiceUrl, args.serviceId);
|
|
65
74
|
return {
|
|
66
75
|
content: [{ type: 'text', text: JSON.stringify(schemas, null, 2) }],
|
|
@@ -68,7 +77,7 @@ function createConfigurationSchemaTools() {
|
|
|
68
77
|
}
|
|
69
78
|
catch (err) {
|
|
70
79
|
(0, metrics_1.getMetrics)().recordUpstreamError('get_service_configuration_schema', (0, upstreamErrors_1.classifyUpstreamError)(err));
|
|
71
|
-
return { isError: true, content: [{ type: 'text', text: describeError(err) }] };
|
|
80
|
+
return { isError: true, content: [{ type: 'text', text: describeError(err, caller !== undefined) }] };
|
|
72
81
|
}
|
|
73
82
|
}, context?.signal),
|
|
74
83
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerConfigurationSchemaTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerConfigurationSchemaTool.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"registerConfigurationSchemaTool.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/registerConfigurationSchemaTool.ts"],"names":[],"mappings":";;AAiDA,wEAsDC;AAvGD,8CAMyB;AACzB,wCAAwC;AACxC,mCAAoE;AACpE,mDAAqD;AACrD,qDAAkF;AAElF,SAAS,aAAa,CAAC,GAAY,EAAE,cAAuB;IAC1D,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,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,wCAAuB,CAAC;YACjC,CAAC;YACD,OAAO,uFAAuF,CAAC;QACjG,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvB,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,CACL,wGAAwG;oBACxG,+DAA+D,CAChE,CAAC;YACJ,CAAC;YACD,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,8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yBACxG;qBACF,CAAC;gBACJ,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,mBAAmB,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAA,iCAAsB,GAAE,CAAC;oBAC3F,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,IAAA,oBAAU,GAAE,CAAC,mBAAmB,CAAC,kCAAkC,EAAE,IAAA,sCAAqB,EAAC,GAAG,CAAC,CAAC,CAAC;oBACjG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxG,CAAC;YACH,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC;SACtB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -6,15 +6,22 @@ const metrics_1 = require("../metrics");
|
|
|
6
6
|
const types_1 = require("./types");
|
|
7
7
|
const liveToolLimit_1 = require("./liveToolLimit");
|
|
8
8
|
const upstreamErrors_1 = require("./upstreamErrors");
|
|
9
|
-
function describeError(err) {
|
|
9
|
+
function describeError(err, signedInCaller) {
|
|
10
10
|
if (err instanceof adsp_cli_1.ServiceNotInDirectoryError) {
|
|
11
11
|
return err.message;
|
|
12
12
|
}
|
|
13
13
|
if (err instanceof adsp_cli_1.HttpRequestError) {
|
|
14
14
|
if (err.status === 401) {
|
|
15
|
+
if (signedInCaller) {
|
|
16
|
+
return upstreamErrors_1.CALLER_SIGN_IN_REJECTED;
|
|
17
|
+
}
|
|
15
18
|
return 'Access token was rejected (401). Run `npx @abgov/adsp-cli login` again to refresh it.';
|
|
16
19
|
}
|
|
17
20
|
if (err.status === 403) {
|
|
21
|
+
if (signedInCaller) {
|
|
22
|
+
return ('Access denied (403) reading tenant-service configuration. This is more likely the wrong tenant realm ' +
|
|
23
|
+
'than a missing role — check the realm in your MCP server URL.');
|
|
24
|
+
}
|
|
18
25
|
return ('Access denied (403) reading tenant-service configuration. This is more likely the wrong tenant realm ' +
|
|
19
26
|
'or environment than a missing role — check ADSP_TENANT_REALM and ADSP_ENV.');
|
|
20
27
|
}
|
|
@@ -52,6 +59,7 @@ always need explicit assignment regardless of that flag.
|
|
|
52
59
|
function createServiceRolesTools() {
|
|
53
60
|
return [
|
|
54
61
|
{
|
|
62
|
+
kind: 'live',
|
|
55
63
|
name: 'list_service_roles',
|
|
56
64
|
annotations: types_1.LIVE_TOOL_ANNOTATIONS,
|
|
57
65
|
description: 'List every ADSP platform service\'s registered RBAC role (role name, description, whether it is ' +
|
|
@@ -63,7 +71,8 @@ function createServiceRolesTools() {
|
|
|
63
71
|
'ADSP_CLIENT_ID and ADSP_CLIENT_SECRET environment variables for non-interactive/CI use.',
|
|
64
72
|
inputSchema: { type: 'object', properties: {} },
|
|
65
73
|
handler: (_args, context) => (0, liveToolLimit_1.withLiveToolPermit)(async () => {
|
|
66
|
-
const
|
|
74
|
+
const caller = context?.caller;
|
|
75
|
+
const tokenResult = caller ? { status: 'ok', token: caller.accessToken } : await (0, adsp_cli_1.getAccessToken)();
|
|
67
76
|
if (tokenResult.status === 'not-authenticated') {
|
|
68
77
|
(0, metrics_1.getMetrics)().recordUpstreamError('list_service_roles', 'not_authenticated');
|
|
69
78
|
return {
|
|
@@ -74,7 +83,7 @@ function createServiceRolesTools() {
|
|
|
74
83
|
};
|
|
75
84
|
}
|
|
76
85
|
try {
|
|
77
|
-
const directoryServiceUrl = (0, adsp_cli_1.getDirectoryServiceUrl)();
|
|
86
|
+
const directoryServiceUrl = caller ? caller.directoryServiceUrl : (0, adsp_cli_1.getDirectoryServiceUrl)();
|
|
78
87
|
const roles = await (0, adsp_cli_1.getServiceRoles)(tokenResult.token, directoryServiceUrl);
|
|
79
88
|
return {
|
|
80
89
|
content: [{ type: 'text', text: SERVICE_ROLES_PREAMBLE + JSON.stringify(roles, null, 2) }],
|
|
@@ -82,7 +91,7 @@ function createServiceRolesTools() {
|
|
|
82
91
|
}
|
|
83
92
|
catch (err) {
|
|
84
93
|
(0, metrics_1.getMetrics)().recordUpstreamError('list_service_roles', (0, upstreamErrors_1.classifyUpstreamError)(err));
|
|
85
|
-
return { isError: true, content: [{ type: 'text', text: describeError(err) }] };
|
|
94
|
+
return { isError: true, content: [{ type: 'text', text: describeError(err, caller !== undefined) }] };
|
|
86
95
|
}
|
|
87
96
|
}, context?.signal),
|
|
88
97
|
},
|
|
@@ -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":";;AAuEA,0DA2CC;AAlHD,8CAMyB;AACzB,wCAAwC;AACxC,mCAAoE;AACpE,mDAAqD;AACrD,qDAAkF;AAElF,SAAS,aAAa,CAAC,GAAY,EAAE,cAAuB;IAC1D,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,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,w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SACtB;KACF,CAAC;AACJ,CAAC"}
|
package/src/tools/types.d.ts
CHANGED
|
@@ -4,9 +4,15 @@ export interface JsonSchemaObject {
|
|
|
4
4
|
properties?: Record<string, unknown>;
|
|
5
5
|
required?: string[];
|
|
6
6
|
}
|
|
7
|
+
export interface CallerSignIn {
|
|
8
|
+
accessToken: string;
|
|
9
|
+
directoryServiceUrl: string;
|
|
10
|
+
}
|
|
7
11
|
export interface ToolCallContext {
|
|
8
12
|
/** Aborted when the client cancels the call or disconnects. */
|
|
9
13
|
signal?: AbortSignal;
|
|
14
|
+
/** Set in hosted mode: live tools act as the signed-in caller instead of the local CLI login. */
|
|
15
|
+
caller?: CallerSignIn;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* MCP tool annotations are hints for the client, not enforcement. Every tool here only reads, so all declare
|
|
@@ -38,7 +44,10 @@ export interface ToolDefinition {
|
|
|
38
44
|
*/
|
|
39
45
|
handler: (args: Record<string, unknown>, context?: ToolCallContext) => Promise<CallToolResult> | CallToolResult;
|
|
40
46
|
}
|
|
47
|
+
export declare function isOfflineTool(tool: ToolDefinition | LiveToolDefinition): tool is ToolDefinition;
|
|
41
48
|
export interface LiveToolDefinition {
|
|
49
|
+
/** Required, not inferred from annotations, because plain /mcp serves every tool that lacks it without sign-in. */
|
|
50
|
+
kind: 'live';
|
|
42
51
|
name: string;
|
|
43
52
|
description: string;
|
|
44
53
|
inputSchema: JsonSchemaObject;
|
package/src/tools/types.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LIVE_TOOL_ANNOTATIONS = exports.OFFLINE_TOOL_ANNOTATIONS = void 0;
|
|
4
|
+
exports.isOfflineTool = isOfflineTool;
|
|
4
5
|
/**
|
|
5
6
|
* MCP tool annotations are hints for the client, not enforcement. Every tool here only reads, so all declare
|
|
6
7
|
* `readOnlyHint`. Offline tools answer from content bundled in the package, so they also declare a closed world;
|
|
@@ -8,4 +9,7 @@ exports.LIVE_TOOL_ANNOTATIONS = exports.OFFLINE_TOOL_ANNOTATIONS = void 0;
|
|
|
8
9
|
*/
|
|
9
10
|
exports.OFFLINE_TOOL_ANNOTATIONS = { readOnlyHint: true, openWorldHint: false };
|
|
10
11
|
exports.LIVE_TOOL_ANNOTATIONS = { readOnlyHint: true };
|
|
12
|
+
function isOfflineTool(tool) {
|
|
13
|
+
return !('kind' in tool);
|
|
14
|
+
}
|
|
11
15
|
//# sourceMappingURL=types.js.map
|
package/src/tools/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/types.ts"],"names":[],"mappings":";;;AA4CA,sCAEC;AA1BD;;;;GAIG;AACU,QAAA,wBAAwB,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAW,CAAC;AACjF,QAAA,qBAAqB,GAAG,EAAE,YAAY,EAAE,IAAI,EAAW,CAAC;AAkBrE,SAAgB,aAAa,CAAC,IAAyC;IACrE,OAAO,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CALLER_SIGN_IN_REJECTED = void 0;
|
|
3
4
|
exports.classifyUpstreamError = classifyUpstreamError;
|
|
4
5
|
const adsp_cli_1 = require("@abgov/adsp-cli");
|
|
6
|
+
exports.CALLER_SIGN_IN_REJECTED = 'Your sign-in was rejected or has expired. Sign in again from your MCP client.';
|
|
5
7
|
function classifyUpstreamError(err) {
|
|
6
8
|
if (err instanceof adsp_cli_1.ServiceNotInDirectoryError) {
|
|
7
9
|
return 'not_in_directory';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upstreamErrors.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/upstreamErrors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upstreamErrors.js","sourceRoot":"","sources":["../../../../../libs/adsp-sdk-mcp-server/src/tools/upstreamErrors.ts"],"names":[],"mappings":";;;AAMA,sDAYC;AAlBD,8CAA+E;AAGlE,QAAA,uBAAuB,GAClC,+EAA+E,CAAC;AAElF,SAAgB,qBAAqB,CAAC,GAAY;IAChD,IAAI,GAAG,YAAY,qCAA0B,EAAE,CAAC;QAC9C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,IAAI,GAAG,YAAY,2BAAgB,EAAE,CAAC;QACpC,OAAO,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;IACrD,CAAC;IACD,sEAAsE;IACtE,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|