@cyanheads/mcp-ts-core 0.13.3 → 0.13.5
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 +9 -7
- package/CLAUDE.md +9 -7
- package/README.md +1 -1
- package/changelog/0.13.x/0.13.4.md +65 -0
- package/changelog/0.13.x/0.13.5.md +41 -0
- package/changelog/template.md +7 -7
- package/dist/config/appRoot.d.ts.map +1 -1
- package/dist/config/appRoot.js +48 -16
- package/dist/config/appRoot.js.map +1 -1
- package/dist/core/app.d.ts +20 -0
- package/dist/core/app.d.ts.map +1 -1
- package/dist/core/app.js +1 -0
- package/dist/core/app.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/linter/rules/error-contract-rules.d.ts +65 -3
- package/dist/linter/rules/error-contract-rules.d.ts.map +1 -1
- package/dist/linter/rules/error-contract-rules.js +138 -3
- 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 +4 -2
- package/dist/linter/rules/resource-rules.js.map +1 -1
- package/dist/linter/rules/schema-rules.d.ts +19 -0
- package/dist/linter/rules/schema-rules.d.ts.map +1 -1
- package/dist/linter/rules/schema-rules.js +36 -0
- package/dist/linter/rules/schema-rules.js.map +1 -1
- package/dist/linter/rules/tool-rules.d.ts +17 -0
- package/dist/linter/rules/tool-rules.d.ts.map +1 -1
- package/dist/linter/rules/tool-rules.js +101 -3
- package/dist/linter/rules/tool-rules.js.map +1 -1
- package/dist/mcp-server/handlerContext.d.ts +11 -2
- package/dist/mcp-server/handlerContext.d.ts.map +1 -1
- package/dist/mcp-server/handlerContext.js +6 -4
- package/dist/mcp-server/handlerContext.js.map +1 -1
- package/dist/mcp-server/inputRequired.d.ts +35 -2
- package/dist/mcp-server/inputRequired.d.ts.map +1 -1
- package/dist/mcp-server/inputRequired.js +116 -2
- package/dist/mcp-server/inputRequired.js.map +1 -1
- package/dist/mcp-server/resources/resource-registration.d.ts +2 -1
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.js +4 -4
- package/dist/mcp-server/resources/resource-registration.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +2 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +5 -2
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
- package/dist/mcp-server/server.d.ts.map +1 -1
- package/dist/mcp-server/server.js +11 -2
- package/dist/mcp-server/server.js.map +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +2 -1
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/tool-registration.js +4 -4
- package/dist/mcp-server/tools/tool-registration.js.map +1 -1
- package/dist/mcp-server/tools/utils/inputPrevalidation.d.ts +114 -0
- package/dist/mcp-server/tools/utils/inputPrevalidation.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/inputPrevalidation.js +428 -0
- package/dist/mcp-server/tools/utils/inputPrevalidation.js.map +1 -0
- package/dist/mcp-server/tools/utils/strictenRecord.d.ts +42 -0
- package/dist/mcp-server/tools/utils/strictenRecord.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/strictenRecord.js +48 -0
- package/dist/mcp-server/tools/utils/strictenRecord.js.map +1 -0
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts +27 -0
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolDefinition.js +35 -6
- package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +33 -5
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +136 -20
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/services/canvas/core/CanvasInstance.d.ts +4 -1
- package/dist/services/canvas/core/CanvasInstance.d.ts.map +1 -1
- package/dist/services/canvas/core/CanvasInstance.js +5 -0
- package/dist/services/canvas/core/CanvasInstance.js.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.d.ts +52 -1
- package/dist/services/canvas/core/CanvasRegistry.d.ts.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.js +79 -3
- package/dist/services/canvas/core/CanvasRegistry.js.map +1 -1
- package/dist/services/canvas/core/sqlGate.d.ts +14 -1
- package/dist/services/canvas/core/sqlGate.d.ts.map +1 -1
- package/dist/services/canvas/core/sqlGate.js +69 -7
- package/dist/services/canvas/core/sqlGate.js.map +1 -1
- package/dist/services/canvas/index.d.ts +2 -2
- package/dist/services/canvas/index.d.ts.map +1 -1
- package/dist/services/canvas/index.js +2 -2
- package/dist/services/canvas/index.js.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts +20 -0
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js +75 -25
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js.map +1 -1
- package/dist/services/canvas/types.d.ts +6 -1
- package/dist/services/canvas/types.d.ts.map +1 -1
- package/dist/types-global/errors.d.ts +30 -0
- package/dist/types-global/errors.d.ts.map +1 -1
- package/dist/types-global/errors.js +4 -3
- package/dist/types-global/errors.js.map +1 -1
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.js +13 -3
- package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
- package/dist/utils/internal/error-handler/mappings.d.ts +14 -1
- package/dist/utils/internal/error-handler/mappings.d.ts.map +1 -1
- package/dist/utils/internal/error-handler/mappings.js +19 -1
- package/dist/utils/internal/error-handler/mappings.js.map +1 -1
- package/dist/utils/internal/error-handler/types.d.ts +12 -1
- package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
- package/dist/utils/internal/performance.d.ts.map +1 -1
- package/dist/utils/internal/performance.js +4 -1
- package/dist/utils/internal/performance.js.map +1 -1
- package/dist/utils/network/fetchWithTimeout.d.ts +24 -4
- package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
- package/dist/utils/network/fetchWithTimeout.js +10 -6
- package/dist/utils/network/fetchWithTimeout.js.map +1 -1
- package/dist/utils/network/httpError.d.ts +56 -6
- package/dist/utils/network/httpError.d.ts.map +1 -1
- package/dist/utils/network/httpError.js +56 -7
- package/dist/utils/network/httpError.js.map +1 -1
- package/dist/utils/network/pacer.d.ts +117 -0
- package/dist/utils/network/pacer.d.ts.map +1 -0
- package/dist/utils/network/pacer.js +304 -0
- package/dist/utils/network/pacer.js.map +1 -0
- package/dist/utils/network/retry.d.ts +119 -3
- package/dist/utils/network/retry.d.ts.map +1 -1
- package/dist/utils/network/retry.js +176 -35
- package/dist/utils/network/retry.js.map +1 -1
- package/dist/utils/security/rateLimiter.d.ts +19 -1
- package/dist/utils/security/rateLimiter.d.ts.map +1 -1
- package/dist/utils/security/rateLimiter.js +49 -1
- package/dist/utils/security/rateLimiter.js.map +1 -1
- package/dist/utils/telemetry/attributes.d.ts +27 -0
- package/dist/utils/telemetry/attributes.d.ts.map +1 -1
- package/dist/utils/telemetry/attributes.js +38 -0
- package/dist/utils/telemetry/attributes.js.map +1 -1
- package/framework-skills/add-tool/SKILL.md +49 -5
- package/framework-skills/api-canvas/SKILL.md +37 -16
- package/framework-skills/api-config/SKILL.md +4 -4
- package/framework-skills/api-context/SKILL.md +4 -2
- package/framework-skills/api-errors/SKILL.md +39 -7
- package/framework-skills/api-linter/SKILL.md +92 -5
- package/framework-skills/api-telemetry/SKILL.md +43 -4
- package/framework-skills/api-utils/SKILL.md +9 -5
- package/framework-skills/api-utils/references/security.md +2 -2
- package/framework-skills/design-mcp-server/SKILL.md +20 -3
- package/framework-skills/field-test/SKILL.md +4 -2
- package/framework-skills/git-wrapup/SKILL.md +87 -69
- package/framework-skills/release-and-publish/SKILL.md +5 -5
- package/framework-skills/release-pr-review/SKILL.md +5 -5
- package/framework-skills/report-issue-framework/SKILL.md +6 -35
- package/framework-skills/report-issue-local/SKILL.md +6 -36
- package/package.json +2 -2
- package/templates/.github/ISSUE_TEMPLATE/bug_report.yml +2 -2
- package/templates/.github/ISSUE_TEMPLATE/feature_request.yml +2 -2
- package/templates/AGENTS.md +1 -1
- package/templates/CLAUDE.md +1 -1
- package/templates/changelog/template.md +7 -7
|
@@ -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,EACL,mBAAmB,EAEnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAA0B,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAG9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,YA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,KAAK,CAAC,MAAM,CAAC;YAEtD,4EAA4E;YAC5E,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;gBAC9B,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YACjE,MAAM,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -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;AAE7D,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,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,6 +10,7 @@
|
|
|
10
10
|
* @module src/mcp-server/server
|
|
11
11
|
*/
|
|
12
12
|
import { McpServer, } from '@modelcontextprotocol/server';
|
|
13
|
+
import { createInputRequiredGate } from './inputRequired.js';
|
|
13
14
|
import { installResourceSubscriptions } from './resources/resourceSubscriptions.js';
|
|
14
15
|
import { logger } from '../utils/internal/logger.js';
|
|
15
16
|
import { requestContextService } from '../utils/internal/requestContext.js';
|
|
@@ -65,6 +66,14 @@ export async function createMcpServerInstance(deps) {
|
|
|
65
66
|
// drop every `ctx.notifyResourceUpdated(uri)` — the notifiers read `undefined`
|
|
66
67
|
// as "no subscription tracking on this connection" and emit unconditionally.
|
|
67
68
|
const subscriptions = (deps.era ?? 'legacy') === 'legacy' ? installResourceSubscriptions(server) : undefined;
|
|
69
|
+
// The capability gate on `ctx.requestInput(...)` is a 2025-era mechanism too:
|
|
70
|
+
// there the refusal comes from the SDK's legacy shim, above the handler
|
|
71
|
+
// callback, where a factory can no longer shape it into an error envelope
|
|
72
|
+
// (#379). A modern instance is gated by the SDK itself, before any result
|
|
73
|
+
// leaves, so it takes no gate.
|
|
74
|
+
const inputGate = (deps.era ?? 'legacy') === 'legacy'
|
|
75
|
+
? createInputRequiredGate(() => server.server.getClientCapabilities())
|
|
76
|
+
: undefined;
|
|
68
77
|
try {
|
|
69
78
|
logger.debug('Registering all MCP capabilities via registries...', context);
|
|
70
79
|
// The bus reaches a modern instance only. Passing it to a legacy one would
|
|
@@ -72,8 +81,8 @@ export async function createMcpServerInstance(deps) {
|
|
|
72
81
|
// it — the 2025 era has no `subscriptions/listen` stream to publish to.
|
|
73
82
|
const bus = (deps.era ?? 'legacy') === 'modern' ? deps.notifier : undefined;
|
|
74
83
|
await Promise.all([
|
|
75
|
-
deps.toolRegistry.registerAll(server, subscriptions, bus),
|
|
76
|
-
deps.resourceRegistry.registerAll(server, subscriptions, bus),
|
|
84
|
+
deps.toolRegistry.registerAll(server, subscriptions, bus, inputGate),
|
|
85
|
+
deps.resourceRegistry.registerAll(server, subscriptions, bus, inputGate),
|
|
77
86
|
deps.promptRegistry.registerAll(server),
|
|
78
87
|
]);
|
|
79
88
|
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;
|
|
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,EAA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C,SAAS,CAAC;QAE5E,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,SAAS,CAAC;YACpE,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,SAAS,CAAC;YACxE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC;SACxC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,8CAA8C,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CACV,qCAAqC,EACrC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EACnD,OAAO,CACR,CAAC;QACF,MAAM,GAAG,CAAC;IACZ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,6 +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 { InputRequiredGate } from '../inputRequired.js';
|
|
6
7
|
import type { ResourceSubscriptions } from '../notifications.js';
|
|
7
8
|
import type { AnyToolDefinition } from './utils/toolDefinition.js';
|
|
8
9
|
import { type HandlerServices } from './utils/toolHandlerFactory.js';
|
|
@@ -20,7 +21,7 @@ export declare class ToolRegistry {
|
|
|
20
21
|
private readonly registeredNames;
|
|
21
22
|
constructor(toolDefs: AnyToolDef[], services: HandlerServices);
|
|
22
23
|
/** Registers all tool definitions with the provided McpServer instance. */
|
|
23
|
-
registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier): Promise<void>;
|
|
24
|
+
registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier, inputGate?: InputRequiredGate): Promise<void>;
|
|
24
25
|
/** Throws at startup if a tool with the same name was already registered. */
|
|
25
26
|
private assertUniqueName;
|
|
26
27
|
/** 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,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,2EAA2E;IAC9D,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,
|
|
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,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,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,2EAA2E;IAC9D,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,EACpB,SAAS,CAAC,EAAE,iBAAiB,GAC5B,OAAO,CAAC,IAAI,CAAC,CA8Cf;IAED,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;IAUxB,4CAA4C;YAC9B,YAAY;CAkD3B"}
|
|
@@ -22,7 +22,7 @@ export class ToolRegistry {
|
|
|
22
22
|
this.services = services;
|
|
23
23
|
}
|
|
24
24
|
/** Registers all tool definitions with the provided McpServer instance. */
|
|
25
|
-
async registerAll(server, subscriptions, bus) {
|
|
25
|
+
async registerAll(server, subscriptions, bus, inputGate) {
|
|
26
26
|
// Reset per-server uniqueness tracking — registries are shared across
|
|
27
27
|
// per-request McpServer instances under HTTP serving.
|
|
28
28
|
this.registeredNames.clear();
|
|
@@ -57,7 +57,7 @@ export class ToolRegistry {
|
|
|
57
57
|
// `tools` capability, so a server with every tool disabled still answers
|
|
58
58
|
// `tools/list` with an empty array rather than `-32601`.
|
|
59
59
|
for (const toolDef of tools) {
|
|
60
|
-
await this.registerTool(server, toolDef, notifiers);
|
|
60
|
+
await this.registerTool(server, toolDef, notifiers, inputGate);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
/** Throws at startup if a tool with the same name was already registered. */
|
|
@@ -69,7 +69,7 @@ export class ToolRegistry {
|
|
|
69
69
|
this.registeredNames.add(name);
|
|
70
70
|
}
|
|
71
71
|
/** Registers a standard tool definition. */
|
|
72
|
-
async registerTool(server, tool, notifiers) {
|
|
72
|
+
async registerTool(server, tool, notifiers, inputGate) {
|
|
73
73
|
const registrationContext = requestContextService.createRequestContext({
|
|
74
74
|
operation: 'ToolRegistry.registerTool',
|
|
75
75
|
additionalContext: { toolName: tool.name },
|
|
@@ -77,7 +77,7 @@ export class ToolRegistry {
|
|
|
77
77
|
logger.debug(`Registering tool: '${tool.name}'`, registrationContext);
|
|
78
78
|
this.assertUniqueName(tool.name);
|
|
79
79
|
await ErrorHandler.tryCatch(() => {
|
|
80
|
-
const handler = createToolHandler(tool, this.services, notifiers);
|
|
80
|
+
const handler = createToolHandler(tool, this.services, notifiers, inputGate);
|
|
81
81
|
const title = tool.title ?? tool.annotations?.title ?? deriveTitleFromName(tool.name);
|
|
82
82
|
// Advertised verbatim; the same schema rejects the same arguments one
|
|
83
83
|
// layer down, where a rejection can carry the framework's structured
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/tool-registration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/tool-registration.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAGlB,MAAM,gDAAgD,CAAC;AACxD,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,EAA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AChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The ordered step raw `tools/call` arguments pass through before
|
|
3
|
+
* — and, for one stage, after — the `input` schema parses them.
|
|
4
|
+
*
|
|
5
|
+
* Strict inputs (#232) reject an unrecognized root key by name, which is right
|
|
6
|
+
* for a misspelling the caller can fix and wrong for the three cases collected
|
|
7
|
+
* here, where the arguments the model wrote are correct and something between
|
|
8
|
+
* the model and the schema is not:
|
|
9
|
+
*
|
|
10
|
+
* 1. **Client-added keys (#453)** — a placeholder, a call description, a call
|
|
11
|
+
* id, or an `arguments`-level `_meta` block the model never wrote and cannot
|
|
12
|
+
* remove. Dropped before parsing.
|
|
13
|
+
* 2. **Key aliases (#452)** — a declared `inputAliases` entry, or the same name
|
|
14
|
+
* in another case style (`max_results` for `maxResults`). Rewritten to the
|
|
15
|
+
* canonical key before parsing. A one-to-one mapping fixed ahead of time, not
|
|
16
|
+
* the nearest-key guess #232 rejected.
|
|
17
|
+
* 3. **Representation repair (#234)** — a JSON-stringified array where an array
|
|
18
|
+
* was declared. Applied only *after* the parse has already failed, and kept
|
|
19
|
+
* only when it flips the arguments from invalid to valid: the author's schema
|
|
20
|
+
* is the sole arbiter, so a repair can never touch input that was already
|
|
21
|
+
* valid.
|
|
22
|
+
*
|
|
23
|
+
* All three are on by default and each has a server-level switch on
|
|
24
|
+
* `createApp({ input })` / `createWorkerHandler({ input })`. None of them
|
|
25
|
+
* changes what `tools/list` advertises, and none appears in a response: a drop,
|
|
26
|
+
* a rewrite, and a repair each emit one debug log and one counter increment
|
|
27
|
+
* instead.
|
|
28
|
+
*
|
|
29
|
+
* The split between the two is deliberate. Counter attributes are bounded and
|
|
30
|
+
* author- or framework-defined — the ignore-list entry that matched, the
|
|
31
|
+
* declared key a rewrite resolved to — because a metric label carrying the
|
|
32
|
+
* caller's own key text mints a permanent time series per spelling a client
|
|
33
|
+
* invents (#114). The raw key and alias go to the debug log, which is where an
|
|
34
|
+
* operator looks when a counter shows a new client artifact and where
|
|
35
|
+
* cardinality costs nothing.
|
|
36
|
+
*
|
|
37
|
+
* @module src/mcp-server/tools/utils/inputPrevalidation
|
|
38
|
+
*/
|
|
39
|
+
import { type RequestContext } from '../../../utils/internal/requestContext.js';
|
|
40
|
+
import type { AnyToolDefinition } from './toolDefinition.js';
|
|
41
|
+
/**
|
|
42
|
+
* Server-level switches for the pre-validation step, set once via
|
|
43
|
+
* `createApp({ input })`. Every stage is on with no configuration; an entry
|
|
44
|
+
* here either extends a stage or turns it off for the whole server. There is no
|
|
45
|
+
* per-tool switch — a definition's only say is the `inputAliases` it declares.
|
|
46
|
+
*/
|
|
47
|
+
export interface InputHandlingOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Rewrite an undeclared root key whose case-folded form (`-`/`_` stripped,
|
|
50
|
+
* lowercased) matches exactly one declared key. `false` leaves declared
|
|
51
|
+
* `inputAliases` working and restores rejection for undeclared variants.
|
|
52
|
+
* Default `true`.
|
|
53
|
+
*/
|
|
54
|
+
caseStyleAliases?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Retry a failed parse once against repaired argument *values* — a
|
|
57
|
+
* JSON-stringified array parsed back into an array. `false` restores the
|
|
58
|
+
* single-parse behavior exactly. Default `true`.
|
|
59
|
+
*/
|
|
60
|
+
coerce?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Additional root keys to drop when the tool does not declare them, on top of
|
|
63
|
+
* the built-in client artifacts (`_meta`, `tool_call_description`,
|
|
64
|
+
* `toolCallId`). `false` disables the stage, so every undeclared key is
|
|
65
|
+
* rejected by name as it was before. Default: the built-in list only.
|
|
66
|
+
*/
|
|
67
|
+
ignoreKeys?: readonly string[] | false;
|
|
68
|
+
}
|
|
69
|
+
/** One increment per repaired call, not per repaired value. */
|
|
70
|
+
export declare function countCoerced(toolName: string, context: RequestContext | undefined): void;
|
|
71
|
+
/**
|
|
72
|
+
* `Max-Results`, `max_results`, and `maxResults` all fold to `maxresults`.
|
|
73
|
+
*
|
|
74
|
+
* Exported so `lint:mcp` decides alias ambiguity by the same fold the rewrite
|
|
75
|
+
* uses — a rule computing its own would pass a definition the runtime declines
|
|
76
|
+
* to rewrite, or fail one it rewrites happily.
|
|
77
|
+
*/
|
|
78
|
+
export declare function foldArgumentKey(key: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Runs the pre-parse half of the step — drop client-added keys, then rewrite
|
|
81
|
+
* key aliases — and returns the arguments to parse.
|
|
82
|
+
*
|
|
83
|
+
* Returns the caller's own object unchanged when nothing applied, so the common
|
|
84
|
+
* path allocates nothing. Non-object arguments are handed straight back: the
|
|
85
|
+
* schema's own rejection already says what arrived.
|
|
86
|
+
*/
|
|
87
|
+
export declare function prevalidateToolArguments(def: AnyToolDefinition, args: unknown, options: InputHandlingOptions | undefined, context: RequestContext | undefined): unknown;
|
|
88
|
+
/**
|
|
89
|
+
* Parses back a string whose trimmed form is a JSON array, at each path the
|
|
90
|
+
* failed parse's issues named. Keys are never added, dropped, or renamed, and
|
|
91
|
+
* a value no issue points at is returned untouched.
|
|
92
|
+
*
|
|
93
|
+
* **Targeted, not a full walk.** A rejection names exactly the values the schema
|
|
94
|
+
* could not accept, and repairing anything else loses repairs that should have
|
|
95
|
+
* succeeded: one call carrying a stringified array for an array field *and* a
|
|
96
|
+
* free-text field legitimately holding `"[1,2]"` would have both rewritten, the
|
|
97
|
+
* re-parse would fail on the free-text field, and the whole call would be
|
|
98
|
+
* rejected over a value that was valid all along. An `invalid_union` issue's
|
|
99
|
+
* outer path counts like any other — that is the value the union rejected.
|
|
100
|
+
*
|
|
101
|
+
* `JSON.parse` is the exact inverse of the `JSON.stringify` that produced the
|
|
102
|
+
* value, so this undoes a known encoding rather than matching a nearest
|
|
103
|
+
* candidate — the distinction that makes it safe where nearest-key matching is
|
|
104
|
+
* not (#232). Safety does not rest on that alone: {@link parseToolArguments}
|
|
105
|
+
* runs this only after validation has already failed and keeps the result only
|
|
106
|
+
* when it then passes.
|
|
107
|
+
*
|
|
108
|
+
* Returns the argument itself when nothing was repairable, which is the signal
|
|
109
|
+
* the caller uses to skip the second parse.
|
|
110
|
+
*/
|
|
111
|
+
export declare function repairRepresentations(args: unknown, issues: ReadonlyArray<{
|
|
112
|
+
readonly path: ReadonlyArray<PropertyKey>;
|
|
113
|
+
}>): unknown;
|
|
114
|
+
//# sourceMappingURL=inputPrevalidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputPrevalidation.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/inputPrevalidation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAMH,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,oCAAoC,CAAC;AAW5C,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,qBAAqB,CAAC;AAM9E;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;CACxC;AAoED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,CAexF;AA8CD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAyND;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,EAAE,cAAc,GAAG,SAAS,GAClC,OAAO,CAcT;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,aAAa,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC,GACnE,OAAO,CAST"}
|