@cyanheads/mcp-ts-core 0.12.7 → 0.12.8
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 +8 -3
- package/CLAUDE.md +8 -3
- package/README.md +11 -4
- package/changelog/0.12.x/0.12.8.md +55 -0
- package/dist/config/index.d.ts +3 -34
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +4 -26
- package/dist/config/index.js.map +1 -1
- package/dist/core/app.d.ts +0 -8
- package/dist/core/app.d.ts.map +1 -1
- package/dist/core/app.js +0 -7
- package/dist/core/app.js.map +1 -1
- package/dist/core/serverManifest.d.ts +0 -7
- package/dist/core/serverManifest.d.ts.map +1 -1
- package/dist/core/serverManifest.js +1 -13
- package/dist/core/serverManifest.js.map +1 -1
- package/dist/linter/rules/enrichment-rules.js +2 -2
- package/dist/linter/rules/enrichment-rules.js.map +1 -1
- package/dist/linter/rules/format-parity-rules.d.ts.map +1 -1
- package/dist/linter/rules/format-parity-rules.js +14 -36
- package/dist/linter/rules/format-parity-rules.js.map +1 -1
- package/dist/linter/rules/prompt-rules.d.ts +1 -1
- package/dist/linter/rules/prompt-rules.d.ts.map +1 -1
- package/dist/linter/rules/prompt-rules.js +2 -19
- package/dist/linter/rules/prompt-rules.js.map +1 -1
- package/dist/linter/rules/resource-rules.d.ts +1 -1
- package/dist/linter/rules/resource-rules.d.ts.map +1 -1
- package/dist/linter/rules/resource-rules.js +9 -39
- package/dist/linter/rules/resource-rules.js.map +1 -1
- package/dist/linter/rules/schema-rules.d.ts +22 -2
- package/dist/linter/rules/schema-rules.d.ts.map +1 -1
- package/dist/linter/rules/schema-rules.js +28 -5
- package/dist/linter/rules/schema-rules.js.map +1 -1
- package/dist/linter/rules/tool-rules.d.ts +1 -1
- package/dist/linter/rules/tool-rules.d.ts.map +1 -1
- package/dist/linter/rules/tool-rules.js +13 -41
- package/dist/linter/rules/tool-rules.js.map +1 -1
- package/dist/linter/validate.d.ts.map +1 -1
- package/dist/linter/validate.js +22 -42
- package/dist/linter/validate.js.map +1 -1
- package/dist/mcp-server/apps/appBuilders.d.ts.map +1 -1
- package/dist/mcp-server/apps/appBuilders.js +2 -16
- package/dist/mcp-server/apps/appBuilders.js.map +1 -1
- package/dist/mcp-server/handlerContext.d.ts +66 -0
- package/dist/mcp-server/handlerContext.d.ts.map +1 -0
- package/dist/mcp-server/handlerContext.js +71 -0
- package/dist/mcp-server/handlerContext.js.map +1 -0
- package/dist/mcp-server/inputRequired.d.ts +7 -1
- package/dist/mcp-server/inputRequired.d.ts.map +1 -1
- package/dist/mcp-server/inputRequired.js +10 -3
- package/dist/mcp-server/inputRequired.js.map +1 -1
- package/dist/mcp-server/resources/resource-registration.d.ts +2 -2
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +14 -43
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +11 -50
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +5 -9
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/tool-registration.js +9 -11
- package/dist/mcp-server/tools/tool-registration.js.map +1 -1
- package/dist/mcp-server/tools/utils/schemaShape.d.ts +21 -0
- package/dist/mcp-server/tools/utils/schemaShape.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/schemaShape.js +8 -6
- package/dist/mcp-server/tools/utils/schemaShape.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +15 -43
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +31 -72
- 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 +2 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/handler.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/handler.js +2 -1
- package/dist/mcp-server/transports/http/landing-page/handler.js.map +1 -1
- package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/protectedResourceMetadata.js +2 -1
- package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -1
- package/dist/mcp-server/transports/http/publicOrigin.d.ts +11 -0
- package/dist/mcp-server/transports/http/publicOrigin.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/publicOrigin.js +13 -0
- package/dist/mcp-server/transports/http/publicOrigin.js.map +1 -0
- package/dist/mcp-server/transports/http/serverCard.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/serverCard.js +2 -1
- package/dist/mcp-server/transports/http/serverCard.js.map +1 -1
- package/dist/mcp-server/transports/http/sessionIdUtils.d.ts +4 -0
- package/dist/mcp-server/transports/http/sessionIdUtils.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/sessionIdUtils.js +3 -13
- package/dist/mcp-server/transports/http/sessionIdUtils.js.map +1 -1
- package/dist/mcp-server/transports/manager.d.ts +0 -3
- package/dist/mcp-server/transports/manager.d.ts.map +1 -1
- package/dist/mcp-server/transports/manager.js +0 -7
- package/dist/mcp-server/transports/manager.js.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.d.ts +14 -0
- package/dist/services/canvas/core/CanvasRegistry.d.ts.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.js +3 -2
- package/dist/services/canvas/core/CanvasRegistry.js.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts +16 -0
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js +78 -103
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js.map +1 -1
- package/dist/services/graph/core/GraphService.d.ts +3 -3
- package/dist/services/graph/core/GraphService.js +3 -3
- package/dist/services/graph/types.d.ts +2 -79
- package/dist/services/graph/types.d.ts.map +1 -1
- package/dist/services/graph/types.js +2 -2
- package/dist/services/index.d.ts +1 -2
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +0 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/mirror/sqlite/handle.d.ts.map +1 -1
- package/dist/services/mirror/sqlite/handle.js +22 -36
- package/dist/services/mirror/sqlite/handle.js.map +1 -1
- package/dist/services/speech/core/ISpeechProvider.d.ts +0 -24
- package/dist/services/speech/core/ISpeechProvider.d.ts.map +1 -1
- package/dist/services/speech/core/ISpeechProvider.js +1 -28
- package/dist/services/speech/core/ISpeechProvider.js.map +1 -1
- package/dist/services/speech/core/SpeechService.d.ts.map +1 -1
- package/dist/services/speech/core/SpeechService.js +5 -8
- package/dist/services/speech/core/SpeechService.js.map +1 -1
- package/dist/services/speech/providers/elevenlabs.provider.d.ts.map +1 -1
- package/dist/services/speech/providers/elevenlabs.provider.js +1 -0
- package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -1
- package/dist/services/speech/types.d.ts +2 -19
- package/dist/services/speech/types.d.ts.map +1 -1
- package/dist/storage/core/providerHelpers.d.ts +52 -0
- package/dist/storage/core/providerHelpers.d.ts.map +1 -0
- package/dist/storage/core/providerHelpers.js +96 -0
- package/dist/storage/core/providerHelpers.js.map +1 -0
- package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.js +1 -4
- package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.js +4 -31
- package/dist/storage/providers/cloudflare/kvProvider.js.map +1 -1
- package/dist/storage/providers/cloudflare/r2Provider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/r2Provider.d.ts.map +1 -1
- package/dist/storage/providers/cloudflare/r2Provider.js +8 -48
- package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts.map +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.js +17 -86
- package/dist/storage/providers/fileSystem/fileSystemProvider.js.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.js +5 -38
- package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
- package/dist/storage/providers/supabase/supabaseProvider.d.ts.map +1 -1
- package/dist/storage/providers/supabase/supabaseProvider.js +1 -4
- package/dist/storage/providers/supabase/supabaseProvider.js.map +1 -1
- package/dist/testing/fuzz.d.ts.map +1 -1
- package/dist/testing/fuzz.js +17 -31
- package/dist/testing/fuzz.js.map +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +4 -26
- package/dist/testing/index.js.map +1 -1
- package/dist/utils/internal/error-handler/types.d.ts +0 -4
- package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
- package/dist/utils/internal/logger.d.ts.map +1 -1
- package/dist/utils/internal/logger.js +2 -16
- package/dist/utils/internal/logger.js.map +1 -1
- package/dist/utils/internal/performance.d.ts +8 -31
- package/dist/utils/internal/performance.d.ts.map +1 -1
- package/dist/utils/internal/performance.js +173 -295
- package/dist/utils/internal/performance.js.map +1 -1
- package/dist/utils/security/idGenerator.d.ts.map +1 -1
- package/dist/utils/security/idGenerator.js +24 -43
- package/dist/utils/security/idGenerator.js.map +1 -1
- package/dist/utils/security/sanitization.d.ts +0 -7
- package/dist/utils/security/sanitization.d.ts.map +1 -1
- package/dist/utils/security/sanitization.js +4 -31
- package/dist/utils/security/sanitization.js.map +1 -1
- package/dist/utils/security/sensitiveFields.d.ts +14 -0
- package/dist/utils/security/sensitiveFields.d.ts.map +1 -0
- package/dist/utils/security/sensitiveFields.js +31 -0
- package/dist/utils/security/sensitiveFields.js.map +1 -0
- package/dist/utils/telemetry/trace.d.ts +8 -10
- package/dist/utils/telemetry/trace.d.ts.map +1 -1
- package/dist/utils/telemetry/trace.js +19 -18
- package/dist/utils/telemetry/trace.js.map +1 -1
- package/dist/utils/types/guards.d.ts +0 -102
- package/dist/utils/types/guards.d.ts.map +1 -1
- package/dist/utils/types/guards.js +0 -114
- package/dist/utils/types/guards.js.map +1 -1
- package/package.json +6 -6
- package/skills/add-provider/SKILL.md +18 -4
- package/skills/api-config/SKILL.md +4 -18
- package/skills/api-services/SKILL.md +1 -1
- package/skills/api-services/references/speech.md +1 -2
- package/skills/api-telemetry/SKILL.md +2 -2
- package/skills/api-utils/SKILL.md +2 -2
- package/skills/code-simplifier/SKILL.md +47 -20
- package/skills/field-test/SKILL.md +93 -14
- package/skills/git-wrapup/SKILL.md +64 -27
- package/skills/orchestrations/SKILL.md +17 -6
- package/skills/orchestrations/workflows/field-test-fix.md +6 -4
- package/skills/orchestrations/workflows/fix-wrapup-release.md +6 -4
- package/skills/orchestrations/workflows/greenfield-build.md +2 -2
- package/skills/orchestrations/workflows/maintenance-release.md +4 -2
- package/skills/release-and-publish/SKILL.md +101 -23
- package/skills/release-pr-review/SKILL.md +147 -0
- package/templates/AGENTS.md +4 -2
- package/templates/CLAUDE.md +4 -2
- package/dist/mcp-server/transports/ITransport.d.ts +0 -15
- package/dist/mcp-server/transports/ITransport.d.ts.map +0 -1
- package/dist/mcp-server/transports/ITransport.js +0 -2
- package/dist/mcp-server/transports/ITransport.js.map +0 -1
- package/dist/services/llm/types.d.ts +0 -16
- package/dist/services/llm/types.d.ts.map +0 -1
- package/dist/services/llm/types.js +0 -9
- package/dist/services/llm/types.js.map +0 -1
- package/dist/utils/internal/health.d.ts +0 -60
- package/dist/utils/internal/health.d.ts.map +0 -1
- package/dist/utils/internal/health.js +0 -46
- package/dist/utils/internal/health.js.map +0 -1
|
@@ -61,15 +61,22 @@ export function createRequestInput() {
|
|
|
61
61
|
* schema to `accepted()` wherever the content matters.
|
|
62
62
|
*/
|
|
63
63
|
export function createContextInputs(mcpReq) {
|
|
64
|
-
|
|
64
|
+
return contextInputsFrom(mcpReq?.inputResponses, mcpReq?.droppedInputResponseKeys ?? [], () => mcpReq?.requestState());
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The `ctx.inputs` reader over an explicit set of responses — what
|
|
68
|
+
* {@link createContextInputs} builds from the SDK request, and what the test
|
|
69
|
+
* kit builds from seeded `inputResponses` / `requestState`.
|
|
70
|
+
*/
|
|
71
|
+
export function contextInputsFrom(responses, dropped, state) {
|
|
65
72
|
const accepted = ((key, schema) => schema === undefined
|
|
66
73
|
? acceptedContent(responses, key)
|
|
67
74
|
: acceptedContent(responses, key, schema));
|
|
68
75
|
return {
|
|
69
76
|
accepted,
|
|
70
|
-
dropped
|
|
77
|
+
dropped,
|
|
71
78
|
responses,
|
|
72
|
-
state
|
|
79
|
+
state,
|
|
73
80
|
view: (key) => inputResponse(responses, key),
|
|
74
81
|
};
|
|
75
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputRequired.js","sourceRoot":"","sources":["../../src/mcp-server/inputRequired.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,EAIf,aAAa,EACb,aAAa,GAGd,MAAM,8BAA8B,CAAC;AAItC;;;;;;;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;A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C,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAA2C;IAC7E,OAAO,iBAAiB,CACtB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,wBAAwB,IAAI,EAAE,EACtC,GAA8B,EAAE,CAAC,MAAM,EAAE,YAAY,EAAK,CAC3D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAgD,EAChD,OAAiB,EACjB,KAA6B;IAE7B,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAW,EAAE,MAAyB,EAAE,EAAE,CAC3D,MAAM,KAAK,SAAS;QAClB,CAAC,CAAC,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC;QACjC,CAAC,CAAC,eAAe,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAA8B,CAAC;IAE5E,OAAO;QACL,QAAQ;QACR,OAAO;QACP,SAAS;QACT,KAAK;QACL,IAAI,EAAE,CAAC,GAAW,EAAqB,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC;KACxE,CAAC;AACJ,CAAC"}
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import { type McpServer, type ServerNotifier } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { ResourceSubscriptions } from '../notifications.js';
|
|
7
7
|
import type { AnyResourceDefinition } from './utils/resourceDefinition.js';
|
|
8
|
-
import { type
|
|
8
|
+
import { type HandlerServices } from './utils/resourceHandlerFactory.js';
|
|
9
9
|
export declare class ResourceRegistry {
|
|
10
10
|
private resourceDefs;
|
|
11
11
|
private services;
|
|
12
12
|
/** Tracks registered resource names to detect duplicates at startup. */
|
|
13
13
|
private readonly registeredNames;
|
|
14
|
-
constructor(resourceDefs: AnyResourceDefinition[], services:
|
|
14
|
+
constructor(resourceDefs: AnyResourceDefinition[], services: HandlerServices);
|
|
15
15
|
/**
|
|
16
16
|
* Registers all resolved resource definitions with the provided McpServer instance.
|
|
17
17
|
*/
|
|
@@ -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,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAEL,KAAK,
|
|
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,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;;OAEG;IACU,WAAW,CACtB,MAAM,EAAE,SAAS,EACjB,aAAa,CAAC,EAAE,qBAAqB,EACrC,GAAG,CAAC,EAAE,cAAc,GACnB,OAAO,CAAC,IAAI,CAAC,CA4Bf;IAED,iFAAiF;IACjF,OAAO,CAAC,gBAAgB;YAUV,gBAAgB;CAwD/B"}
|
|
@@ -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;AAItC,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,
|
|
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;AAItC,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,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,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;gBACxD,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;aACvC,CAAC;YAEF,IAAI,uBAAuB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC7C,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE;oBACrD,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;iBAChD,CAAC,CAAC;gBAEH,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAC5E,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CACtB,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"}
|
|
@@ -3,51 +3,22 @@
|
|
|
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 type { InputRequiredResult, ReadResourceResult, ServerContext,
|
|
7
|
-
import { type
|
|
6
|
+
import type { InputRequiredResult, ReadResourceResult, ServerContext, Variables } from '@modelcontextprotocol/server';
|
|
7
|
+
import { type HandlerServices } from '../../handlerContext.js';
|
|
8
|
+
import type { NotifierSources } from '../../notifications.js';
|
|
8
9
|
import type { AnyResourceDefinition } from './resourceDefinition.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface ResourceHandlerFactoryServices {
|
|
13
|
-
/**
|
|
14
|
-
* When true, surface `ctx.sessionId` even in stateless HTTP mode (per-request
|
|
15
|
-
* generated token). Wired from `createApp({ context: { exposeStatelessSessionId } })`.
|
|
16
|
-
* Default false — `ctx.sessionId` is only set when the session has
|
|
17
|
-
* request-spanning lifetime (HTTP `stateful` / `auto` mode).
|
|
18
|
-
*/
|
|
19
|
-
exposeStatelessSessionId?: boolean;
|
|
20
|
-
logger: Logger;
|
|
21
|
-
storage: StorageService;
|
|
22
|
-
}
|
|
10
|
+
/** The factory's own contract, shared with the tool factory. */
|
|
11
|
+
export type { HandlerServices } from '../../handlerContext.js';
|
|
12
|
+
export type { NotifierSources } from '../../notifications.js';
|
|
23
13
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* Split from {@link ResourceHandlerFactoryServices} so each per-request
|
|
28
|
-
* McpServer gets its own notifier closures — preventing a concurrent
|
|
29
|
-
* registerAll() from overwriting an in-flight handler's notifier target.
|
|
30
|
-
*
|
|
31
|
-
* The resource handler factory picks a delivery path per era via
|
|
32
|
-
* {@link selectNotifiers}, and uses these closures only as a fallback for
|
|
33
|
-
* scopes with neither a bus nor a request sender (stdio, test harnesses).
|
|
14
|
+
* Default `resources/read` contents when a definition declares no `format`:
|
|
15
|
+
* a string result is passed through for text MIME types, anything else is
|
|
16
|
+
* pretty-printed JSON. Also the fallback `appResource()` mirrors UI meta into.
|
|
34
17
|
*/
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* on 2026-07-28 the client opts into notification types through its listen
|
|
40
|
-
* stream, and only what reaches the bus is filtered against that opt-in
|
|
41
|
-
* (#193).
|
|
42
|
-
*/
|
|
43
|
-
bus?: ServerNotifier;
|
|
44
|
-
notifyPromptListChanged?: () => void;
|
|
45
|
-
notifyResourceListChanged?: () => void;
|
|
46
|
-
notifyResourceUpdated?: (uri: string) => void;
|
|
47
|
-
notifyToolListChanged?: () => void;
|
|
48
|
-
/** Per-connection `resources/subscribe` registry (#354). Legacy era only. */
|
|
49
|
-
subscriptions?: ResourceSubscriptions;
|
|
50
|
-
}
|
|
18
|
+
export declare function defaultResponseFormatter(result: unknown, meta: {
|
|
19
|
+
uri: URL;
|
|
20
|
+
mimeType: string;
|
|
21
|
+
}): ReadResourceResult['contents'];
|
|
51
22
|
/**
|
|
52
23
|
* Creates an MCP resource read handler from a resource definition.
|
|
53
24
|
* The returned function is compatible with the MCP SDK's resource callback type.
|
|
@@ -60,5 +31,5 @@ export interface ResourceHandlerNotifiers {
|
|
|
60
31
|
* - Formats response via `format` or JSON default
|
|
61
32
|
* - Catches errors and re-throws for the SDK
|
|
62
33
|
*/
|
|
63
|
-
export declare function createResourceHandler(def: AnyResourceDefinition, services:
|
|
34
|
+
export declare function createResourceHandler(def: AnyResourceDefinition, services: HandlerServices, notifiers: NotifierSources): (uri: URL, variables: Variables, ctx: ServerContext) => Promise<ReadResourceResult | InputRequiredResult>;
|
|
64
35
|
//# 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,
|
|
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;AAEtC,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,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;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,eAAe,GACzB,CACD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,aAAa,KACf,OAAO,CAAC,kBAAkB,GAAG,mBAAmB,CAAC,CAsErD"}
|
|
@@ -3,12 +3,9 @@
|
|
|
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 {
|
|
7
|
-
import {
|
|
8
|
-
import { createContextInputs, createRequestInput, isInputRequiredSignal, } from '../../inputRequired.js';
|
|
9
|
-
import { selectNotifiers } from '../../notifications.js';
|
|
6
|
+
import { buildHandlerContext, handlerParentContext, resolveHandlerRequest, } from '../../handlerContext.js';
|
|
7
|
+
import { isInputRequiredSignal } from '../../inputRequired.js';
|
|
10
8
|
import { withRequiredScopes } from '../../transports/auth/lib/authUtils.js';
|
|
11
|
-
import { resolveSessionMode } from '../../types.js';
|
|
12
9
|
import { McpError } from '../../../types-global/errors.js';
|
|
13
10
|
import { ErrorHandler } from '../../../utils/internal/error-handler/errorHandler.js';
|
|
14
11
|
import { measureResourceExecution } from '../../../utils/internal/performance.js';
|
|
@@ -25,7 +22,12 @@ function formatResourceText(result, mimeType) {
|
|
|
25
22
|
? result
|
|
26
23
|
: JSON.stringify(result, null, 2);
|
|
27
24
|
}
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Default `resources/read` contents when a definition declares no `format`:
|
|
27
|
+
* a string result is passed through for text MIME types, anything else is
|
|
28
|
+
* pretty-printed JSON. Also the fallback `appResource()` mirrors UI meta into.
|
|
29
|
+
*/
|
|
30
|
+
export function defaultResponseFormatter(result, meta) {
|
|
29
31
|
const text = formatResourceText(result, meta.mimeType);
|
|
30
32
|
return [
|
|
31
33
|
{
|
|
@@ -66,33 +68,12 @@ export function createResourceHandler(def, services, notifiers) {
|
|
|
66
68
|
const formatter = def.format ?? defaultResponseFormatter;
|
|
67
69
|
const resourceName = def.name ?? def.uriTemplate;
|
|
68
70
|
return async (uri, variables, serverContext) => {
|
|
69
|
-
const
|
|
70
|
-
const signal = mcpReq?.signal ?? new AbortController().signal;
|
|
71
|
-
const effectiveNotifiers = selectNotifiers(notifiers, mcpReq);
|
|
72
|
-
const sdkSessionId = typeof serverContext?.sessionId === 'string' ? serverContext.sessionId : undefined;
|
|
73
|
-
// Surface sessionId on `Context` only when it has request-spanning
|
|
74
|
-
// lifetime — stateful HTTP (or `auto`, which resolves to stateful for
|
|
75
|
-
// HTTP). In stateless mode the SDK still hands us a per-request token;
|
|
76
|
-
// pass it through only when the consumer opted in via
|
|
77
|
-
// `createApp({ context: { exposeStatelessSessionId: true } })`. Stdio
|
|
78
|
-
// gives no sessionId at the SDK layer, so the gate is moot there.
|
|
79
|
-
const isStatefulMode = resolveSessionMode(config.mcpSessionMode) === 'stateful';
|
|
80
|
-
const handlerSessionId = sdkSessionId && (isStatefulMode || services.exposeStatelessSessionId === true)
|
|
81
|
-
? sdkSessionId
|
|
82
|
-
: undefined;
|
|
71
|
+
const request = resolveHandlerRequest(serverContext, services, notifiers);
|
|
83
72
|
const resourceUri = observableResourceUri(uri);
|
|
84
|
-
// Raw `inputParams` is intentionally excluded from the context — it flows
|
|
85
|
-
// into the completion log via context spread and can contain caller data.
|
|
86
73
|
// The URI template already captures the named segments; anything else is
|
|
87
74
|
// query-string / caller-supplied and belongs in metrics, not logs.
|
|
88
|
-
// Log correlation always uses the raw SDK sessionId — useful even in
|
|
89
|
-
// stateless mode for tracing the SDK's per-request token through events.
|
|
90
|
-
const requestId = mcpReq?.id;
|
|
91
75
|
const appContext = requestContextService.createRequestContext({
|
|
92
|
-
parentContext:
|
|
93
|
-
...(typeof requestId === 'string' ? { requestId } : {}),
|
|
94
|
-
...(sdkSessionId ? { sessionId: sdkSessionId } : {}),
|
|
95
|
-
},
|
|
76
|
+
parentContext: handlerParentContext(request),
|
|
96
77
|
operation: 'HandleResourceRead',
|
|
97
78
|
additionalContext: {
|
|
98
79
|
resourceName,
|
|
@@ -111,28 +92,8 @@ export function createResourceHandler(def, services, notifiers) {
|
|
|
111
92
|
// output-schema validation and `format()` decide the client-visible
|
|
112
93
|
// outcome, so a failure in either is a failed read. Closing the span when
|
|
113
94
|
// the handler returned recorded those as successes (#346).
|
|
114
|
-
//
|
|
115
|
-
// The context is built from inside the execution span so `ctx.traceId` /
|
|
116
|
-
// `ctx.spanId` — and the child logger built from them — name the
|
|
117
|
-
// `resource_read:*` span the handler runs in rather than the enclosing
|
|
118
|
-
// request span (#296). `attachTypedFail` adds `ctx.fail` when the
|
|
119
|
-
// definition declares an error contract; otherwise no-op.
|
|
120
95
|
return await measureResourceExecution(async (spanContext, recordOutput) => {
|
|
121
|
-
const ctx =
|
|
122
|
-
appContext: spanContext,
|
|
123
|
-
logger: services.logger,
|
|
124
|
-
storage: services.storage,
|
|
125
|
-
signal,
|
|
126
|
-
sessionId: handlerSessionId,
|
|
127
|
-
inputs: createContextInputs(mcpReq),
|
|
128
|
-
requestInput: createRequestInput(),
|
|
129
|
-
...(mcpReq?.log && { wireLog: mcpReq.log }),
|
|
130
|
-
notifyPromptListChanged: effectiveNotifiers.notifyPromptListChanged,
|
|
131
|
-
notifyResourceListChanged: effectiveNotifiers.notifyResourceListChanged,
|
|
132
|
-
notifyResourceUpdated: effectiveNotifiers.notifyResourceUpdated,
|
|
133
|
-
notifyToolListChanged: effectiveNotifiers.notifyToolListChanged,
|
|
134
|
-
uri,
|
|
135
|
-
}), def.errors);
|
|
96
|
+
const ctx = buildHandlerContext(request, services, spanContext, def.errors, uri);
|
|
136
97
|
// Handler may return sync or async.
|
|
137
98
|
const handlerResult = await def.handler(validatedParams, ctx);
|
|
138
99
|
// The domain value is what `mcp.resource.output_bytes` measures — not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceHandlerFactory.js","sourceRoot":"","sources":["../../../../src/mcp-server/resources/utils/resourceHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
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,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAU3E,8EAA8E;AAC9E,oBAA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pServer, ServerNotifier } from '@modelcontextprotocol/server';
|
|
6
6
|
import type { ResourceSubscriptions } from '../notifications.js';
|
|
7
7
|
import type { AnyToolDefinition } from './utils/toolDefinition.js';
|
|
8
|
-
import { type
|
|
8
|
+
import { type HandlerServices } from './utils/toolHandlerFactory.js';
|
|
9
9
|
/**
|
|
10
10
|
* Union of all accepted tool definition shapes.
|
|
11
11
|
*
|
|
@@ -14,20 +14,16 @@ import { type HandlerFactoryServices } from './utils/toolHandlerFactory.js';
|
|
|
14
14
|
*/
|
|
15
15
|
export type AnyToolDef = AnyToolDefinition;
|
|
16
16
|
export declare class ToolRegistry {
|
|
17
|
-
private toolDefs;
|
|
18
|
-
private services
|
|
17
|
+
private readonly toolDefs;
|
|
18
|
+
private readonly services;
|
|
19
19
|
/** Tracks registered tool names to detect duplicates at startup. */
|
|
20
20
|
private readonly registeredNames;
|
|
21
|
-
constructor(toolDefs: AnyToolDef[], services
|
|
21
|
+
constructor(toolDefs: AnyToolDef[], services: HandlerServices);
|
|
22
22
|
/** Registers all tool definitions with the provided McpServer instance. */
|
|
23
23
|
registerAll(server: McpServer, subscriptions?: ResourceSubscriptions, bus?: ServerNotifier): Promise<void>;
|
|
24
24
|
/** Throws at startup if a tool with the same name was already registered. */
|
|
25
25
|
private assertUniqueName;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Registers a standard tool definition.
|
|
29
|
-
* Requires `services` to have been passed to the constructor for Context creation.
|
|
30
|
-
*/
|
|
26
|
+
/** Registers a standard tool definition. */
|
|
31
27
|
private registerTool;
|
|
32
28
|
}
|
|
33
29
|
//# sourceMappingURL=tool-registration.d.ts.map
|
|
@@ -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,
|
|
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,GACnB,OAAO,CAAC,IAAI,CAAC,CA8Cf;IAED,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;IAUxB,4CAA4C;YAC9B,YAAY;CAiD3B"}
|
|
@@ -5,6 +5,13 @@ import { JsonRpcErrorCode } from '../../types-global/errors.js';
|
|
|
5
5
|
import { ErrorHandler } from '../../utils/internal/error-handler/errorHandler.js';
|
|
6
6
|
import { logger } from '../../utils/internal/logger.js';
|
|
7
7
|
import { requestContextService } from '../../utils/internal/requestContext.js';
|
|
8
|
+
/** The advertised `title` when a definition declares none: snake_case or kebab-case → Title Case. */
|
|
9
|
+
function deriveTitleFromName(name) {
|
|
10
|
+
return name
|
|
11
|
+
.replace(/[_-]/g, ' ')
|
|
12
|
+
.replace(/\b\w/g, (ch) => ch.toUpperCase())
|
|
13
|
+
.trim();
|
|
14
|
+
}
|
|
8
15
|
export class ToolRegistry {
|
|
9
16
|
toolDefs;
|
|
10
17
|
services;
|
|
@@ -61,13 +68,7 @@ export class ToolRegistry {
|
|
|
61
68
|
}
|
|
62
69
|
this.registeredNames.add(name);
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
return name.replace(/_/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase());
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Registers a standard tool definition.
|
|
69
|
-
* Requires `services` to have been passed to the constructor for Context creation.
|
|
70
|
-
*/
|
|
71
|
+
/** Registers a standard tool definition. */
|
|
71
72
|
async registerTool(server, tool, notifiers) {
|
|
72
73
|
const registrationContext = requestContextService.createRequestContext({
|
|
73
74
|
operation: 'ToolRegistry.registerTool',
|
|
@@ -76,11 +77,8 @@ export class ToolRegistry {
|
|
|
76
77
|
logger.debug(`Registering tool: '${tool.name}'`, registrationContext);
|
|
77
78
|
this.assertUniqueName(tool.name);
|
|
78
79
|
await ErrorHandler.tryCatch(() => {
|
|
79
|
-
if (!this.services) {
|
|
80
|
-
throw new Error(`Cannot register tool '${tool.name}': HandlerFactoryServices not provided to ToolRegistry`);
|
|
81
|
-
}
|
|
82
80
|
const handler = createToolHandler(tool, this.services, notifiers);
|
|
83
|
-
const title = tool.title ?? tool.annotations?.title ??
|
|
81
|
+
const title = tool.title ?? tool.annotations?.title ?? deriveTitleFromName(tool.name);
|
|
84
82
|
// Advertised verbatim; the same schema rejects the same arguments one
|
|
85
83
|
// layer down, where a rejection can carry the framework's structured
|
|
86
84
|
// error envelope (#377). The SDK reads it through `~standard` like any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/tool-registration.ts"],"names":[],"mappings":"AAOA,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,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAU3E,MAAM,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../src/mcp-server/tools/tool-registration.ts"],"names":[],"mappings":"AAOA,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,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAU3E,qGAAqG;AACrG,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,IAAI;SACR,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;SAC1C,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,OAAO,YAAY;IAKJ,QAAQ;IACR,QAAQ;IAL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AAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEtF,sEAAsE;YACtE,qEAAqE;YACrE,uEAAuE;YACvE,yDAAyD;YACzD,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAiC,CAAC;YAErF,sFAAsF;YACtF,MAAM,CAAC,YAAY,CACjB,IAAI,CAAC,IAAI,EACT;gBACE,KAAK;gBACL,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,WAAW;gBACX,YAAY,EAAE,sBAAsB,CAAC,IAAI,CAAC;gBAC1C,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC1D,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;aACzC,EACD,OAA0C,CAC3C,CAAC;YAEF,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,4BAA4B,EAAE,mBAAmB,CAAC,CAAC;QACpF,CAAC,EACD;YACE,SAAS,EAAE,mBAAmB,IAAI,CAAC,IAAI,EAAE;YACzC,OAAO,EAAE,mBAAmB;YAC5B,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;YAChD,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -7,6 +7,27 @@
|
|
|
7
7
|
* @module src/mcp-server/tools/utils/schemaShape
|
|
8
8
|
*/
|
|
9
9
|
import type { ZodDiscriminatedUnion, ZodObject, ZodRawShape } from 'zod';
|
|
10
|
+
/**
|
|
11
|
+
* The Zod 4 definition fields the framework reads off a schema without going
|
|
12
|
+
* through the class API: the `type` tag every schema carries, plus the
|
|
13
|
+
* per-type payload (`shape`, `options`, `element`, …). Everything is optional
|
|
14
|
+
* because the linter also sees partial and hostile objects.
|
|
15
|
+
*/
|
|
16
|
+
export interface ZodDef {
|
|
17
|
+
checks?: unknown[];
|
|
18
|
+
discriminator?: unknown;
|
|
19
|
+
element?: unknown;
|
|
20
|
+
entries?: Record<string, unknown>;
|
|
21
|
+
innerType?: unknown;
|
|
22
|
+
items?: unknown[];
|
|
23
|
+
options?: unknown[];
|
|
24
|
+
shape?: Record<string, unknown>;
|
|
25
|
+
type?: string;
|
|
26
|
+
values?: unknown[];
|
|
27
|
+
valueType?: unknown;
|
|
28
|
+
}
|
|
29
|
+
/** Reads `_zod.def` from any value; `undefined` when it is not a Zod 4 schema. */
|
|
30
|
+
export declare function zodDef(value: unknown): ZodDef | undefined;
|
|
10
31
|
/** True when `value` is a `z.object()`. */
|
|
11
32
|
export declare function isZodObjectSchema(value: unknown): value is ZodObject<ZodRawShape>;
|
|
12
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaShape.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/schemaShape.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemaShape.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/schemaShape.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,kFAAkF;AAClF,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGzD;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,WAAW,CAAC,CAEjF;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,qBAAqB,CAAC,SAAS,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,SAAS,CAAC,WAAW,CAAC,EAAE,CAQhF"}
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
* server manifest, and the linter agree on what a union root is.
|
|
7
7
|
* @module src/mcp-server/tools/utils/schemaShape
|
|
8
8
|
*/
|
|
9
|
+
/** Reads `_zod.def` from any value; `undefined` when it is not a Zod 4 schema. */
|
|
10
|
+
export function zodDef(value) {
|
|
11
|
+
if (!value || typeof value !== 'object')
|
|
12
|
+
return undefined;
|
|
13
|
+
return value._zod?.def;
|
|
14
|
+
}
|
|
9
15
|
/** True when `value` is a `z.object()`. */
|
|
10
16
|
export function isZodObjectSchema(value) {
|
|
11
|
-
|
|
12
|
-
return false;
|
|
13
|
-
return value._zod?.def?.type === 'object';
|
|
17
|
+
return zodDef(value)?.type === 'object';
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* True when `value` is a `z.discriminatedUnion()`.
|
|
@@ -21,9 +25,7 @@ export function isZodObjectSchema(value) {
|
|
|
21
25
|
* choose a branch by, and every variant's `required` list would apply at once.
|
|
22
26
|
*/
|
|
23
27
|
export function isDiscriminatedUnionSchema(value) {
|
|
24
|
-
|
|
25
|
-
return false;
|
|
26
|
-
const def = value._zod?.def;
|
|
28
|
+
const def = zodDef(value);
|
|
27
29
|
return def?.type === 'union' && typeof def.discriminator === 'string';
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaShape.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/schemaShape.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"schemaShape.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/schemaShape.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH,kFAAkF;AAClF,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,OAAQ,KAAqC,CAAC,IAAI,EAAE,GAAG,CAAC;AAC1D,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,QAAQ,CAAC;AAC1C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAEd,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,OAAO,GAAG,EAAE,IAAI,KAAK,OAAO,IAAI,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,MAAM,OAAO,GAAI,MAAgC,CAAC,OAAO,CAAC;QAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAC3B,CAAC,CAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA8B;YACjE,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;IACD,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -3,55 +3,27 @@
|
|
|
3
3
|
* Constructs Context, checks inline auth, measures execution, formats response.
|
|
4
4
|
* @module src/mcp-server/tools/utils/toolHandlerFactory
|
|
5
5
|
*/
|
|
6
|
-
import type { CallToolResult, ContentBlock, InputRequiredResult, ServerContext
|
|
6
|
+
import type { CallToolResult, ContentBlock, InputRequiredResult, ServerContext } from '@modelcontextprotocol/server';
|
|
7
7
|
import { ZodError, type ZodObject, type ZodRawShape } from 'zod';
|
|
8
8
|
import type { Context } from '../../../core/context.js';
|
|
9
|
-
import { type
|
|
10
|
-
import type {
|
|
9
|
+
import { type HandlerServices } from '../../handlerContext.js';
|
|
10
|
+
import type { NotifierSources } from '../../notifications.js';
|
|
11
11
|
import { JsonRpcErrorCode } from '../../../types-global/errors.js';
|
|
12
|
-
import type { Logger } from '../../../utils/internal/logger.js';
|
|
13
12
|
import type { AnyToolDefinition } from './toolDefinition.js';
|
|
14
|
-
/**
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
* When true, surface `ctx.sessionId` even in stateless HTTP mode (per-request
|
|
18
|
-
* generated token). Wired from `createApp({ context: { exposeStatelessSessionId } })`.
|
|
19
|
-
* Default false — `ctx.sessionId` is only set when the session has
|
|
20
|
-
* request-spanning lifetime (HTTP `stateful` / `auto` mode).
|
|
21
|
-
*/
|
|
22
|
-
exposeStatelessSessionId?: boolean;
|
|
23
|
-
logger: Logger;
|
|
24
|
-
storage: StorageService;
|
|
25
|
-
}
|
|
13
|
+
/** The factory's own contract, shared with the resource factory. */
|
|
14
|
+
export type { HandlerServices } from '../../handlerContext.js';
|
|
15
|
+
export type { NotifierSources } from '../../notifications.js';
|
|
26
16
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
17
|
+
* Renders `content[]` for a validated tool result: `format()` (or the JSON
|
|
18
|
+
* default) over the domain payload, with any blocks collected via
|
|
19
|
+
* `ctx.content` (image/audio bytes) prepended. Collected blocks ride
|
|
20
|
+
* `content[]` only — never `structuredContent` — so a handler can surface
|
|
21
|
+
* media for the model without the base64 duplicating into the typed output.
|
|
29
22
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* overwriting an in-flight handler's notifier target (and potentially
|
|
33
|
-
* notifying the wrong server).
|
|
34
|
-
*
|
|
35
|
-
* The handler factory picks a delivery path per era via
|
|
36
|
-
* {@link selectNotifiers}, and uses these closures only as a fallback for
|
|
37
|
-
* scopes with neither a bus nor a request sender (stdio, test harnesses).
|
|
23
|
+
* A formatter failure is isolated from handler failures so it classifies as
|
|
24
|
+
* an internal error, carrying the formatter's own error as `cause`.
|
|
38
25
|
*/
|
|
39
|
-
export
|
|
40
|
-
/**
|
|
41
|
-
* Publish facade for the modern era's `subscriptions/listen` bus, supplied
|
|
42
|
-
* only for `modern` instances. Takes precedence over the request-scoped path:
|
|
43
|
-
* on 2026-07-28 the client opts into notification types through its listen
|
|
44
|
-
* stream, and only what reaches the bus is filtered against that opt-in
|
|
45
|
-
* (#193).
|
|
46
|
-
*/
|
|
47
|
-
bus?: ServerNotifier;
|
|
48
|
-
notifyPromptListChanged?: () => void;
|
|
49
|
-
notifyResourceListChanged?: () => void;
|
|
50
|
-
notifyResourceUpdated?: (uri: string) => void;
|
|
51
|
-
notifyToolListChanged?: () => void;
|
|
52
|
-
/** Per-connection `resources/subscribe` registry (#354). Legacy era only. */
|
|
53
|
-
subscriptions?: ResourceSubscriptions;
|
|
54
|
-
}
|
|
26
|
+
export declare function renderToolContent(def: AnyToolDefinition, validatedOutput: Record<string, unknown>, ctx: Context): ContentBlock[];
|
|
55
27
|
/**
|
|
56
28
|
* Shapes a `CallToolResult` for a tool error response with parity across both
|
|
57
29
|
* surfaces clients forward to the agent:
|
|
@@ -153,5 +125,5 @@ export declare function buildToolSuccessResult(def: AnyToolDefinition, ctx: Cont
|
|
|
153
125
|
* - Formats response via `format` or JSON default
|
|
154
126
|
* - Catches errors and returns `isError: true`
|
|
155
127
|
*/
|
|
156
|
-
export declare function createToolHandler(def: AnyToolDefinition, services:
|
|
128
|
+
export declare function createToolHandler(def: AnyToolDefinition, services: HandlerServices, notifiers: NotifierSources): (input: Record<string, unknown>, ctx: ServerContext) => Promise<CallToolResult | InputRequiredResult>;
|
|
157
129
|
//# sourceMappingURL=toolHandlerFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,aAAa,
|
|
1
|
+
{"version":3,"file":"toolHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACd,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAmB,MAAM,KAAK,CAAC;AAElF,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAiB,gBAAgB,EAAY,MAAM,0BAA0B,CAAC;AAKrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAA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