@cyanheads/mcp-ts-core 0.11.5 → 0.12.1
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 +27 -23
- package/CLAUDE.md +27 -23
- package/README.md +10 -10
- package/biome.json +1 -1
- package/changelog/0.12.x/0.12.0.md +96 -0
- package/changelog/0.12.x/0.12.1.md +26 -0
- package/dist/cli/init.js +1 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/config/index.d.ts +9 -18
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +21 -28
- package/dist/config/index.js.map +1 -1
- package/dist/core/app.d.ts +27 -7
- package/dist/core/app.d.ts.map +1 -1
- package/dist/core/app.js +28 -28
- package/dist/core/app.js.map +1 -1
- package/dist/core/context.d.ts +90 -57
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +32 -33
- package/dist/core/context.js.map +1 -1
- package/dist/core/gcPressure.d.ts.map +1 -1
- package/dist/core/gcPressure.js +3 -4
- package/dist/core/gcPressure.js.map +1 -1
- package/dist/core/index.d.ts +6 -7
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +10 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/serverManifest.d.ts +6 -4
- package/dist/core/serverManifest.d.ts.map +1 -1
- package/dist/core/serverManifest.js +37 -14
- package/dist/core/serverManifest.js.map +1 -1
- package/dist/core/worker.d.ts.map +1 -1
- package/dist/core/worker.js +34 -37
- package/dist/core/worker.js.map +1 -1
- package/dist/linter/rules/enrichment-rules.d.ts.map +1 -1
- package/dist/linter/rules/enrichment-rules.js +5 -2
- package/dist/linter/rules/enrichment-rules.js.map +1 -1
- package/dist/linter/rules/portability-rules.d.ts +4 -2
- package/dist/linter/rules/portability-rules.d.ts.map +1 -1
- package/dist/linter/rules/portability-rules.js +33 -4
- package/dist/linter/rules/portability-rules.js.map +1 -1
- package/dist/linter/rules/schema-rules.d.ts +10 -3
- package/dist/linter/rules/schema-rules.d.ts.map +1 -1
- package/dist/linter/rules/schema-rules.js +52 -25
- package/dist/linter/rules/schema-rules.js.map +1 -1
- package/dist/linter/rules/tool-rules.d.ts.map +1 -1
- package/dist/linter/rules/tool-rules.js +5 -2
- package/dist/linter/rules/tool-rules.js.map +1 -1
- package/dist/linter/types.d.ts +2 -1
- package/dist/linter/types.d.ts.map +1 -1
- package/dist/logs/combined.log +10 -22
- package/dist/logs/error.log +6 -18
- package/dist/mcp-server/inputRequired.d.ts +52 -0
- package/dist/mcp-server/inputRequired.d.ts.map +1 -0
- package/dist/mcp-server/inputRequired.js +76 -0
- package/dist/mcp-server/inputRequired.js.map +1 -0
- package/dist/mcp-server/notifications.d.ts +103 -34
- package/dist/mcp-server/notifications.d.ts.map +1 -1
- package/dist/mcp-server/notifications.js +104 -29
- package/dist/mcp-server/notifications.js.map +1 -1
- package/dist/mcp-server/prompts/prompt-registration.d.ts +2 -2
- package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -1
- package/dist/mcp-server/prompts/prompt-registration.js +15 -5
- package/dist/mcp-server/prompts/prompt-registration.js.map +1 -1
- package/dist/mcp-server/prompts/utils/promptDefinition.d.ts +1 -1
- package/dist/mcp-server/prompts/utils/promptDefinition.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.d.ts +3 -3
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.js +9 -15
- package/dist/mcp-server/resources/resource-registration.js.map +1 -1
- package/dist/mcp-server/resources/resourceSubscriptions.d.ts +45 -0
- package/dist/mcp-server/resources/resourceSubscriptions.d.ts.map +1 -0
- package/dist/mcp-server/resources/resourceSubscriptions.js +51 -0
- package/dist/mcp-server/resources/resourceSubscriptions.js.map +1 -0
- package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +3 -5
- package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceDefinition.js +1 -1
- package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +18 -17
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +39 -39
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
- package/dist/mcp-server/server.d.ts +20 -21
- package/dist/mcp-server/server.d.ts.map +1 -1
- package/dist/mcp-server/server.js +42 -28
- package/dist/mcp-server/server.js.map +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +11 -33
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/tool-registration.js +18 -243
- package/dist/mcp-server/tools/tool-registration.js.map +1 -1
- package/dist/mcp-server/tools/utils/schemaShape.d.ts +27 -0
- package/dist/mcp-server/tools/utils/schemaShape.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/schemaShape.js +43 -0
- package/dist/mcp-server/tools/utils/schemaShape.js.map +1 -0
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts +28 -8
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolDefinition.js +63 -1
- package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +54 -20
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +156 -44
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/mcp-server/transports/ITransport.d.ts +2 -2
- package/dist/mcp-server/transports/ITransport.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/authFactory.js +1 -1
- package/dist/mcp-server/transports/auth/authFactory.js.map +1 -1
- package/dist/mcp-server/transports/auth/lib/authTypes.d.ts +1 -1
- package/dist/mcp-server/transports/auth/lib/authTypes.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/lib/authUtils.js +5 -13
- package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -1
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +5 -11
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -1
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +9 -22
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -1
- package/dist/mcp-server/transports/heartbeat.d.ts.map +1 -1
- package/dist/mcp-server/transports/heartbeat.js +4 -8
- package/dist/mcp-server/transports/heartbeat.js.map +1 -1
- package/dist/mcp-server/transports/http/eventStore.d.ts +57 -0
- package/dist/mcp-server/transports/http/eventStore.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/eventStore.js +114 -0
- package/dist/mcp-server/transports/http/eventStore.js.map +1 -0
- package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.js +6 -24
- package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
- package/dist/mcp-server/transports/http/httpServer.d.ts +4 -3
- package/dist/mcp-server/transports/http/httpServer.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpServer.js +16 -33
- package/dist/mcp-server/transports/http/httpServer.js.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.d.ts +30 -8
- package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.js +180 -374
- package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/assets/styles.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/assets/styles.js +0 -1
- package/dist/mcp-server/transports/http/landing-page/assets/styles.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 +4 -8
- package/dist/mcp-server/transports/http/landing-page/handler.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/sections/tools.js +22 -4
- package/dist/mcp-server/transports/http/landing-page/sections/tools.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 -6
- package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -1
- package/dist/mcp-server/transports/http/robotsTxt.js +2 -2
- package/dist/mcp-server/transports/http/robotsTxt.js.map +1 -1
- package/dist/mcp-server/transports/http/serverCard.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/serverCard.js +2 -6
- package/dist/mcp-server/transports/http/serverCard.js.map +1 -1
- package/dist/mcp-server/transports/http/sessionStore.d.ts +46 -66
- package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/sessionStore.js +140 -238
- package/dist/mcp-server/transports/http/sessionStore.js.map +1 -1
- package/dist/mcp-server/transports/manager.d.ts +21 -4
- package/dist/mcp-server/transports/manager.d.ts.map +1 -1
- package/dist/mcp-server/transports/manager.js +40 -34
- package/dist/mcp-server/transports/manager.js.map +1 -1
- package/dist/mcp-server/transports/stdio/stdioTransport.d.ts +24 -31
- package/dist/mcp-server/transports/stdio/stdioTransport.d.ts.map +1 -1
- package/dist/mcp-server/transports/stdio/stdioTransport.js +23 -38
- package/dist/mcp-server/transports/stdio/stdioTransport.js.map +1 -1
- package/dist/mcp-server/types.d.ts +25 -0
- package/dist/mcp-server/types.d.ts.map +1 -0
- package/dist/mcp-server/types.js +10 -0
- package/dist/mcp-server/types.js.map +1 -0
- package/dist/services/canvas/core/CanvasInstance.d.ts +2 -2
- package/dist/services/canvas/core/CanvasInstance.d.ts.map +1 -1
- package/dist/services/canvas/core/CanvasInstance.js.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.d.ts +4 -4
- package/dist/services/canvas/core/CanvasRegistry.d.ts.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.js +8 -18
- package/dist/services/canvas/core/CanvasRegistry.js.map +1 -1
- package/dist/services/canvas/core/DataCanvas.d.ts +5 -5
- package/dist/services/canvas/core/DataCanvas.d.ts.map +1 -1
- package/dist/services/canvas/core/DataCanvas.js +2 -3
- package/dist/services/canvas/core/DataCanvas.js.map +1 -1
- package/dist/services/canvas/core/IDataCanvasProvider.d.ts +11 -11
- package/dist/services/canvas/core/IDataCanvasProvider.d.ts.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts +11 -11
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js +4 -10
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js.map +1 -1
- package/dist/services/llm/providers/openrouter.provider.d.ts.map +1 -1
- package/dist/services/llm/providers/openrouter.provider.js +2 -5
- package/dist/services/llm/providers/openrouter.provider.js.map +1 -1
- package/dist/services/mirror/core/defineMirror.js +1 -1
- package/dist/services/mirror/core/defineMirror.js.map +1 -1
- package/dist/services/mirror/types.d.ts +5 -5
- package/dist/services/mirror/types.d.ts.map +1 -1
- package/dist/services/speech/providers/elevenlabs.provider.js +1 -1
- package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -1
- package/dist/services/speech/providers/whisper.provider.js +1 -1
- package/dist/services/speech/providers/whisper.provider.js.map +1 -1
- package/dist/storage/core/StorageService.d.ts +1 -1
- package/dist/storage/core/StorageService.d.ts.map +1 -1
- package/dist/storage/core/StorageService.js +12 -20
- package/dist/storage/core/StorageService.js.map +1 -1
- package/dist/storage/core/storageFactory.d.ts.map +1 -1
- package/dist/storage/core/storageFactory.js.map +1 -1
- package/dist/storage/core/storageValidation.d.ts +1 -1
- package/dist/storage/core/storageValidation.d.ts.map +1 -1
- package/dist/storage/core/storageValidation.js +2 -2
- package/dist/storage/core/storageValidation.js.map +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.js +4 -12
- package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.js +3 -8
- 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 +3 -8
- package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.js +2 -4
- package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
- package/dist/testing/fuzz.d.ts +7 -4
- package/dist/testing/fuzz.d.ts.map +1 -1
- package/dist/testing/fuzz.js +13 -5
- package/dist/testing/fuzz.js.map +1 -1
- package/dist/testing/index.d.ts +35 -12
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +53 -38
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/vitest.d.ts +1 -1
- package/dist/testing/vitest.d.ts.map +1 -1
- package/dist/types-global/errors.d.ts +28 -15
- package/dist/types-global/errors.d.ts.map +1 -1
- package/dist/types-global/errors.js +8 -1
- package/dist/types-global/errors.js.map +1 -1
- package/dist/utils/formatting/diffFormatter.d.ts +5 -5
- package/dist/utils/formatting/diffFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/diffFormatter.js +7 -20
- package/dist/utils/formatting/diffFormatter.js.map +1 -1
- package/dist/utils/formatting/tableFormatter.d.ts +3 -3
- package/dist/utils/formatting/tableFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/tableFormatter.js +6 -17
- package/dist/utils/formatting/tableFormatter.js.map +1 -1
- package/dist/utils/formatting/treeFormatter.d.ts +3 -3
- package/dist/utils/formatting/treeFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/treeFormatter.js +5 -18
- package/dist/utils/formatting/treeFormatter.js.map +1 -1
- package/dist/utils/index.d.ts +4 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.d.ts +1 -1
- package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -1
- package/dist/utils/internal/error-handler/errorHandler.js +23 -11
- package/dist/utils/internal/error-handler/errorHandler.js.map +1 -1
- package/dist/utils/internal/error-handler/types.d.ts +10 -13
- package/dist/utils/internal/error-handler/types.d.ts.map +1 -1
- package/dist/utils/internal/logger.d.ts +3 -3
- package/dist/utils/internal/logger.d.ts.map +1 -1
- package/dist/utils/internal/logger.js +11 -5
- package/dist/utils/internal/logger.js.map +1 -1
- package/dist/utils/internal/performance.d.ts +13 -5
- package/dist/utils/internal/performance.d.ts.map +1 -1
- package/dist/utils/internal/performance.js +76 -17
- package/dist/utils/internal/performance.js.map +1 -1
- package/dist/utils/internal/requestContext.d.ts +92 -55
- package/dist/utils/internal/requestContext.d.ts.map +1 -1
- package/dist/utils/internal/requestContext.js +120 -40
- package/dist/utils/internal/requestContext.js.map +1 -1
- package/dist/utils/metrics/tokenCounter.d.ts +3 -3
- package/dist/utils/metrics/tokenCounter.d.ts.map +1 -1
- package/dist/utils/metrics/tokenCounter.js.map +1 -1
- package/dist/utils/network/fetchWithTimeout.d.ts +2 -2
- package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
- package/dist/utils/network/fetchWithTimeout.js +8 -24
- package/dist/utils/network/fetchWithTimeout.js.map +1 -1
- package/dist/utils/network/retry.d.ts +2 -2
- package/dist/utils/network/retry.d.ts.map +1 -1
- package/dist/utils/overflow/outlineOnOverflow.d.ts +1 -1
- package/dist/utils/overflow/outlineOnOverflow.d.ts.map +1 -1
- package/dist/utils/pagination/pagination.d.ts +3 -3
- package/dist/utils/pagination/pagination.d.ts.map +1 -1
- package/dist/utils/pagination/pagination.js +3 -3
- package/dist/utils/pagination/pagination.js.map +1 -1
- package/dist/utils/parsing/csvParser.d.ts +2 -2
- package/dist/utils/parsing/csvParser.d.ts.map +1 -1
- package/dist/utils/parsing/csvParser.js +4 -8
- package/dist/utils/parsing/csvParser.js.map +1 -1
- package/dist/utils/parsing/dateParser.d.ts +3 -3
- package/dist/utils/parsing/dateParser.d.ts.map +1 -1
- package/dist/utils/parsing/dateParser.js +3 -2
- package/dist/utils/parsing/dateParser.js.map +1 -1
- package/dist/utils/parsing/frontmatterParser.d.ts +2 -2
- package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -1
- package/dist/utils/parsing/frontmatterParser.js +7 -10
- package/dist/utils/parsing/frontmatterParser.js.map +1 -1
- package/dist/utils/parsing/htmlExtractor.d.ts +2 -2
- package/dist/utils/parsing/htmlExtractor.d.ts.map +1 -1
- package/dist/utils/parsing/htmlExtractor.js +6 -11
- package/dist/utils/parsing/htmlExtractor.js.map +1 -1
- package/dist/utils/parsing/jsonParser.d.ts +2 -2
- package/dist/utils/parsing/jsonParser.d.ts.map +1 -1
- package/dist/utils/parsing/jsonParser.js +4 -8
- package/dist/utils/parsing/jsonParser.js.map +1 -1
- package/dist/utils/parsing/pdfParser.d.ts +10 -10
- package/dist/utils/parsing/pdfParser.d.ts.map +1 -1
- package/dist/utils/parsing/pdfParser.js +26 -89
- package/dist/utils/parsing/pdfParser.js.map +1 -1
- package/dist/utils/parsing/xmlParser.d.ts +2 -2
- package/dist/utils/parsing/xmlParser.d.ts.map +1 -1
- package/dist/utils/parsing/xmlParser.js +4 -8
- package/dist/utils/parsing/xmlParser.js.map +1 -1
- package/dist/utils/parsing/yamlParser.d.ts +2 -2
- package/dist/utils/parsing/yamlParser.d.ts.map +1 -1
- package/dist/utils/parsing/yamlParser.js +4 -8
- package/dist/utils/parsing/yamlParser.js.map +1 -1
- package/dist/utils/scheduling/scheduler.d.ts.map +1 -1
- package/dist/utils/scheduling/scheduler.js +5 -6
- package/dist/utils/scheduling/scheduler.js.map +1 -1
- package/dist/utils/security/rateLimiter.d.ts +2 -2
- package/dist/utils/security/rateLimiter.d.ts.map +1 -1
- package/dist/utils/security/rateLimiter.js +1 -1
- package/dist/utils/security/rateLimiter.js.map +1 -1
- package/dist/utils/telemetry/attributes.d.ts +23 -7
- package/dist/utils/telemetry/attributes.d.ts.map +1 -1
- package/dist/utils/telemetry/attributes.js +23 -10
- package/dist/utils/telemetry/attributes.js.map +1 -1
- package/dist/utils/telemetry/trace.d.ts +3 -3
- package/dist/utils/telemetry/trace.d.ts.map +1 -1
- package/dist/utils/telemetry/trace.js +4 -2
- package/dist/utils/telemetry/trace.js.map +1 -1
- package/package.json +22 -26
- package/scripts/lint-mcp.ts +1 -3
- package/scripts/lint-packaging.ts +1 -1
- package/skills/add-service/SKILL.md +2 -2
- package/skills/add-test/SKILL.md +42 -20
- package/skills/add-tool/SKILL.md +103 -19
- package/skills/api-config/SKILL.md +4 -11
- package/skills/api-context/SKILL.md +216 -120
- package/skills/api-linter/SKILL.md +16 -3
- package/skills/api-telemetry/SKILL.md +10 -12
- package/skills/api-testing/SKILL.md +53 -52
- package/skills/api-workers/SKILL.md +9 -1
- package/skills/code-simplifier/SKILL.md +2 -2
- package/skills/design-mcp-server/SKILL.md +31 -17
- package/skills/field-test/SKILL.md +4 -2
- package/skills/polish-docs-meta/SKILL.md +1 -1
- package/skills/polish-docs-meta/references/agent-protocol.md +2 -2
- package/skills/polish-docs-meta/references/readme.md +1 -1
- package/skills/release-and-publish/SKILL.md +3 -1
- package/skills/report-issue-framework/SKILL.md +2 -2
- package/skills/report-issue-local/SKILL.md +2 -2
- package/skills/security-pass/SKILL.md +16 -14
- package/skills/tool-defs-analysis/SKILL.md +15 -5
- package/templates/.env.example +4 -0
- package/templates/AGENTS.md +6 -6
- package/templates/CLAUDE.md +6 -6
- package/templates/tests/resources/echo.resource.test.ts +16 -9
- package/dist/mcp-server/elicitation.d.ts +0 -64
- package/dist/mcp-server/elicitation.d.ts.map +0 -1
- package/dist/mcp-server/elicitation.js +0 -81
- package/dist/mcp-server/elicitation.js.map +0 -1
- package/dist/mcp-server/protocolSession.d.ts +0 -34
- package/dist/mcp-server/protocolSession.d.ts.map +0 -1
- package/dist/mcp-server/protocolSession.js +0 -13
- package/dist/mcp-server/protocolSession.js.map +0 -1
- package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts +0 -53
- package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.d.ts.map +0 -1
- package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js +0 -65
- package/dist/mcp-server/tasks/core/evictingTaskMessageQueue.js.map +0 -1
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts +0 -70
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts.map +0 -1
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js +0 -130
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js.map +0 -1
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts +0 -109
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts.map +0 -1
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.js +0 -209
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.js.map +0 -1
- package/dist/mcp-server/tasks/core/taskManager.d.ts +0 -91
- package/dist/mcp-server/tasks/core/taskManager.d.ts.map +0 -1
- package/dist/mcp-server/tasks/core/taskManager.js +0 -210
- package/dist/mcp-server/tasks/core/taskManager.js.map +0 -1
- package/dist/mcp-server/tasks/core/taskTypes.d.ts +0 -18
- package/dist/mcp-server/tasks/core/taskTypes.d.ts.map +0 -1
- package/dist/mcp-server/tasks/core/taskTypes.js +0 -20
- package/dist/mcp-server/tasks/core/taskTypes.js.map +0 -1
- package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts +0 -101
- package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts.map +0 -1
- package/dist/mcp-server/tasks/utils/taskToolDefinition.js +0 -14
- package/dist/mcp-server/tasks/utils/taskToolDefinition.js.map +0 -1
package/templates/AGENTS.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
**Version:** 0.1.0
|
|
5
5
|
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^{{FRAMEWORK_VERSION}}`
|
|
6
6
|
**Engines:** Bun ≥1.3.0, Node ≥24.0.0
|
|
7
|
-
**MCP SDK:** `@modelcontextprotocol/
|
|
7
|
+
**MCP SDK:** `@modelcontextprotocol/server` {{MCP_SDK_VERSION}}
|
|
8
8
|
**Zod:** {{ZOD_VERSION}}
|
|
9
9
|
|
|
10
10
|
> **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
|
|
@@ -48,7 +48,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
48
48
|
- **Logic throws, framework catches.** Tool/resource handlers are pure — throw on failure, no `try/catch`. Plain `Error` is fine; the framework catches, classifies, and formats. Use error factories (`notFound()`, `validationError()`, etc.) when the error code matters.
|
|
49
49
|
- **Use `ctx.log`** for request-scoped logging. No `console` calls.
|
|
50
50
|
- **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
|
|
51
|
-
- **
|
|
51
|
+
- **Need input the caller didn't supply?** `return ctx.requestInput(...)` and read `ctx.inputs` when the handler is re-entered. Never `await` for user input mid-handler.
|
|
52
52
|
- **Secrets in env vars only** — never hardcoded.
|
|
53
53
|
- **Close the loop on issues.** When implementing work tracked by a GitHub issue, comment on the issue with what landed and close it. Do both — a comment without a close leaves stale issues open; a close without a comment leaves no record of what shipped. The comment is for future readers — state the concrete changes, not the conversation that produced them.
|
|
54
54
|
|
|
@@ -181,13 +181,13 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
181
181
|
|
|
182
182
|
| Property | Description |
|
|
183
183
|
|:---------|:------------|
|
|
184
|
-
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
|
|
184
|
+
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino **and** `notifications/message` to the client, so treat it as client-visible. |
|
|
185
185
|
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
|
|
186
|
-
| `ctx.
|
|
186
|
+
| `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. Always present. |
|
|
187
|
+
| `ctx.inputs` | Reader over a retried request's responses — `.accepted(key, schema)`, `.view(key)`, `.state()`, `.dropped`. Empty on the first round. |
|
|
187
188
|
| `ctx.enrich` | Success-path agent context (empty-result notices, query echo, pagination totals) — `ctx.enrich(...)` or `.notice()` / `.total()` / `.echo()` / `.truncated()`. Reaches `structuredContent` and `content[]`; lands only when the definition declares an `enrichment` block (no-op otherwise). |
|
|
188
189
|
| `ctx.content` | Non-text content blocks — `.image(data, mimeType)`, `.audio(data, mimeType)`, or `ctx.content(block)` for a raw block. Prepended to `content[]` after `format()`; never enters `structuredContent`. |
|
|
189
190
|
| `ctx.signal` | `AbortSignal` for cancellation. |
|
|
190
|
-
| `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
|
|
191
191
|
| `ctx.requestId` | Unique request ID. |
|
|
192
192
|
| `ctx.tenantId` | Tenant ID from JWT; `'default'` for stdio or HTTP with auth off. |
|
|
193
193
|
|
|
@@ -303,7 +303,7 @@ Available skills:
|
|
|
303
303
|
| `api-auth` | Auth modes, scopes, JWT/OAuth |
|
|
304
304
|
| `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
|
|
305
305
|
| `api-config` | AppConfig, parseConfig, env vars |
|
|
306
|
-
| `api-context` | Context interface, logger, state,
|
|
306
|
+
| `api-context` | Context interface, RequestContext, logger, state, multi-round-trip input |
|
|
307
307
|
| `api-errors` | McpError, JsonRpcErrorCode, error patterns |
|
|
308
308
|
| `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
|
|
309
309
|
| `api-mirror` | MirrorService: persistent self-refreshing local mirror (embedded SQLite + FTS5) of a bulk upstream dataset — Tier 3 opt-in |
|
package/templates/CLAUDE.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
**Version:** 0.1.0
|
|
5
5
|
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^{{FRAMEWORK_VERSION}}`
|
|
6
6
|
**Engines:** Bun ≥1.3.0, Node ≥24.0.0
|
|
7
|
-
**MCP SDK:** `@modelcontextprotocol/
|
|
7
|
+
**MCP SDK:** `@modelcontextprotocol/server` {{MCP_SDK_VERSION}}
|
|
8
8
|
**Zod:** {{ZOD_VERSION}}
|
|
9
9
|
|
|
10
10
|
> **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
|
|
@@ -48,7 +48,7 @@ Tailor suggestions to what's actually missing or stale — don't recite the full
|
|
|
48
48
|
- **Logic throws, framework catches.** Tool/resource handlers are pure — throw on failure, no `try/catch`. Plain `Error` is fine; the framework catches, classifies, and formats. Use error factories (`notFound()`, `validationError()`, etc.) when the error code matters.
|
|
49
49
|
- **Use `ctx.log`** for request-scoped logging. No `console` calls.
|
|
50
50
|
- **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
|
|
51
|
-
- **
|
|
51
|
+
- **Need input the caller didn't supply?** `return ctx.requestInput(...)` and read `ctx.inputs` when the handler is re-entered. Never `await` for user input mid-handler.
|
|
52
52
|
- **Secrets in env vars only** — never hardcoded.
|
|
53
53
|
- **Close the loop on issues.** When implementing work tracked by a GitHub issue, comment on the issue with what landed and close it. Do both — a comment without a close leaves stale issues open; a close without a comment leaves no record of what shipped. The comment is for future readers — state the concrete changes, not the conversation that produced them.
|
|
54
54
|
|
|
@@ -181,13 +181,13 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
181
181
|
|
|
182
182
|
| Property | Description |
|
|
183
183
|
|:---------|:------------|
|
|
184
|
-
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
|
|
184
|
+
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. Dual-sink: Pino **and** `notifications/message` to the client, so treat it as client-visible. |
|
|
185
185
|
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.getMany(keys)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
|
|
186
|
-
| `ctx.
|
|
186
|
+
| `ctx.requestInput` | Suspend and ask the caller for more input — `return ctx.requestInput({ inputRequests: { key: inputRequired.elicit({ message, requestedSchema }) } })`. Never returns; the handler is re-entered with the answers. Always present. |
|
|
187
|
+
| `ctx.inputs` | Reader over a retried request's responses — `.accepted(key, schema)`, `.view(key)`, `.state()`, `.dropped`. Empty on the first round. |
|
|
187
188
|
| `ctx.enrich` | Success-path agent context (empty-result notices, query echo, pagination totals) — `ctx.enrich(...)` or `.notice()` / `.total()` / `.echo()` / `.truncated()`. Reaches `structuredContent` and `content[]`; lands only when the definition declares an `enrichment` block (no-op otherwise). |
|
|
188
189
|
| `ctx.content` | Non-text content blocks — `.image(data, mimeType)`, `.audio(data, mimeType)`, or `ctx.content(block)` for a raw block. Prepended to `content[]` after `format()`; never enters `structuredContent`. |
|
|
189
190
|
| `ctx.signal` | `AbortSignal` for cancellation. |
|
|
190
|
-
| `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
|
|
191
191
|
| `ctx.requestId` | Unique request ID. |
|
|
192
192
|
| `ctx.tenantId` | Tenant ID from JWT; `'default'` for stdio or HTTP with auth off. |
|
|
193
193
|
|
|
@@ -303,7 +303,7 @@ Available skills:
|
|
|
303
303
|
| `api-auth` | Auth modes, scopes, JWT/OAuth |
|
|
304
304
|
| `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
|
|
305
305
|
| `api-config` | AppConfig, parseConfig, env vars |
|
|
306
|
-
| `api-context` | Context interface, logger, state,
|
|
306
|
+
| `api-context` | Context interface, RequestContext, logger, state, multi-round-trip input |
|
|
307
307
|
| `api-errors` | McpError, JsonRpcErrorCode, error patterns |
|
|
308
308
|
| `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
|
|
309
309
|
| `api-mirror` | MirrorService: persistent self-refreshing local mirror (embedded SQLite + FTS5) of a bulk upstream dataset — Tier 3 opt-in |
|
|
@@ -16,15 +16,22 @@ describe('echoResource', () => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
it('lists available resources', async () => {
|
|
19
|
-
// `list` receives the SDK's
|
|
20
|
-
// async — a minimal literal is enough for a listing that ignores it.
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
// `list` receives the SDK's `ServerContext`, not a handler `Context`, and
|
|
20
|
+
// may be async — a minimal literal is enough for a listing that ignores it.
|
|
21
|
+
const serverContext = {
|
|
22
|
+
mcpReq: {
|
|
23
|
+
id: 'test',
|
|
24
|
+
method: 'resources/list',
|
|
25
|
+
signal: new AbortController().signal,
|
|
26
|
+
requestState: () => undefined,
|
|
27
|
+
send: () => Promise.resolve({} as never),
|
|
28
|
+
notify: () => Promise.resolve(),
|
|
29
|
+
log: () => Promise.resolve(),
|
|
30
|
+
elicitInput: () => Promise.resolve({ action: 'cancel' as const }),
|
|
31
|
+
requestSampling: () => Promise.reject(new Error('not supported')),
|
|
32
|
+
},
|
|
33
|
+
} as unknown as Parameters<NonNullable<typeof echoResource.list>>[0];
|
|
34
|
+
const listing = await echoResource.list!(serverContext);
|
|
28
35
|
expect(listing.resources).toHaveLength(1);
|
|
29
36
|
expect(listing.resources[0]).toMatchObject({
|
|
30
37
|
uri: 'echo://hello',
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Shared elicitation plumbing for the tool and resource handler
|
|
3
|
-
* factories.
|
|
4
|
-
* @module src/mcp-server/elicitation
|
|
5
|
-
*/
|
|
6
|
-
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
7
|
-
import { type ElicitRequestFormParams, type ElicitRequestURLParams, type ElicitResult, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
-
import { type ZodObject, type ZodRawShape } from 'zod';
|
|
9
|
-
import type { ElicitFn } from '../core/context.js';
|
|
10
|
-
type SdkExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
11
|
-
/**
|
|
12
|
-
* The elicitation slice of the tool and resource notifier bundles.
|
|
13
|
-
*
|
|
14
|
-
* `elicitInput` and `getClientCapabilities` are bound at registration time to
|
|
15
|
-
* the per-server `Server` instance so `wrapElicit` can gate `ctx.elicit` on the
|
|
16
|
-
* client's advertised capability and forward elicitation requests on the wire.
|
|
17
|
-
* Both are undefined where no connected client is available (the auto-task
|
|
18
|
-
* background path).
|
|
19
|
-
*/
|
|
20
|
-
export interface ElicitationNotifiers {
|
|
21
|
-
/** Bound to `server.server.elicitInput.bind(server.server)`. */
|
|
22
|
-
elicitInput?: (params: ElicitRequestFormParams | ElicitRequestURLParams) => Promise<ElicitResult>;
|
|
23
|
-
/** Bound to `server.server.getClientCapabilities.bind(server.server)`. */
|
|
24
|
-
getClientCapabilities?: () => {
|
|
25
|
-
elicitation?: unknown;
|
|
26
|
-
} | undefined;
|
|
27
|
-
/** Route elicitation through RequestHandlerExtra.sendRequest on per-request servers. */
|
|
28
|
-
requestScopedElicitation?: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Validate an accepted elicitation payload against the schema its request
|
|
32
|
-
* advertised.
|
|
33
|
-
*
|
|
34
|
-
* `Server.elicitInput` runs this check itself, but a per-request HTTP server
|
|
35
|
-
* reaches the client through `RequestHandlerExtra.sendRequest` instead and so
|
|
36
|
-
* bypasses it. Raising the SDK's own `InvalidParams` shape here keeps
|
|
37
|
-
* `ctx.elicit`'s failure contract identical on both transports.
|
|
38
|
-
*
|
|
39
|
-
* @param schema - The Zod object the elicitation request was built from.
|
|
40
|
-
* @param content - The `content` of an `accept` response.
|
|
41
|
-
* @throws {McpError} `InvalidParams` when the payload does not satisfy `schema`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function assertElicitedContent(schema: ZodObject<ZodRawShape>, content: unknown): void;
|
|
44
|
-
/**
|
|
45
|
-
* Builds `ctx.elicit` from the notifiers bound at registration time.
|
|
46
|
-
*
|
|
47
|
-
* Returns `undefined` when:
|
|
48
|
-
* - `elicitInput` was not bound (auto-task background path, or no server),
|
|
49
|
-
* - the client did not advertise the elicitation capability (checked at
|
|
50
|
-
* request time, after the initialize handshake populates capabilities).
|
|
51
|
-
*
|
|
52
|
-
* When defined, the returned function is an `ElicitFn`: directly callable for
|
|
53
|
-
* form-mode elicitation (schema converted from ZodObject to the restricted
|
|
54
|
-
* flat JSON Schema the MCP spec requires), plus a `.url(message, url)` helper
|
|
55
|
-
* for URL-mode elicitation (elicitationId generated internally).
|
|
56
|
-
*
|
|
57
|
-
* CRITICAL: `requestedSchema` must be a plain JSON Schema object in the spec's
|
|
58
|
-
* restricted flat form — passing a raw ZodObject causes AJV validation to
|
|
59
|
-
* reject the request on the SDK side. `z.toJSONSchema(schema)` produces the
|
|
60
|
-
* correct shape.
|
|
61
|
-
*/
|
|
62
|
-
export declare function wrapElicit(notifiers: ElicitationNotifiers, sdkContext: SdkExtra): ElicitFn | undefined;
|
|
63
|
-
export {};
|
|
64
|
-
//# sourceMappingURL=elicitation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../src/mcp-server/elicitation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAEjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,KAAK,QAAQ,GAAG,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,GAAG,sBAAsB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAClG,0EAA0E;IAC1E,qBAAqB,CAAC,EAAE,MAAM;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;IACpE,wFAAwF;IACxF,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAU5F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,oBAAoB,EAC/B,UAAU,EAAE,QAAQ,GACnB,QAAQ,GAAG,SAAS,CAgCtB"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Shared elicitation plumbing for the tool and resource handler
|
|
3
|
-
* factories.
|
|
4
|
-
* @module src/mcp-server/elicitation
|
|
5
|
-
*/
|
|
6
|
-
import { ElicitResultSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
-
import { toJSONSchema } from 'zod';
|
|
8
|
-
import { invalidParams } from '../types-global/errors.js';
|
|
9
|
-
/**
|
|
10
|
-
* Validate an accepted elicitation payload against the schema its request
|
|
11
|
-
* advertised.
|
|
12
|
-
*
|
|
13
|
-
* `Server.elicitInput` runs this check itself, but a per-request HTTP server
|
|
14
|
-
* reaches the client through `RequestHandlerExtra.sendRequest` instead and so
|
|
15
|
-
* bypasses it. Raising the SDK's own `InvalidParams` shape here keeps
|
|
16
|
-
* `ctx.elicit`'s failure contract identical on both transports.
|
|
17
|
-
*
|
|
18
|
-
* @param schema - The Zod object the elicitation request was built from.
|
|
19
|
-
* @param content - The `content` of an `accept` response.
|
|
20
|
-
* @throws {McpError} `InvalidParams` when the payload does not satisfy `schema`.
|
|
21
|
-
*/
|
|
22
|
-
export function assertElicitedContent(schema, content) {
|
|
23
|
-
const parsed = schema.safeParse(content);
|
|
24
|
-
if (parsed.success)
|
|
25
|
-
return;
|
|
26
|
-
throw invalidParams('Elicitation response content does not match the requested schema.', {
|
|
27
|
-
reason: 'elicitation_response_invalid',
|
|
28
|
-
issues: parsed.error.issues.map((issue) => ({
|
|
29
|
-
path: issue.path.join('.'),
|
|
30
|
-
code: issue.code,
|
|
31
|
-
})),
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Builds `ctx.elicit` from the notifiers bound at registration time.
|
|
36
|
-
*
|
|
37
|
-
* Returns `undefined` when:
|
|
38
|
-
* - `elicitInput` was not bound (auto-task background path, or no server),
|
|
39
|
-
* - the client did not advertise the elicitation capability (checked at
|
|
40
|
-
* request time, after the initialize handshake populates capabilities).
|
|
41
|
-
*
|
|
42
|
-
* When defined, the returned function is an `ElicitFn`: directly callable for
|
|
43
|
-
* form-mode elicitation (schema converted from ZodObject to the restricted
|
|
44
|
-
* flat JSON Schema the MCP spec requires), plus a `.url(message, url)` helper
|
|
45
|
-
* for URL-mode elicitation (elicitationId generated internally).
|
|
46
|
-
*
|
|
47
|
-
* CRITICAL: `requestedSchema` must be a plain JSON Schema object in the spec's
|
|
48
|
-
* restricted flat form — passing a raw ZodObject causes AJV validation to
|
|
49
|
-
* reject the request on the SDK side. `z.toJSONSchema(schema)` produces the
|
|
50
|
-
* correct shape.
|
|
51
|
-
*/
|
|
52
|
-
export function wrapElicit(notifiers, sdkContext) {
|
|
53
|
-
const { elicitInput, getClientCapabilities } = notifiers;
|
|
54
|
-
if (typeof elicitInput !== 'function')
|
|
55
|
-
return;
|
|
56
|
-
// Capability check runs at request time (not registration time) so that
|
|
57
|
-
// capabilities populated during the initialize handshake are visible.
|
|
58
|
-
if (!getClientCapabilities?.()?.elicitation)
|
|
59
|
-
return;
|
|
60
|
-
const send = (params) => {
|
|
61
|
-
if (!notifiers.requestScopedElicitation)
|
|
62
|
-
return elicitInput(params);
|
|
63
|
-
return sdkContext.sendRequest({ method: 'elicitation/create', params }, ElicitResultSchema);
|
|
64
|
-
};
|
|
65
|
-
const formFn = async (msg, schema) => {
|
|
66
|
-
const requestedSchema = toJSONSchema(schema);
|
|
67
|
-
const result = await send({ mode: 'form', message: msg, requestedSchema });
|
|
68
|
-
if (notifiers.requestScopedElicitation && result.action === 'accept' && result.content) {
|
|
69
|
-
assertElicitedContent(schema, result.content);
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
};
|
|
73
|
-
const urlFn = (msg, url) => {
|
|
74
|
-
const elicitationId = crypto.randomUUID();
|
|
75
|
-
return send({ mode: 'url', message: msg, elicitationId, url });
|
|
76
|
-
};
|
|
77
|
-
const elicitFn = formFn;
|
|
78
|
-
elicitFn.url = urlFn;
|
|
79
|
-
return elicitFn;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=elicitation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.js","sourceRoot":"","sources":["../../src/mcp-server/elicitation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAIL,kBAAkB,GAGnB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAoC,MAAM,KAAK,CAAC;AAGrE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAsBzD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA8B,EAAE,OAAgB;IACpF,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO;IAC3B,MAAM,aAAa,CAAC,mEAAmE,EAAE;QACvF,MAAM,EAAE,8BAA8B;QACtC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CACxB,SAA+B,EAC/B,UAAoB;IAEpB,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC;IACzD,IAAI,OAAO,WAAW,KAAK,UAAU;QAAE,OAAO;IAE9C,wEAAwE;IACxE,sEAAsE;IACtE,IAAI,CAAC,qBAAqB,EAAE,EAAE,EAAE,WAAW;QAAE,OAAO;IAEpD,MAAM,IAAI,GAAG,CACX,MAAwD,EACjC,EAAE;QACzB,IAAI,CAAC,SAAS,CAAC,wBAAwB;YAAE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;QACpE,OAAO,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAC9F,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,EAAE,GAAW,EAAE,MAA8B,EAAyB,EAAE;QAC1F,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,CAA+C,CAAC;QAC3F,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3E,IAAI,SAAS,CAAC,wBAAwB,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACvF,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAW,EAAyB,EAAE;QAChE,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAkB,CAAC;IACpC,QAAQ,CAAC,GAAG,GAAG,KAAK,CAAC;IACrB,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Request-spanning protocol state hooks for transports that
|
|
3
|
-
* create a fresh MCP SDK server for every request.
|
|
4
|
-
*
|
|
5
|
-
* The SDK stores negotiated capabilities and cancellation controllers on a
|
|
6
|
-
* `Server` instance. Streamable HTTP deliberately cannot reuse that instance
|
|
7
|
-
* across requests (GHSA-345p-7cg4-v4c7), so the framework carries only the
|
|
8
|
-
* minimal session state needed by handler contexts through these hooks.
|
|
9
|
-
*
|
|
10
|
-
* @module src/mcp-server/protocolSession
|
|
11
|
-
*/
|
|
12
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
13
|
-
import type { ClientCapabilities, RequestId } from '@modelcontextprotocol/sdk/types.js';
|
|
14
|
-
/** A cancellation signal registered for one in-flight JSON-RPC request. */
|
|
15
|
-
export interface ProtocolRequestRegistration {
|
|
16
|
-
/** Aborted when a matching `notifications/cancelled` reaches the session. */
|
|
17
|
-
signal: AbortSignal;
|
|
18
|
-
/** Removes only this registration; safe to call more than once. */
|
|
19
|
-
unregister: () => void;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* State restored onto a per-request server from its durable HTTP session.
|
|
23
|
-
* Undefined for stdio and stateless HTTP, where no cross-request restoration
|
|
24
|
-
* is necessary or possible.
|
|
25
|
-
*/
|
|
26
|
-
export interface ProtocolSessionHooks {
|
|
27
|
-
/** Capabilities captured from the successful initialize request. */
|
|
28
|
-
clientCapabilities?: ClientCapabilities;
|
|
29
|
-
/** Registers a tool/resource request for cross-request cancellation. */
|
|
30
|
-
registerRequest?: (requestId: RequestId) => ProtocolRequestRegistration;
|
|
31
|
-
}
|
|
32
|
-
/** Factory shared by stdio (no hooks) and per-request HTTP servers. */
|
|
33
|
-
export type McpServerFactory = (session?: ProtocolSessionHooks) => Promise<McpServer>;
|
|
34
|
-
//# sourceMappingURL=protocolSession.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocolSession.d.ts","sourceRoot":"","sources":["../../src/mcp-server/protocolSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAExF,2EAA2E;AAC3E,MAAM,WAAW,2BAA2B;IAC1C,6EAA6E;IAC7E,MAAM,EAAE,WAAW,CAAC;IACpB,mEAAmE;IACnE,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,wEAAwE;IACxE,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,2BAA2B,CAAC;CACzE;AAED,uEAAuE;AACvE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Request-spanning protocol state hooks for transports that
|
|
3
|
-
* create a fresh MCP SDK server for every request.
|
|
4
|
-
*
|
|
5
|
-
* The SDK stores negotiated capabilities and cancellation controllers on a
|
|
6
|
-
* `Server` instance. Streamable HTTP deliberately cannot reuse that instance
|
|
7
|
-
* across requests (GHSA-345p-7cg4-v4c7), so the framework carries only the
|
|
8
|
-
* minimal session state needed by handler contexts through these hooks.
|
|
9
|
-
*
|
|
10
|
-
* @module src/mcp-server/protocolSession
|
|
11
|
-
*/
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=protocolSession.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocolSession.js","sourceRoot":"","sources":["../../src/mcp-server/protocolSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview A TaskMessageQueue wrapper that expires a task's queue on the
|
|
3
|
-
* same schedule as the task itself.
|
|
4
|
-
*
|
|
5
|
-
* The SDK's `InMemoryTaskMessageQueue` deletes a queue only in `dequeueAll`,
|
|
6
|
-
* which the SDK calls on `tasks/result` retrieval and `tasks/cancel`. Both
|
|
7
|
-
* `enqueue` and `dequeue` allocate-and-keep a queue for any taskId they touch,
|
|
8
|
-
* so a client that abandons a task — never fetching its result, never
|
|
9
|
-
* cancelling — strands that queue and any messages in it for the life of the
|
|
10
|
-
* process. Nothing in the SDK parallels the task store's TTL.
|
|
11
|
-
*
|
|
12
|
-
* @experimental These APIs are experimental and may change without notice.
|
|
13
|
-
* @module src/mcp-server/tasks/core/evictingTaskMessageQueue
|
|
14
|
-
*/
|
|
15
|
-
import type { QueuedMessage, TaskMessageQueue } from './taskTypes.js';
|
|
16
|
-
/**
|
|
17
|
-
* Wraps a {@link TaskMessageQueue} so each task's queue is reclaimed once its
|
|
18
|
-
* TTL elapses.
|
|
19
|
-
*
|
|
20
|
-
* Eviction is lazy and traffic-driven rather than timer-based: a deadline is
|
|
21
|
-
* refreshed whenever a task's queue is touched, expired queues are dropped on
|
|
22
|
-
* the next operation, and `dequeueAll` releases the deadline outright. That
|
|
23
|
-
* keeps the wrapper free of per-task timers and correct on runtimes where a
|
|
24
|
-
* timer would never fire.
|
|
25
|
-
*
|
|
26
|
-
* @experimental
|
|
27
|
-
*/
|
|
28
|
-
export declare class EvictingTaskMessageQueue implements TaskMessageQueue {
|
|
29
|
-
private readonly inner;
|
|
30
|
-
private readonly ttlMs;
|
|
31
|
-
private readonly deadlines;
|
|
32
|
-
/**
|
|
33
|
-
* @param inner - Queue to delegate to.
|
|
34
|
-
* @param ttlMs - Lifetime of an untouched queue. A non-positive value
|
|
35
|
-
* disables eviction, matching a task store configured without a TTL.
|
|
36
|
-
*/
|
|
37
|
-
constructor(inner: TaskMessageQueue, ttlMs: number);
|
|
38
|
-
private get evicts();
|
|
39
|
-
/**
|
|
40
|
-
* Drain queues whose deadline has passed, then extend `taskId`'s.
|
|
41
|
-
*
|
|
42
|
-
* `dequeueAll` is the inner queue's only delete path, so it doubles as the
|
|
43
|
-
* eviction primitive here — dropping the messages and the map entry in one
|
|
44
|
-
* call.
|
|
45
|
-
*/
|
|
46
|
-
private expireAndTouch;
|
|
47
|
-
enqueue(taskId: string, message: QueuedMessage, sessionId?: string, maxSize?: number): Promise<void>;
|
|
48
|
-
dequeue(taskId: string, sessionId?: string): Promise<QueuedMessage | undefined>;
|
|
49
|
-
dequeueAll(taskId: string, sessionId?: string): Promise<QueuedMessage[]>;
|
|
50
|
-
/** Number of queues currently tracked for eviction. Exposed for tests. */
|
|
51
|
-
get trackedCount(): number;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=evictingTaskMessageQueue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evictingTaskMessageQueue.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tasks/core/evictingTaskMessageQueue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,qBAAa,wBAAyB,YAAW,gBAAgB;IAS7D,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IATxB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IAEvD;;;;OAIG;IACH,YACmB,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,MAAM,EAC5B;IAEJ,OAAO,KAAK,MAAM,GAEjB;IAED;;;;;;OAMG;YACW,cAAc;IAatB,OAAO,CACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,EACtB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAGf;IAEK,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAGpF;IAEK,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAG7E;IAED,0EAA0E;IAC1E,IAAI,YAAY,IAAI,MAAM,CAEzB;CACF"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wraps a {@link TaskMessageQueue} so each task's queue is reclaimed once its
|
|
3
|
-
* TTL elapses.
|
|
4
|
-
*
|
|
5
|
-
* Eviction is lazy and traffic-driven rather than timer-based: a deadline is
|
|
6
|
-
* refreshed whenever a task's queue is touched, expired queues are dropped on
|
|
7
|
-
* the next operation, and `dequeueAll` releases the deadline outright. That
|
|
8
|
-
* keeps the wrapper free of per-task timers and correct on runtimes where a
|
|
9
|
-
* timer would never fire.
|
|
10
|
-
*
|
|
11
|
-
* @experimental
|
|
12
|
-
*/
|
|
13
|
-
export class EvictingTaskMessageQueue {
|
|
14
|
-
inner;
|
|
15
|
-
ttlMs;
|
|
16
|
-
deadlines = new Map();
|
|
17
|
-
/**
|
|
18
|
-
* @param inner - Queue to delegate to.
|
|
19
|
-
* @param ttlMs - Lifetime of an untouched queue. A non-positive value
|
|
20
|
-
* disables eviction, matching a task store configured without a TTL.
|
|
21
|
-
*/
|
|
22
|
-
constructor(inner, ttlMs) {
|
|
23
|
-
this.inner = inner;
|
|
24
|
-
this.ttlMs = ttlMs;
|
|
25
|
-
}
|
|
26
|
-
get evicts() {
|
|
27
|
-
return this.ttlMs > 0;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Drain queues whose deadline has passed, then extend `taskId`'s.
|
|
31
|
-
*
|
|
32
|
-
* `dequeueAll` is the inner queue's only delete path, so it doubles as the
|
|
33
|
-
* eviction primitive here — dropping the messages and the map entry in one
|
|
34
|
-
* call.
|
|
35
|
-
*/
|
|
36
|
-
async expireAndTouch(taskId) {
|
|
37
|
-
if (!this.evicts)
|
|
38
|
-
return;
|
|
39
|
-
const now = Date.now();
|
|
40
|
-
for (const [id, deadline] of this.deadlines) {
|
|
41
|
-
if (now < deadline)
|
|
42
|
-
continue;
|
|
43
|
-
this.deadlines.delete(id);
|
|
44
|
-
await this.inner.dequeueAll(id);
|
|
45
|
-
}
|
|
46
|
-
this.deadlines.set(taskId, now + this.ttlMs);
|
|
47
|
-
}
|
|
48
|
-
async enqueue(taskId, message, sessionId, maxSize) {
|
|
49
|
-
await this.expireAndTouch(taskId);
|
|
50
|
-
await this.inner.enqueue(taskId, message, sessionId, maxSize);
|
|
51
|
-
}
|
|
52
|
-
async dequeue(taskId, sessionId) {
|
|
53
|
-
await this.expireAndTouch(taskId);
|
|
54
|
-
return await this.inner.dequeue(taskId, sessionId);
|
|
55
|
-
}
|
|
56
|
-
async dequeueAll(taskId, sessionId) {
|
|
57
|
-
this.deadlines.delete(taskId);
|
|
58
|
-
return await this.inner.dequeueAll(taskId, sessionId);
|
|
59
|
-
}
|
|
60
|
-
/** Number of queues currently tracked for eviction. Exposed for tests. */
|
|
61
|
-
get trackedCount() {
|
|
62
|
-
return this.deadlines.size;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=evictingTaskMessageQueue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evictingTaskMessageQueue.js","sourceRoot":"","sources":["../../../../src/mcp-server/tasks/core/evictingTaskMessageQueue.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,wBAAwB;IAShB,KAAK;IACL,KAAK;IATP,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEvD;;;;OAIG;IACH,YACmB,KAAuB,EACvB,KAAa;qBADb,KAAK;qBACL,KAAK;IACrB,CAAC;IAEJ,IAAY,MAAM;QAChB,OAAO,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,cAAc,CAAC,MAAc;QACzC,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5C,IAAI,GAAG,GAAG,QAAQ;gBAAE,SAAS;YAC7B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC1B,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAAc,EACd,OAAsB,EACtB,SAAkB,EAClB,OAAgB;QAEhB,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,SAAkB;QAC9C,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAClC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,SAAkB;QACjD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxD,CAAC;IAED,0EAA0E;IAC1E,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview A TaskStore wrapper that enforces session ownership on top of
|
|
3
|
-
* the SDK's InMemoryTaskStore (which ignores sessionId parameters).
|
|
4
|
-
*
|
|
5
|
-
* This ensures that in HTTP mode, tasks created by one session cannot be
|
|
6
|
-
* accessed by another session, even when using the in-memory store.
|
|
7
|
-
*
|
|
8
|
-
* @experimental These APIs are experimental and may change without notice.
|
|
9
|
-
* @module src/mcp-server/tasks/core/sessionAwareTaskStore
|
|
10
|
-
*/
|
|
11
|
-
import type { Request, RequestId, Result } from '@modelcontextprotocol/sdk/types.js';
|
|
12
|
-
import { type CreateTaskOptions, type Task, type TaskStore } from './taskTypes.js';
|
|
13
|
-
/**
|
|
14
|
-
* Wraps an InMemoryTaskStore to add session ownership enforcement.
|
|
15
|
-
*
|
|
16
|
-
* Tracks which session created each task and rejects access from
|
|
17
|
-
* non-owning sessions. Tasks created without a sessionId are accessible
|
|
18
|
-
* by any session (backwards-compatible with stdio/unauth flows).
|
|
19
|
-
*
|
|
20
|
-
* @experimental
|
|
21
|
-
*/
|
|
22
|
-
export declare class SessionAwareTaskStore implements TaskStore {
|
|
23
|
-
private readonly inner;
|
|
24
|
-
/**
|
|
25
|
-
* Maps taskId -> owning sessionId and the deadline past which the row is
|
|
26
|
-
* reclaimable.
|
|
27
|
-
*
|
|
28
|
-
* The inner store drops a task once its TTL elapses, so an ownership row
|
|
29
|
-
* that outlives it is pure leak — one permanent entry per task call, since
|
|
30
|
-
* every HTTP request transport carries a sessionId. Mirroring the inner
|
|
31
|
-
* store's own expiry keeps this map's lifetime bounded by the tasks it
|
|
32
|
-
* describes. `Infinity` covers a task created without a TTL, which the
|
|
33
|
-
* inner store likewise never evicts.
|
|
34
|
-
*/
|
|
35
|
-
private readonly ownership;
|
|
36
|
-
constructor(inner: TaskStore);
|
|
37
|
-
/**
|
|
38
|
-
* Owning session for a task, or `undefined` when unowned or expired.
|
|
39
|
-
* Prunes the row on the way past — a lazy sweep costs one comparison on a
|
|
40
|
-
* path that is already touching the entry.
|
|
41
|
-
*/
|
|
42
|
-
private ownerOf;
|
|
43
|
-
/**
|
|
44
|
-
* Refresh a row's deadline, mirroring the inner store's TTL reset. The TTL
|
|
45
|
-
* is fixed when the task is created, so this needs no read of the inner
|
|
46
|
-
* store.
|
|
47
|
-
*/
|
|
48
|
-
private touch;
|
|
49
|
-
/** Drop every expired row. Runs on task creation, where the map grows. */
|
|
50
|
-
private sweepExpired;
|
|
51
|
-
createTask(taskParams: CreateTaskOptions, requestId: RequestId, request: Request, sessionId?: string): Promise<Task>;
|
|
52
|
-
getTask(taskId: string, sessionId?: string): Promise<Task | null>;
|
|
53
|
-
storeTaskResult(taskId: string, status: 'completed' | 'failed', result: Result, sessionId?: string): Promise<void>;
|
|
54
|
-
getTaskResult(taskId: string, sessionId?: string): Promise<Result>;
|
|
55
|
-
updateTaskStatus(taskId: string, status: Task['status'], statusMessage?: string, sessionId?: string): Promise<void>;
|
|
56
|
-
listTasks(cursor?: string, sessionId?: string): Promise<{
|
|
57
|
-
tasks: Task[];
|
|
58
|
-
nextCursor?: string;
|
|
59
|
-
}>;
|
|
60
|
-
/**
|
|
61
|
-
* Validates that the caller's session matches the task's owner.
|
|
62
|
-
* Tasks created without a sessionId are accessible by any session.
|
|
63
|
-
*
|
|
64
|
-
* Once the row expires this falls through rather than throwing, so a probe
|
|
65
|
-
* for an evicted taskId gets the inner store's uniform not-found instead of
|
|
66
|
-
* a `Forbidden` that would confirm the id had once existed.
|
|
67
|
-
*/
|
|
68
|
-
private assertOwnership;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=sessionAwareTaskStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionAwareTaskStore.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tasks/core/sessionAwareTaskStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAGrF,OAAO,EAAE,KAAK,iBAAiB,EAAc,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE/F;;;;;;;;GAQG;AACH,qBAAa,qBAAsB,YAAW,SAAS;IAiBzC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAhBlC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAGtB;IAEJ,YAA6B,KAAK,EAAE,SAAS,EAAI;IAEjD;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAUf;;;;OAIG;IACH,OAAO,CAAC,KAAK;IAMb,0EAA0E;IAC1E,OAAO,CAAC,YAAY;IAOd,UAAU,CACd,UAAU,EAAE,iBAAiB,EAC7B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAYf;IAEK,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAGtE;IAEK,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,GAAG,QAAQ,EAC9B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAMf;IAEK,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGvE;IAEK,gBAAgB,CACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAKf;IAEK,SAAS,CACb,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC;QAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAYjD;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;CAOxB"}
|