@cyanheads/mcp-ts-core 0.13.9 → 0.13.10
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/AGENTS.md +36 -13
- package/CLAUDE.md +36 -13
- package/README.md +9 -9
- package/changelog/0.13.x/0.13.10.md +118 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +11 -0
- package/dist/config/index.js.map +1 -1
- package/dist/core/app.d.ts.map +1 -1
- package/dist/core/app.js +15 -1
- package/dist/core/app.js.map +1 -1
- package/dist/core/context.d.ts +89 -20
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +40 -0
- package/dist/core/context.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/worker.d.ts +6 -0
- package/dist/core/worker.d.ts.map +1 -1
- package/dist/core/worker.js +1 -0
- package/dist/core/worker.js.map +1 -1
- package/dist/linter/rules/error-contract-rules.d.ts +3 -44
- package/dist/linter/rules/error-contract-rules.d.ts.map +1 -1
- package/dist/linter/rules/error-contract-rules.js +8 -144
- package/dist/linter/rules/error-contract-rules.js.map +1 -1
- package/dist/linter/rules/index.d.ts +1 -1
- package/dist/linter/rules/index.d.ts.map +1 -1
- package/dist/linter/rules/index.js +1 -1
- package/dist/linter/rules/index.js.map +1 -1
- package/dist/linter/rules/resource-rules.d.ts.map +1 -1
- package/dist/linter/rules/resource-rules.js +1 -2
- package/dist/linter/rules/resource-rules.js.map +1 -1
- package/dist/linter/rules/tool-rules.d.ts.map +1 -1
- package/dist/linter/rules/tool-rules.js +1 -2
- package/dist/linter/rules/tool-rules.js.map +1 -1
- package/dist/mcp-server/handlerContext.d.ts +26 -13
- package/dist/mcp-server/handlerContext.d.ts.map +1 -1
- package/dist/mcp-server/handlerContext.js +32 -17
- package/dist/mcp-server/handlerContext.js.map +1 -1
- package/dist/mcp-server/inputRequired.d.ts +120 -8
- package/dist/mcp-server/inputRequired.d.ts.map +1 -1
- package/dist/mcp-server/inputRequired.js +177 -12
- package/dist/mcp-server/inputRequired.js.map +1 -1
- package/dist/mcp-server/prompts/prompt-registration.d.ts +10 -2
- package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -1
- package/dist/mcp-server/prompts/prompt-registration.js +49 -11
- package/dist/mcp-server/prompts/prompt-registration.js.map +1 -1
- package/dist/mcp-server/resources/resource-registration.d.ts +4 -2
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.js +6 -4
- package/dist/mcp-server/resources/resource-registration.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +4 -3
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +42 -14
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
- package/dist/mcp-server/server.d.ts +9 -0
- package/dist/mcp-server/server.d.ts.map +1 -1
- package/dist/mcp-server/server.js +14 -13
- package/dist/mcp-server/server.js.map +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +7 -3
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/tool-registration.js +9 -5
- package/dist/mcp-server/tools/tool-registration.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +17 -9
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +91 -50
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.js +7 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
- package/dist/testing/index.d.ts +17 -2
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +21 -7
- package/dist/testing/index.js.map +1 -1
- package/dist/types-global/errors.d.ts +18 -15
- package/dist/types-global/errors.d.ts.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.d.ts +5 -4
- package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.js +9 -7
- package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
- package/dist/utils/internal/error-handler/types.d.ts +3 -1
- package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
- package/dist/utils/internal/performance.d.ts +4 -2
- package/dist/utils/internal/performance.d.ts.map +1 -1
- package/dist/utils/internal/performance.js +8 -6
- package/dist/utils/internal/performance.js.map +1 -1
- package/dist/utils/internal/telemetryMessages.d.ts +0 -1
- package/dist/utils/internal/telemetryMessages.d.ts.map +1 -1
- package/dist/utils/internal/telemetryMessages.js +0 -1
- package/dist/utils/internal/telemetryMessages.js.map +1 -1
- package/dist/utils/telemetry/attributes.d.ts +5 -4
- package/dist/utils/telemetry/attributes.d.ts.map +1 -1
- package/dist/utils/telemetry/attributes.js +5 -4
- package/dist/utils/telemetry/attributes.js.map +1 -1
- package/framework-skills/add-service/SKILL.md +3 -12
- package/framework-skills/add-test/SKILL.md +6 -3
- package/framework-skills/add-tool/SKILL.md +29 -33
- package/framework-skills/api-config/SKILL.md +2 -1
- package/framework-skills/api-context/SKILL.md +155 -40
- package/framework-skills/api-errors/SKILL.md +43 -47
- package/framework-skills/api-linter/SKILL.md +5 -29
- package/framework-skills/api-telemetry/SKILL.md +11 -7
- package/framework-skills/api-testing/SKILL.md +43 -11
- package/framework-skills/api-workers/SKILL.md +3 -1
- package/framework-skills/design-mcp-server/SKILL.md +5 -5
- package/framework-skills/field-test/SKILL.md +2 -2
- package/framework-skills/polish-docs-meta/SKILL.md +2 -2
- package/framework-skills/release-and-publish/SKILL.md +3 -3
- package/framework-skills/release-pr-review/SKILL.md +2 -2
- package/framework-skills/security-pass/SKILL.md +8 -7
- package/package.json +4 -3
- package/scripts/install-otel.ts +84 -0
- package/scripts/lint-packaging.ts +188 -27
- package/templates/.env.example +2 -0
- package/templates/AGENTS.md +5 -4
- package/templates/CLAUDE.md +5 -4
- package/templates/Dockerfile +67 -50
- package/templates/src/mcp-server/tools/definitions/echo.tool.ts +3 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputRequired.js","sourceRoot":"","sources":["../../src/mcp-server/inputRequired.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"inputRequired.js","sourceRoot":"","sources":["../../src/mcp-server/inputRequired.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,eAAe,EACf,4BAA4B,EAE5B,uBAAuB,EAIvB,aAAa,EACb,aAAa,GAId,MAAM,8BAA8B,CAAC;AAItC,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,QAAQ,GACT,MAAM,0BAA0B,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAIvB,MAAM;IAH3B,wEAAwE;IAC/D,qBAAqB,GAAG,IAAa,CAAC;IAE/C,YAAqB,MAA2B;QAC9C,KAAK,CAAC,2DAA2D,CAAC,CAAC;sBADhD,MAAM;QAEzB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,OAAO,CACL,KAAK,YAAY,mBAAmB;QACpC,CAAC,OAAO,KAAK,KAAK,QAAQ;YACxB,KAAK,KAAK,IAAI;YACb,KAA6C,CAAC,qBAAqB,KAAK,IAAI,CAAC,CACjF,CAAC;AACJ,CAAC;AA+BD;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAwB,EACxB,MAAiB;IAEjB,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;QACrB,OAAO;YACL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CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,aAAa,CAClB,8DAA8D,EAC9D,SAAS,EACT,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -6,16 +6,24 @@
|
|
|
6
6
|
* @module src/mcp-server/prompts/prompt-registration
|
|
7
7
|
*/
|
|
8
8
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
9
|
+
import { type RequestStateSealer } from '../inputRequired.js';
|
|
9
10
|
import type { AnyPromptDefinition } from './utils/promptDefinition.js';
|
|
10
11
|
import type { logger as defaultLogger } from '../../utils/internal/logger.js';
|
|
11
12
|
export declare class PromptRegistry {
|
|
12
13
|
private promptDefs;
|
|
13
14
|
private logger;
|
|
15
|
+
private requestState?;
|
|
14
16
|
/** Tracks registered prompt names to detect duplicates at startup. */
|
|
15
17
|
private readonly registeredNames;
|
|
16
|
-
constructor(promptDefs: AnyPromptDefinition[], logger: typeof defaultLogger);
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* @param requestState - The process's `requestState` sealer, present when
|
|
20
|
+
* `MCP_REQUEST_STATE_KEY` is set; an `input_required` result leaves with
|
|
21
|
+
* its state sealed, as a tool's and a resource's do.
|
|
22
|
+
*/
|
|
23
|
+
constructor(promptDefs: AnyPromptDefinition[], logger: typeof defaultLogger, requestState?: RequestStateSealer | undefined);
|
|
24
|
+
/**
|
|
25
|
+
* Registers all prompts on the given MCP server. Registration logs under one
|
|
26
|
+
* context; each `prompts/get` call logs under its own.
|
|
19
27
|
*/
|
|
20
28
|
registerAll(server: McpServer): Promise<void>;
|
|
21
29
|
/** Throws at startup if a prompt with the same name was already registered. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"prompt-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAGV,SAAS,EAEV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAG1F,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI1E,qBAAa,cAAc;IAUvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY,CAAC;IAXvB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD;;;;OAIG;IACH,YACU,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,OAAO,aAAa,EAC5B,YAAY,CAAC,EAAE,kBAAkB,YAAA,EACvC;IAEJ;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlD;IAED,+EAA+E;IAC/E,OAAO,CAAC,gBAAgB;YAUV,cAAc;CAsG7B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handlerParentContext } from '../handlerContext.js';
|
|
2
|
+
import { isInputRequiredSignal, sealThrown, } from '../inputRequired.js';
|
|
2
3
|
import { JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
|
|
3
4
|
import { ErrorHandler } from '../../utils/internal/error-handler/errorHandler.js';
|
|
4
5
|
import { measurePromptGeneration } from '../../utils/internal/performance.js';
|
|
@@ -6,14 +7,22 @@ import { requestContextService } from '../../utils/internal/requestContext.js';
|
|
|
6
7
|
export class PromptRegistry {
|
|
7
8
|
promptDefs;
|
|
8
9
|
logger;
|
|
10
|
+
requestState;
|
|
9
11
|
/** Tracks registered prompt names to detect duplicates at startup. */
|
|
10
12
|
registeredNames = new Set();
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @param requestState - The process's `requestState` sealer, present when
|
|
15
|
+
* `MCP_REQUEST_STATE_KEY` is set; an `input_required` result leaves with
|
|
16
|
+
* its state sealed, as a tool's and a resource's do.
|
|
17
|
+
*/
|
|
18
|
+
constructor(promptDefs, logger, requestState) {
|
|
12
19
|
this.promptDefs = promptDefs;
|
|
13
20
|
this.logger = logger;
|
|
21
|
+
this.requestState = requestState;
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
|
-
* Registers all prompts on the given MCP server.
|
|
24
|
+
* Registers all prompts on the given MCP server. Registration logs under one
|
|
25
|
+
* context; each `prompts/get` call logs under its own.
|
|
17
26
|
*/
|
|
18
27
|
async registerAll(server) {
|
|
19
28
|
this.registeredNames.clear();
|
|
@@ -52,10 +61,34 @@ export class PromptRegistry {
|
|
|
52
61
|
...(promptDef.args && {
|
|
53
62
|
argsSchema: promptDef.args,
|
|
54
63
|
}),
|
|
55
|
-
}, async (
|
|
64
|
+
}, async (...params) => {
|
|
65
|
+
// The SDK calls a prompt registered with `argsSchema` as
|
|
66
|
+
// `(args, ctx)` and one without as `(ctx)` alone (#581).
|
|
67
|
+
const [args, serverContext] = (promptDef.args ? params : [undefined, params[0]]);
|
|
68
|
+
// Per call, as for tools and resources, not the registration `context`:
|
|
69
|
+
// its `requestId` is the one the call's records carry and its error
|
|
70
|
+
// `data` returns (#576).
|
|
71
|
+
const requestContext = requestContextService.createRequestContext({
|
|
72
|
+
parentContext: handlerParentContext(serverContext),
|
|
73
|
+
operation: 'HandlePromptGet',
|
|
74
|
+
additionalContext: { promptName: promptDef.name },
|
|
75
|
+
});
|
|
56
76
|
try {
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
// An argless prompt's `generate` is typed to receive `{}`; its
|
|
78
|
+
// input measures as nothing.
|
|
79
|
+
const validatedArgs = promptDef.args ? promptDef.args.parse(args) : {};
|
|
80
|
+
const messages = await measurePromptGeneration(async () => {
|
|
81
|
+
try {
|
|
82
|
+
return await promptDef.generate(validatedArgs);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
// Inside the measurement, as for tools and resources: an
|
|
86
|
+
// input-required signal leaves with its `requestState`
|
|
87
|
+
// sealed when a key is configured, so a sealing failure
|
|
88
|
+
// is a failed call like any other.
|
|
89
|
+
throw await sealThrown(error, this.requestState, serverContext);
|
|
90
|
+
}
|
|
91
|
+
}, { ...requestContext, promptName: promptDef.name }, promptDef.args ? validatedArgs : undefined);
|
|
59
92
|
return { messages };
|
|
60
93
|
}
|
|
61
94
|
catch (error) {
|
|
@@ -65,15 +98,20 @@ export class PromptRegistry {
|
|
|
65
98
|
if (isInputRequiredSignal(error))
|
|
66
99
|
return error.result;
|
|
67
100
|
/**
|
|
68
|
-
* `handleError`
|
|
69
|
-
*
|
|
70
|
-
*
|
|
101
|
+
* `handleError` writes the call's one `error` record, with the
|
|
102
|
+
* stack and cause chain; the completion record stays at `info`
|
|
103
|
+
* (#582). The client gets the classified code and message, plus
|
|
104
|
+
* only the `data` a thrown `McpError` declared and the call's
|
|
105
|
+
* `requestId` (#576) — the same wire shape as tools and resources.
|
|
71
106
|
*/
|
|
72
107
|
const handled = ErrorHandler.handleError(error, {
|
|
73
108
|
operation: `prompt:${promptDef.name}`,
|
|
74
|
-
context,
|
|
109
|
+
context: requestContext,
|
|
75
110
|
});
|
|
76
|
-
throw new McpError(handled instanceof McpError ? handled.code : JsonRpcErrorCode.InternalError, handled.message,
|
|
111
|
+
throw new McpError(handled instanceof McpError ? handled.code : JsonRpcErrorCode.InternalError, handled.message, {
|
|
112
|
+
...(error instanceof McpError ? error.data : undefined),
|
|
113
|
+
requestId: requestContext.requestId,
|
|
114
|
+
}, { cause: error });
|
|
77
115
|
}
|
|
78
116
|
});
|
|
79
117
|
this.logger.debug(`Registered prompt: ${promptDef.name}`, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompt-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/prompts/prompt-registration.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,qBAAqB,EAErB,UAAU,GACX,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,MAAM,OAAO,cAAc;IAUf,UAAU;IACV,MAAM;IACN,YAAY;IAXtB,sEAAsE;IACrD,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAErD;;;;OAIG;IACH,YACU,UAAiC,EACjC,MAA4B,EAC5B,YAAiC;0BAFjC,UAAU;sBACV,MAAM;4BACN,YAAY;IACnB,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,MAAiB;QACjC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAE7B,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,4BAA4B;SACxC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,UAAU,CAAC,MAAM,eAAe,EAAE,OAAO,CAAC,CAAC;QAEjF,qEAAqE;QACrE,2EAA2E;QAC3E,2DAA2D;QAC3D,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;Q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AAC;oBAEtD;;;;;;uBAMG;oBACH,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE;wBAC9C,SAAS,EAAE,UAAU,SAAS,CAAC,IAAI,EAAE;wBACrC,OAAO,EAAE,cAAc;qBACxB,CAAC,CAAC;oBACH,MAAM,IAAI,QAAQ,CAChB,OAAO,YAAY,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,EAC3E,OAAO,CAAC,OAAO,EACf;wBACE,GAAG,CAAC,KAAK,YAAY,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;wBACvD,SAAS,EAAE,cAAc,CAAC,SAAS;qBACpC,EACD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;gBACJ,CAAC;YACH,CAAC,CACF,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,SAAS,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC,EACD;YACE,SAAS,EAAE,qBAAqB,SAAS,CAAC,IAAI,EAAE;YAChD,OAAO;YACP,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module src/mcp-server/resources/resource-registration
|
|
4
4
|
*/
|
|
5
5
|
import { type McpServer, type ServerNotifier } from '@modelcontextprotocol/server';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ClientCapabilityView } from '../inputRequired.js';
|
|
7
7
|
import type { ResourceSubscriptions } from '../notifications.js';
|
|
8
8
|
import type { AnyResourceDefinition } from './utils/resourceDefinition.js';
|
|
9
9
|
import { type HandlerServices } from './utils/resourceHandlerFactory.js';
|
|
@@ -15,8 +15,10 @@ export declare class ResourceRegistry {
|
|
|
15
15
|
constructor(resourceDefs: AnyResourceDefinition[], services: HandlerServices);
|
|
16
16
|
/**
|
|
17
17
|
* Registers all resolved resource definitions with the provided McpServer instance.
|
|
18
|
+
* `capabilities` is the instance's view of what its client declared (#580),
|
|
19
|
+
* which every handler context resolves per request.
|
|
18
20
|
*/
|
|
19
|
-
registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier,
|
|
21
|
+
registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier, capabilities?: ClientCapabilityView): Promise<void>;
|
|
20
22
|
/** Throws at startup if a resource with the same name was already registered. */
|
|
21
23
|
private assertUniqueName;
|
|
22
24
|
private registerResource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"resource-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,wDAAwD,CAAC;AAUhE,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,QAAQ;IALlB,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACU,YAAY,EAAE,qBAAqB,EAAE,EACrC,QAAQ,EAAE,eAAe,EAC/B;IAEJ;;;;OAIG;IACU,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,EACpB,YAAY,CAAC,EAAE,oBAAoB,GAClC,OAAO,CAAC,IAAI,CAAC,CA4Bf;IAED,iFAAiF;IACjF,OAAO,CAAC,gBAAgB;YAUV,gBAAgB;CAyD/B"}
|
|
@@ -22,8 +22,10 @@ export class ResourceRegistry {
|
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Registers all resolved resource definitions with the provided McpServer instance.
|
|
25
|
+
* `capabilities` is the instance's view of what its client declared (#580),
|
|
26
|
+
* which every handler context resolves per request.
|
|
25
27
|
*/
|
|
26
|
-
async registerAll(server, subscriptions, bus,
|
|
28
|
+
async registerAll(server, subscriptions, bus, capabilities) {
|
|
27
29
|
this.registeredNames.clear();
|
|
28
30
|
// Per-server notifier closures targeting `server.send*ListChanged()`. Bound
|
|
29
31
|
// once per registerAll() call — never mutated on a shared services object
|
|
@@ -45,7 +47,7 @@ export class ResourceRegistry {
|
|
|
45
47
|
// declared `resources` capability, so a server with no resources still
|
|
46
48
|
// answers `resources/list` with an empty array rather than `-32601`.
|
|
47
49
|
for (const resourceDef of this.resourceDefs) {
|
|
48
|
-
await this.registerResource(server, resourceDef, notifiers,
|
|
50
|
+
await this.registerResource(server, resourceDef, notifiers, capabilities);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
/** Throws at startup if a resource with the same name was already registered. */
|
|
@@ -56,7 +58,7 @@ export class ResourceRegistry {
|
|
|
56
58
|
}
|
|
57
59
|
this.registeredNames.add(name);
|
|
58
60
|
}
|
|
59
|
-
async registerResource(server, def, notifiers,
|
|
61
|
+
async registerResource(server, def, notifiers, capabilities) {
|
|
60
62
|
const resourceName = def.name ?? def.uriTemplate;
|
|
61
63
|
const registrationContext = requestContextService.createRequestContext({
|
|
62
64
|
operation: 'ResourceRegistry.registerResource',
|
|
@@ -65,7 +67,7 @@ export class ResourceRegistry {
|
|
|
65
67
|
logger.debug(`Registering resource: '${resourceName}'`, registrationContext);
|
|
66
68
|
this.assertUniqueName(resourceName);
|
|
67
69
|
await ErrorHandler.tryCatch(() => {
|
|
68
|
-
const handler = createResourceHandler(def, this.services, notifiers,
|
|
70
|
+
const handler = createResourceHandler(def, this.services, notifiers, capabilities);
|
|
69
71
|
const title = def.title ?? resourceName;
|
|
70
72
|
const mimeType = def.mimeType ?? 'application/json';
|
|
71
73
|
const metadata = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEL,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EACL,qBAAqB,GAGtB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,SAAS,uBAAuB,CAAC,WAAmB;IAClD,OAAO,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,OAAO,gBAAgB;IAKjB,YAAY;IACZ,QAAQ;IALlB,wEAAwE;IACvD,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAErD,YACU,YAAqC,EACrC,QAAyB;4BADzB,YAAY;wBACZ,QAAQ;IACf,CAAC;IAEJ
|
|
1
|
+
{"version":3,"file":"resource-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/resources/resource-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEL,gBAAgB,GAEjB,MAAM,8BAA8B,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tB,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,aAAa,YAAY,4BAA4B,EAAE,mBAAmB,CAAC,CAAC;QAC3F,CAAC,EACD;YACE,SAAS,EAAE,uBAAuB,YAAY,EAAE;YAChD,OAAO,EAAE,mBAAmB;YAC5B,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { InputRequiredResult, ReadResourceResult, ServerContext, Variables } from '@modelcontextprotocol/server';
|
|
7
7
|
import { type HandlerServices } from '../../handlerContext.js';
|
|
8
|
-
import { type
|
|
8
|
+
import { type ClientCapabilityView } from '../../inputRequired.js';
|
|
9
9
|
import type { NotifierSources } from '../../notifications.js';
|
|
10
10
|
import type { AnyResourceDefinition } from './resourceDefinition.js';
|
|
11
11
|
/** The factory's own contract, shared with the tool factory. */
|
|
@@ -30,7 +30,8 @@ export declare function defaultResponseFormatter(result: unknown, meta: {
|
|
|
30
30
|
* - Checks inline `auth` scopes if defined
|
|
31
31
|
* - Validates params via Zod schema
|
|
32
32
|
* - Formats response via `format` or JSON default
|
|
33
|
-
* - Catches errors and re-throws for the SDK
|
|
33
|
+
* - Catches errors and re-throws for the SDK, with the declared recovery filled
|
|
34
|
+
* (#579) and the read's request id added (#576)
|
|
34
35
|
*/
|
|
35
|
-
export declare function createResourceHandler(def: AnyResourceDefinition, services: HandlerServices, notifiers: NotifierSources,
|
|
36
|
+
export declare function createResourceHandler(def: AnyResourceDefinition, services: HandlerServices, notifiers: NotifierSources, capabilities?: ClientCapabilityView): (uri: URL, variables: Variables, ctx: ServerContext) => Promise<ReadResourceResult | InputRequiredResult>;
|
|
36
37
|
//# sourceMappingURL=resourceHandlerFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,SAAS,EACV,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"resourceHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,SAAS,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAWhG,gEAAgE;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBrE;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACnC,kBAAkB,CAAC,UAAU,CAAC,CAShC;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,eAAe,EAC1B,YAAY,CAAC,EAAE,oBAAoB,GAClC,CACD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,aAAa,KACf,OAAO,CAAC,kBAAkB,GAAG,mBAAmB,CAAC,CAgGrD"}
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* Constructs Context (with `uri`), checks inline auth, validates params, formats response.
|
|
4
4
|
* @module src/mcp-server/resources/utils/resourceHandlerFactory
|
|
5
5
|
*/
|
|
6
|
+
import { resolveDeclaredFailure } from '../../../core/context.js';
|
|
6
7
|
import { buildHandlerContext, handlerParentContext, resolveHandlerRequest, } from '../../handlerContext.js';
|
|
7
|
-
import { isInputRequiredSignal } from '../../inputRequired.js';
|
|
8
|
+
import { isInputRequiredSignal, sealThrown, } from '../../inputRequired.js';
|
|
8
9
|
import { parseOutputContract } from '../../outputContract.js';
|
|
9
10
|
import { withRequiredScopes } from '../../transports/auth/lib/authUtils.js';
|
|
10
|
-
import { McpError } from '../../../types-global/errors.js';
|
|
11
|
+
import { JsonRpcErrorCode, McpError } from '../../../types-global/errors.js';
|
|
11
12
|
import { asRequestCancelled, ErrorHandler } from '../../../utils/internal/error-handler/errorHandler.js';
|
|
12
13
|
import { measureResourceExecution } from '../../../utils/internal/performance.js';
|
|
13
14
|
import { requestContextService } from '../../../utils/internal/requestContext.js';
|
|
@@ -62,9 +63,10 @@ function observableResourceUri(uri) {
|
|
|
62
63
|
* - Checks inline `auth` scopes if defined
|
|
63
64
|
* - Validates params via Zod schema
|
|
64
65
|
* - Formats response via `format` or JSON default
|
|
65
|
-
* - Catches errors and re-throws for the SDK
|
|
66
|
+
* - Catches errors and re-throws for the SDK, with the declared recovery filled
|
|
67
|
+
* (#579) and the read's request id added (#576)
|
|
66
68
|
*/
|
|
67
|
-
export function createResourceHandler(def, services, notifiers,
|
|
69
|
+
export function createResourceHandler(def, services, notifiers, capabilities) {
|
|
68
70
|
const mimeType = def.mimeType ?? 'application/json';
|
|
69
71
|
const formatter = def.format ?? defaultResponseFormatter;
|
|
70
72
|
const resourceName = def.name ?? def.uriTemplate;
|
|
@@ -74,7 +76,7 @@ export function createResourceHandler(def, services, notifiers, inputGate) {
|
|
|
74
76
|
// The URI template already captures the named segments; anything else is
|
|
75
77
|
// query-string / caller-supplied and belongs in metrics, not logs.
|
|
76
78
|
const appContext = requestContextService.createRequestContext({
|
|
77
|
-
parentContext: handlerParentContext(
|
|
79
|
+
parentContext: handlerParentContext(serverContext),
|
|
78
80
|
operation: 'HandleResourceRead',
|
|
79
81
|
additionalContext: {
|
|
80
82
|
resourceName,
|
|
@@ -94,7 +96,7 @@ export function createResourceHandler(def, services, notifiers, inputGate) {
|
|
|
94
96
|
// outcome, so a failure in either is a failed read. Closing the span when
|
|
95
97
|
// the handler returned recorded those as successes (#346).
|
|
96
98
|
return await measureResourceExecution(async (spanContext, recordOutput) => {
|
|
97
|
-
const ctx = buildHandlerContext(request, services, spanContext, def.errors,
|
|
99
|
+
const ctx = buildHandlerContext(request, services, spanContext, def.errors, capabilities, uri);
|
|
98
100
|
try {
|
|
99
101
|
// Handler may return sync or async.
|
|
100
102
|
const handlerResult = await def.handler(validatedParams, ctx);
|
|
@@ -115,8 +117,10 @@ export function createResourceHandler(def, services, notifiers, inputGate) {
|
|
|
115
117
|
catch (error) {
|
|
116
118
|
// Inside the measurement on purpose: the completion log's
|
|
117
119
|
// `metrics.errorCode` and the span's error-code attribute are
|
|
118
|
-
// derived from what leaves this callback (#421).
|
|
119
|
-
|
|
120
|
+
// derived from what leaves this callback (#421). An input-required
|
|
121
|
+
// signal leaves with its `requestState` sealed when a key is
|
|
122
|
+
// configured, so a sealing failure is a failed read like any other.
|
|
123
|
+
throw asRequestCancelled(await sealThrown(error, services.requestState, serverContext), request.signal);
|
|
120
124
|
}
|
|
121
125
|
}, { ...appContext, resourceName }, { uri: resourceUri, mimeType });
|
|
122
126
|
}
|
|
@@ -128,13 +132,37 @@ export function createResourceHandler(def, services, notifiers, inputGate) {
|
|
|
128
132
|
// an `McpError` carrying the reason and hint (#379).
|
|
129
133
|
if (isInputRequiredSignal(error))
|
|
130
134
|
return error.result;
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
const { code, message, data } = ErrorHandler.classifyOnly(error);
|
|
136
|
-
throw new McpError(code, message, data, { cause: error });
|
|
135
|
+
// Classified without logging: the completion record carries the code.
|
|
136
|
+
const { failure } = resolveDeclaredFailure(def.errors, asMcpError(error));
|
|
137
|
+
throw withRequestId(failure, appContext.requestId);
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
140
|
}
|
|
141
|
+
/** The thrown value as an `McpError`, classified by {@link ErrorHandler.classifyOnly} when it is not one. */
|
|
142
|
+
function asMcpError(error) {
|
|
143
|
+
if (error instanceof McpError)
|
|
144
|
+
return error;
|
|
145
|
+
const { code, message, data } = ErrorHandler.classifyOnly(error);
|
|
146
|
+
return new McpError(code, message, data, { cause: error });
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The error the SDK serializes into the read's JSON-RPC `error`, carrying the
|
|
150
|
+
* read's `requestId` as `data.requestId` (#576) — the id its completion record
|
|
151
|
+
* logs — so a failure reported from the client can be matched to that record.
|
|
152
|
+
* Set after the thrown data, so the framework's value replaces a thrown one.
|
|
153
|
+
*
|
|
154
|
+
* A `-32602` whose `data` is exactly `{ uri }` passes through untouched: it is
|
|
155
|
+
* the spec's resource-not-found shape, which clients recognize by that exact
|
|
156
|
+
* `data`.
|
|
157
|
+
*/
|
|
158
|
+
function withRequestId(error, requestId) {
|
|
159
|
+
const { data } = error;
|
|
160
|
+
const isResourceNotFound = error.code === JsonRpcErrorCode.InvalidParams &&
|
|
161
|
+
data !== undefined &&
|
|
162
|
+
typeof data.uri === 'string' &&
|
|
163
|
+
Object.keys(data).length === 1;
|
|
164
|
+
if (isResourceNotFound)
|
|
165
|
+
return error;
|
|
166
|
+
return new McpError(error.code, error.message, { ...data, requestId }, { cause: error });
|
|
167
|
+
}
|
|
140
168
|
//# sourceMappingURL=resourceHandlerFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceHandlerFactory.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EACL,mBAAmB,EAEnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"resourceHandlerFactory.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,mBAAmB,EAEnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,qBAAqB,EACrB,UAAU,GACX,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAU3E,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;IACjF,OAAO,kBAAkB,KAAK,kBAAkB,IAAI,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAe,EAAE,QAAgB;IAC3D,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC5D,CAAC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AE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,aAAa,CAAC,KAAe,EAAE,SAAiB;IACvD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACvB,MAAM,kBAAkB,GACtB,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC,aAAa;QAC7C,IAAI,KAAK,SAAS;QAClB,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ;QAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACjC,IAAI,kBAAkB;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { type Implementation, McpServer, type ServerNotifier } from '@modelcontextprotocol/server';
|
|
13
13
|
import type { AppConfig } from '../config/index.js';
|
|
14
14
|
import type { CacheHints } from './cacheHints.js';
|
|
15
|
+
import { type RequestStateSealer } from './inputRequired.js';
|
|
15
16
|
import type { PromptRegistry } from './prompts/prompt-registration.js';
|
|
16
17
|
import type { ResourceRegistry } from './resources/resource-registration.js';
|
|
17
18
|
import type { ToolRegistry } from './tools/tool-registration.js';
|
|
@@ -57,6 +58,14 @@ export interface McpServerDeps {
|
|
|
57
58
|
*/
|
|
58
59
|
notifier?: ServerNotifier;
|
|
59
60
|
promptRegistry: PromptRegistry;
|
|
61
|
+
/**
|
|
62
|
+
* The process's `requestState` sealer, built once from
|
|
63
|
+
* `MCP_REQUEST_STATE_KEY`. Its `verify` becomes the instance's
|
|
64
|
+
* `requestState.verify`, so every echoed state is checked before a handler
|
|
65
|
+
* runs, on the 2025-era shim's rounds as on 2026-07-28 retries. Absent when
|
|
66
|
+
* no key is configured, and the SDK then receives no `requestState` option.
|
|
67
|
+
*/
|
|
68
|
+
requestState?: RequestStateSealer;
|
|
60
69
|
resourceRegistry: ResourceRegistry;
|
|
61
70
|
/**
|
|
62
71
|
* Human-readable display name forwarded to `new McpServer({ serverInfo })`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,SAAS,EAET,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,SAAS,EAET,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iDAAiD,CAAC;AAExF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAI5E,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,mEAAmE;IACnE,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAuFrF"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @module src/mcp-server/server
|
|
11
11
|
*/
|
|
12
12
|
import { McpServer, } from '@modelcontextprotocol/server';
|
|
13
|
-
import {
|
|
13
|
+
import { clientCapabilityView } from './inputRequired.js';
|
|
14
14
|
import { installResourceSubscriptions } from './resources/resourceSubscriptions.js';
|
|
15
15
|
import { logger } from '../utils/internal/logger.js';
|
|
16
16
|
import { requestContextService } from '../utils/internal/requestContext.js';
|
|
@@ -58,31 +58,32 @@ export async function createMcpServerInstance(deps) {
|
|
|
58
58
|
// `elicitation/create` round trips over the live session) on 2025-era
|
|
59
59
|
// ones, so handlers are written once.
|
|
60
60
|
inputRequired: { legacyShim: true },
|
|
61
|
+
...(deps.requestState && { requestState: { verify: deps.requestState.verify } }),
|
|
61
62
|
});
|
|
63
|
+
const era = deps.era ?? 'legacy';
|
|
62
64
|
// The `resources/subscribe` registry is a 2025-era mechanism: the method
|
|
63
65
|
// does not exist on 2026-07-28, where the client opts in through
|
|
64
66
|
// `subscriptions/listen` and the SDK filters delivery. Installing it on a
|
|
65
67
|
// modern instance would leave the registry permanently empty and silently
|
|
66
68
|
// drop every `ctx.notifyResourceUpdated(uri)` — the notifiers read `undefined`
|
|
67
69
|
// as "no subscription tracking on this connection" and emit unconditionally.
|
|
68
|
-
const subscriptions =
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
: undefined;
|
|
70
|
+
const subscriptions = era === 'legacy' ? installResourceSubscriptions(server) : undefined;
|
|
71
|
+
// What the client declared, resolved per request from the source this era
|
|
72
|
+
// has (#580): the `initialize` value on a 2025-era instance, the request's
|
|
73
|
+
// envelope on a modern one. One view per instance feeds
|
|
74
|
+
// `ctx.clientCapabilities`, the filter over `ctx.inputs` (#496), and — on
|
|
75
|
+
// the 2025-era arm only, where the SDK's shim refusal cannot be shaped into
|
|
76
|
+
// an error envelope (#379) — the gate `ctx.requestInput` runs.
|
|
77
|
+
const capabilities = clientCapabilityView(era, server);
|
|
77
78
|
try {
|
|
78
79
|
logger.debug('Registering all MCP capabilities via registries...', context);
|
|
79
80
|
// The bus reaches a modern instance only. Passing it to a legacy one would
|
|
80
81
|
// route `ctx.notify*` away from the live session that can actually deliver
|
|
81
82
|
// it — the 2025 era has no `subscriptions/listen` stream to publish to.
|
|
82
|
-
const bus =
|
|
83
|
+
const bus = era === 'modern' ? deps.notifier : undefined;
|
|
83
84
|
await Promise.all([
|
|
84
|
-
deps.toolRegistry.registerAll(server, subscriptions, bus,
|
|
85
|
-
deps.resourceRegistry.registerAll(server, subscriptions, bus,
|
|
85
|
+
deps.toolRegistry.registerAll(server, subscriptions, bus, capabilities),
|
|
86
|
+
deps.resourceRegistry.registerAll(server, subscriptions, bus, capabilities),
|
|
86
87
|
deps.promptRegistry.registerAll(server),
|
|
87
88
|
]);
|
|
88
89
|
logger.debug('All MCP capabilities registered successfully', context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,SAAS,GAGV,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp-server/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAEL,SAAS,GAGV,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,oBAAoB,EAA2B,MAAM,+BAA+B,CAAC;AAG9F,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAmE3E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,IAAmB;IAC/D,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;QACzD,SAAS,EAAE,yBAAyB;KACrC,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,OAAO,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;QAC/B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;QACrC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAA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@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module src/mcp-server/tools/tool-registration
|
|
4
4
|
*/
|
|
5
5
|
import type { McpServer, ServerNotifier } from '@modelcontextprotocol/server';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ClientCapabilityView } from '../inputRequired.js';
|
|
7
7
|
import type { ResourceSubscriptions } from '../notifications.js';
|
|
8
8
|
import type { AnyToolDefinition } from './utils/toolDefinition.js';
|
|
9
9
|
import { type HandlerServices } from './utils/toolHandlerFactory.js';
|
|
@@ -20,8 +20,12 @@ export declare class ToolRegistry {
|
|
|
20
20
|
/** Tracks registered tool names to detect duplicates at startup. */
|
|
21
21
|
private readonly registeredNames;
|
|
22
22
|
constructor(toolDefs: AnyToolDef[], services: HandlerServices);
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Registers all tool definitions with the provided McpServer instance.
|
|
25
|
+
* `capabilities` is the instance's view of what its client declared (#580),
|
|
26
|
+
* which every handler context resolves per request.
|
|
27
|
+
*/
|
|
28
|
+
registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier, capabilities?: ClientCapabilityView): Promise<void>;
|
|
25
29
|
/** Throws at startup if a tool with the same name was already registered. */
|
|
26
30
|
private assertUniqueName;
|
|
27
31
|
/** Registers a standard tool definition. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/tool-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAgB,MAAM,8BAA8B,CAAC;AAE5F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tool-registration.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/tool-registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAgB,MAAM,8BAA8B,CAAC;AAE5F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,gDAAgD,CAAC;AAMxD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAU3C,qBAAa,YAAY;IAKrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAL3B,oEAAoE;IACpE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD,YACmB,QAAQ,EAAE,UAAU,EAAE,EACtB,QAAQ,EAAE,eAAe,EACxC;IAEJ;;;;OAIG;IACU,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,EACpB,YAAY,CAAC,EAAE,oBAAoB,GAClC,OAAO,CAAC,IAAI,CAAC,CA8Cf;IAED,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;IAUxB,4CAA4C;YAC9B,YAAY;CAkD3B"}
|