@cyanheads/mcp-ts-core 0.1.0-beta.12
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/CLAUDE.md +583 -0
- package/LICENSE +201 -0
- package/README.md +287 -0
- package/biome.json +103 -0
- package/dist/app.d.ts +82 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +222 -0
- package/dist/app.js.map +1 -0
- package/dist/cli/init.d.ts +8 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +161 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/config/index.d.ts +349 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +464 -0
- package/dist/config/index.js.map +1 -0
- package/dist/context.d.ts +119 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +144 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/prompts/prompt-registration.d.ts +33 -0
- package/dist/mcp-server/prompts/prompt-registration.d.ts.map +1 -0
- package/dist/mcp-server/prompts/prompt-registration.js +91 -0
- package/dist/mcp-server/prompts/prompt-registration.js.map +1 -0
- package/dist/mcp-server/prompts/utils/newPromptDefinition.d.ts +49 -0
- package/dist/mcp-server/prompts/utils/newPromptDefinition.d.ts.map +1 -0
- package/dist/mcp-server/prompts/utils/newPromptDefinition.js +39 -0
- package/dist/mcp-server/prompts/utils/newPromptDefinition.js.map +1 -0
- package/dist/mcp-server/prompts/utils/promptDefinition.d.ts +37 -0
- package/dist/mcp-server/prompts/utils/promptDefinition.d.ts.map +1 -0
- package/dist/mcp-server/prompts/utils/promptDefinition.js +2 -0
- package/dist/mcp-server/prompts/utils/promptDefinition.js.map +1 -0
- package/dist/mcp-server/resources/resource-registration.d.ts +27 -0
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -0
- package/dist/mcp-server/resources/resource-registration.js +85 -0
- package/dist/mcp-server/resources/resource-registration.js.map +1 -0
- package/dist/mcp-server/resources/utils/newResourceDefinition.d.ts +84 -0
- package/dist/mcp-server/resources/utils/newResourceDefinition.d.ts.map +1 -0
- package/dist/mcp-server/resources/utils/newResourceDefinition.js +40 -0
- package/dist/mcp-server/resources/utils/newResourceDefinition.js.map +1 -0
- package/dist/mcp-server/resources/utils/newResourceHandlerFactory.d.ts +32 -0
- package/dist/mcp-server/resources/utils/newResourceHandlerFactory.d.ts.map +1 -0
- package/dist/mcp-server/resources/utils/newResourceHandlerFactory.js +103 -0
- package/dist/mcp-server/resources/utils/newResourceHandlerFactory.js.map +1 -0
- package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +94 -0
- package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -0
- package/dist/mcp-server/resources/utils/resourceDefinition.js +2 -0
- package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -0
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +14 -0
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -0
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +111 -0
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -0
- package/dist/mcp-server/roots/roots-registration.d.ts +22 -0
- package/dist/mcp-server/roots/roots-registration.d.ts.map +1 -0
- package/dist/mcp-server/roots/roots-registration.js +25 -0
- package/dist/mcp-server/roots/roots-registration.js.map +1 -0
- package/dist/mcp-server/server.d.ts +34 -0
- package/dist/mcp-server/server.d.ts.map +1 -0
- package/dist/mcp-server/server.js +62 -0
- package/dist/mcp-server/server.js.map +1 -0
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts +42 -0
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.d.ts.map +1 -0
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js +70 -0
- package/dist/mcp-server/tasks/core/sessionAwareTaskStore.js.map +1 -0
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts +109 -0
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.d.ts.map +1 -0
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.js +209 -0
- package/dist/mcp-server/tasks/core/storageBackedTaskStore.js.map +1 -0
- package/dist/mcp-server/tasks/core/taskManager.d.ts +103 -0
- package/dist/mcp-server/tasks/core/taskManager.d.ts.map +1 -0
- package/dist/mcp-server/tasks/core/taskManager.js +144 -0
- package/dist/mcp-server/tasks/core/taskManager.js.map +1 -0
- package/dist/mcp-server/tasks/core/taskTypes.d.ts +11 -0
- package/dist/mcp-server/tasks/core/taskTypes.d.ts.map +1 -0
- package/dist/mcp-server/tasks/core/taskTypes.js +13 -0
- package/dist/mcp-server/tasks/core/taskTypes.js.map +1 -0
- package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts +108 -0
- package/dist/mcp-server/tasks/utils/taskToolDefinition.d.ts.map +1 -0
- package/dist/mcp-server/tasks/utils/taskToolDefinition.js +14 -0
- package/dist/mcp-server/tasks/utils/taskToolDefinition.js.map +1 -0
- package/dist/mcp-server/tools/tool-registration.d.ts +49 -0
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -0
- package/dist/mcp-server/tools/tool-registration.js +269 -0
- package/dist/mcp-server/tools/tool-registration.js.map +1 -0
- package/dist/mcp-server/tools/utils/newToolDefinition.d.ts +73 -0
- package/dist/mcp-server/tools/utils/newToolDefinition.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/newToolDefinition.js +45 -0
- package/dist/mcp-server/tools/utils/newToolDefinition.js.map +1 -0
- package/dist/mcp-server/tools/utils/newToolHandlerFactory.d.ts +33 -0
- package/dist/mcp-server/tools/utils/newToolHandlerFactory.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/newToolHandlerFactory.js +107 -0
- package/dist/mcp-server/tools/utils/newToolHandlerFactory.js.map +1 -0
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts +118 -0
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/toolDefinition.js +2 -0
- package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -0
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +34 -0
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +68 -0
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -0
- package/dist/mcp-server/transports/ITransport.d.ts +15 -0
- package/dist/mcp-server/transports/ITransport.d.ts.map +1 -0
- package/dist/mcp-server/transports/ITransport.js +2 -0
- package/dist/mcp-server/transports/ITransport.js.map +1 -0
- package/dist/mcp-server/transports/auth/authFactory.d.ts +11 -0
- package/dist/mcp-server/transports/auth/authFactory.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/authFactory.js +43 -0
- package/dist/mcp-server/transports/auth/authFactory.js.map +1 -0
- package/dist/mcp-server/transports/auth/authMiddleware.d.ts +24 -0
- package/dist/mcp-server/transports/auth/authMiddleware.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/authMiddleware.js +69 -0
- package/dist/mcp-server/transports/auth/authMiddleware.js.map +1 -0
- package/dist/mcp-server/transports/auth/lib/authContext.d.ts +34 -0
- package/dist/mcp-server/transports/auth/lib/authContext.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/lib/authContext.js +25 -0
- package/dist/mcp-server/transports/auth/lib/authContext.js.map +1 -0
- package/dist/mcp-server/transports/auth/lib/authTypes.d.ts +19 -0
- package/dist/mcp-server/transports/auth/lib/authTypes.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/lib/authTypes.js +2 -0
- package/dist/mcp-server/transports/auth/lib/authTypes.js.map +1 -0
- package/dist/mcp-server/transports/auth/lib/authUtils.d.ts +18 -0
- package/dist/mcp-server/transports/auth/lib/authUtils.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/lib/authUtils.js +64 -0
- package/dist/mcp-server/transports/auth/lib/authUtils.js.map +1 -0
- package/dist/mcp-server/transports/auth/lib/checkScopes.d.ts +25 -0
- package/dist/mcp-server/transports/auth/lib/checkScopes.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/lib/checkScopes.js +34 -0
- package/dist/mcp-server/transports/auth/lib/checkScopes.js.map +1 -0
- package/dist/mcp-server/transports/auth/lib/claimParser.d.ts +34 -0
- package/dist/mcp-server/transports/auth/lib/claimParser.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/lib/claimParser.js +58 -0
- package/dist/mcp-server/transports/auth/lib/claimParser.js.map +1 -0
- package/dist/mcp-server/transports/auth/lib/withAuth.d.ts +25 -0
- package/dist/mcp-server/transports/auth/lib/withAuth.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/lib/withAuth.js +30 -0
- package/dist/mcp-server/transports/auth/lib/withAuth.js.map +1 -0
- package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts +18 -0
- package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/strategies/authStrategy.js +2 -0
- package/dist/mcp-server/transports/auth/strategies/authStrategy.js.map +1 -0
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts +14 -0
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +86 -0
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -0
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts +14 -0
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -0
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +113 -0
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -0
- package/dist/mcp-server/transports/http/httpErrorHandler.d.ts +25 -0
- package/dist/mcp-server/transports/http/httpErrorHandler.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/httpErrorHandler.js +112 -0
- package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -0
- package/dist/mcp-server/transports/http/httpTransport.d.ts +47 -0
- package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/httpTransport.js +396 -0
- package/dist/mcp-server/transports/http/httpTransport.js.map +1 -0
- package/dist/mcp-server/transports/http/httpTypes.d.ts +17 -0
- package/dist/mcp-server/transports/http/httpTypes.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/httpTypes.js +2 -0
- package/dist/mcp-server/transports/http/httpTypes.js.map +1 -0
- package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts +21 -0
- package/dist/mcp-server/transports/http/protectedResourceMetadata.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/protectedResourceMetadata.js +44 -0
- package/dist/mcp-server/transports/http/protectedResourceMetadata.js.map +1 -0
- package/dist/mcp-server/transports/http/sessionIdUtils.d.ts +33 -0
- package/dist/mcp-server/transports/http/sessionIdUtils.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/sessionIdUtils.js +54 -0
- package/dist/mcp-server/transports/http/sessionIdUtils.js.map +1 -0
- package/dist/mcp-server/transports/http/sessionStore.d.ts +87 -0
- package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/sessionStore.js +209 -0
- package/dist/mcp-server/transports/http/sessionStore.js.map +1 -0
- package/dist/mcp-server/transports/manager.d.ts +22 -0
- package/dist/mcp-server/transports/manager.d.ts.map +1 -0
- package/dist/mcp-server/transports/manager.js +62 -0
- package/dist/mcp-server/transports/manager.js.map +1 -0
- package/dist/mcp-server/transports/stdio/stdioTransport.d.ts +44 -0
- package/dist/mcp-server/transports/stdio/stdioTransport.d.ts.map +1 -0
- package/dist/mcp-server/transports/stdio/stdioTransport.js +63 -0
- package/dist/mcp-server/transports/stdio/stdioTransport.js.map +1 -0
- package/dist/services/graph/core/GraphService.d.ts +205 -0
- package/dist/services/graph/core/GraphService.d.ts.map +1 -0
- package/dist/services/graph/core/GraphService.js +231 -0
- package/dist/services/graph/core/GraphService.js.map +1 -0
- package/dist/services/graph/core/IGraphProvider.d.ts +295 -0
- package/dist/services/graph/core/IGraphProvider.d.ts.map +1 -0
- package/dist/services/graph/core/IGraphProvider.js +8 -0
- package/dist/services/graph/core/IGraphProvider.js.map +1 -0
- package/dist/services/graph/types.d.ts +107 -0
- package/dist/services/graph/types.d.ts.map +1 -0
- package/dist/services/graph/types.js +8 -0
- package/dist/services/graph/types.js.map +1 -0
- package/dist/services/llm/core/ILlmProvider.d.ts +86 -0
- package/dist/services/llm/core/ILlmProvider.d.ts.map +1 -0
- package/dist/services/llm/core/ILlmProvider.js +2 -0
- package/dist/services/llm/core/ILlmProvider.js.map +1 -0
- package/dist/services/llm/providers/openrouter.provider.d.ts +187 -0
- package/dist/services/llm/providers/openrouter.provider.d.ts.map +1 -0
- package/dist/services/llm/providers/openrouter.provider.js +302 -0
- package/dist/services/llm/providers/openrouter.provider.js.map +1 -0
- package/dist/services/llm/types.d.ts +16 -0
- package/dist/services/llm/types.d.ts.map +1 -0
- package/dist/services/llm/types.js +9 -0
- package/dist/services/llm/types.js.map +1 -0
- package/dist/services/speech/core/ISpeechProvider.d.ts +92 -0
- package/dist/services/speech/core/ISpeechProvider.d.ts.map +1 -0
- package/dist/services/speech/core/ISpeechProvider.js +34 -0
- package/dist/services/speech/core/ISpeechProvider.js.map +1 -0
- package/dist/services/speech/core/SpeechService.d.ts +87 -0
- package/dist/services/speech/core/SpeechService.d.ts.map +1 -0
- package/dist/services/speech/core/SpeechService.js +135 -0
- package/dist/services/speech/core/SpeechService.js.map +1 -0
- package/dist/services/speech/providers/elevenlabs.provider.d.ts +77 -0
- package/dist/services/speech/providers/elevenlabs.provider.d.ts.map +1 -0
- package/dist/services/speech/providers/elevenlabs.provider.js +199 -0
- package/dist/services/speech/providers/elevenlabs.provider.js.map +1 -0
- package/dist/services/speech/providers/whisper.provider.d.ts +94 -0
- package/dist/services/speech/providers/whisper.provider.d.ts.map +1 -0
- package/dist/services/speech/providers/whisper.provider.js +240 -0
- package/dist/services/speech/providers/whisper.provider.js.map +1 -0
- package/dist/services/speech/types.d.ts +173 -0
- package/dist/services/speech/types.d.ts.map +1 -0
- package/dist/services/speech/types.js +8 -0
- package/dist/services/speech/types.js.map +1 -0
- package/dist/storage/core/IStorageProvider.d.ts +159 -0
- package/dist/storage/core/IStorageProvider.d.ts.map +1 -0
- package/dist/storage/core/IStorageProvider.js +2 -0
- package/dist/storage/core/IStorageProvider.js.map +1 -0
- package/dist/storage/core/StorageService.d.ts +22 -0
- package/dist/storage/core/StorageService.d.ts.map +1 -0
- package/dist/storage/core/StorageService.js +151 -0
- package/dist/storage/core/StorageService.js.map +1 -0
- package/dist/storage/core/storageFactory.d.ts +66 -0
- package/dist/storage/core/storageFactory.d.ts.map +1 -0
- package/dist/storage/core/storageFactory.js +122 -0
- package/dist/storage/core/storageFactory.js.map +1 -0
- package/dist/storage/core/storageValidation.d.ts +77 -0
- package/dist/storage/core/storageValidation.d.ts.map +1 -0
- package/dist/storage/core/storageValidation.js +303 -0
- package/dist/storage/core/storageValidation.js.map +1 -0
- package/dist/storage/providers/cloudflare/d1Provider.d.ts +94 -0
- package/dist/storage/providers/cloudflare/d1Provider.d.ts.map +1 -0
- package/dist/storage/providers/cloudflare/d1Provider.js +347 -0
- package/dist/storage/providers/cloudflare/d1Provider.js.map +1 -0
- package/dist/storage/providers/cloudflare/kvProvider.d.ts +21 -0
- package/dist/storage/providers/cloudflare/kvProvider.d.ts.map +1 -0
- package/dist/storage/providers/cloudflare/kvProvider.js +183 -0
- package/dist/storage/providers/cloudflare/kvProvider.js.map +1 -0
- package/dist/storage/providers/cloudflare/r2Provider.d.ts +28 -0
- package/dist/storage/providers/cloudflare/r2Provider.d.ts.map +1 -0
- package/dist/storage/providers/cloudflare/r2Provider.js +222 -0
- package/dist/storage/providers/cloudflare/r2Provider.js.map +1 -0
- package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts +20 -0
- package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts.map +1 -0
- package/dist/storage/providers/fileSystem/fileSystemProvider.js +282 -0
- package/dist/storage/providers/fileSystem/fileSystemProvider.js.map +1 -0
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +21 -0
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -0
- package/dist/storage/providers/inMemory/inMemoryProvider.js +139 -0
- package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -0
- package/dist/storage/providers/supabase/supabase.types.d.ts +49 -0
- package/dist/storage/providers/supabase/supabase.types.d.ts.map +1 -0
- package/dist/storage/providers/supabase/supabase.types.js +8 -0
- package/dist/storage/providers/supabase/supabase.types.js.map +1 -0
- package/dist/storage/providers/supabase/supabaseProvider.d.ts +24 -0
- package/dist/storage/providers/supabase/supabaseProvider.d.ts.map +1 -0
- package/dist/storage/providers/supabase/supabaseProvider.js +209 -0
- package/dist/storage/providers/supabase/supabaseProvider.js.map +1 -0
- package/dist/testing/index.d.ts +53 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +132 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types-global/errors.d.ts +83 -0
- package/dist/types-global/errors.d.ts.map +1 -0
- package/dist/types-global/errors.js +113 -0
- package/dist/types-global/errors.js.map +1 -0
- package/dist/utils/formatting/diffFormatter.d.ts +227 -0
- package/dist/utils/formatting/diffFormatter.d.ts.map +1 -0
- package/dist/utils/formatting/diffFormatter.js +369 -0
- package/dist/utils/formatting/diffFormatter.js.map +1 -0
- package/dist/utils/formatting/index.d.ts +9 -0
- package/dist/utils/formatting/index.d.ts.map +1 -0
- package/dist/utils/formatting/index.js +9 -0
- package/dist/utils/formatting/index.js.map +1 -0
- package/dist/utils/formatting/markdownBuilder.d.ts +543 -0
- package/dist/utils/formatting/markdownBuilder.d.ts.map +1 -0
- package/dist/utils/formatting/markdownBuilder.js +674 -0
- package/dist/utils/formatting/markdownBuilder.js.map +1 -0
- package/dist/utils/formatting/tableFormatter.d.ts +261 -0
- package/dist/utils/formatting/tableFormatter.d.ts.map +1 -0
- package/dist/utils/formatting/tableFormatter.js +456 -0
- package/dist/utils/formatting/tableFormatter.js.map +1 -0
- package/dist/utils/formatting/treeFormatter.d.ts +344 -0
- package/dist/utils/formatting/treeFormatter.d.ts.map +1 -0
- package/dist/utils/formatting/treeFormatter.js +400 -0
- package/dist/utils/formatting/treeFormatter.js.map +1 -0
- package/dist/utils/internal/encoding.d.ts +42 -0
- package/dist/utils/internal/encoding.d.ts.map +1 -0
- package/dist/utils/internal/encoding.js +87 -0
- package/dist/utils/internal/encoding.js.map +1 -0
- package/dist/utils/internal/error-handler/errorHandler.d.ts +140 -0
- package/dist/utils/internal/error-handler/errorHandler.d.ts.map +1 -0
- package/dist/utils/internal/error-handler/errorHandler.js +318 -0
- package/dist/utils/internal/error-handler/errorHandler.js.map +1 -0
- package/dist/utils/internal/error-handler/helpers.d.ts +98 -0
- package/dist/utils/internal/error-handler/helpers.d.ts.map +1 -0
- package/dist/utils/internal/error-handler/helpers.js +214 -0
- package/dist/utils/internal/error-handler/helpers.js.map +1 -0
- package/dist/utils/internal/error-handler/mappings.d.ts +85 -0
- package/dist/utils/internal/error-handler/mappings.d.ts.map +1 -0
- package/dist/utils/internal/error-handler/mappings.js +234 -0
- package/dist/utils/internal/error-handler/mappings.js.map +1 -0
- package/dist/utils/internal/error-handler/types.d.ts +160 -0
- package/dist/utils/internal/error-handler/types.d.ts.map +1 -0
- package/dist/utils/internal/error-handler/types.js +6 -0
- package/dist/utils/internal/error-handler/types.js.map +1 -0
- package/dist/utils/internal/health.d.ts +60 -0
- package/dist/utils/internal/health.d.ts.map +1 -0
- package/dist/utils/internal/health.js +46 -0
- package/dist/utils/internal/health.js.map +1 -0
- package/dist/utils/internal/logger.d.ts +300 -0
- package/dist/utils/internal/logger.d.ts.map +1 -0
- package/dist/utils/internal/logger.js +573 -0
- package/dist/utils/internal/logger.js.map +1 -0
- package/dist/utils/internal/performance.d.ts +78 -0
- package/dist/utils/internal/performance.d.ts.map +1 -0
- package/dist/utils/internal/performance.js +227 -0
- package/dist/utils/internal/performance.js.map +1 -0
- package/dist/utils/internal/requestContext.d.ts +200 -0
- package/dist/utils/internal/requestContext.d.ts.map +1 -0
- package/dist/utils/internal/requestContext.js +163 -0
- package/dist/utils/internal/requestContext.js.map +1 -0
- package/dist/utils/internal/runtime.d.ts +49 -0
- package/dist/utils/internal/runtime.d.ts.map +1 -0
- package/dist/utils/internal/runtime.js +90 -0
- package/dist/utils/internal/runtime.js.map +1 -0
- package/dist/utils/internal/startupBanner.d.ts +23 -0
- package/dist/utils/internal/startupBanner.d.ts.map +1 -0
- package/dist/utils/internal/startupBanner.js +34 -0
- package/dist/utils/internal/startupBanner.js.map +1 -0
- package/dist/utils/metrics/tokenCounter.d.ts +97 -0
- package/dist/utils/metrics/tokenCounter.d.ts.map +1 -0
- package/dist/utils/metrics/tokenCounter.js +162 -0
- package/dist/utils/metrics/tokenCounter.js.map +1 -0
- package/dist/utils/network/fetchWithTimeout.d.ts +91 -0
- package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -0
- package/dist/utils/network/fetchWithTimeout.js +305 -0
- package/dist/utils/network/fetchWithTimeout.js.map +1 -0
- package/dist/utils/pagination/pagination.d.ts +157 -0
- package/dist/utils/pagination/pagination.d.ts.map +1 -0
- package/dist/utils/pagination/pagination.js +191 -0
- package/dist/utils/pagination/pagination.js.map +1 -0
- package/dist/utils/parsing/csvParser.d.ts +84 -0
- package/dist/utils/parsing/csvParser.d.ts.map +1 -0
- package/dist/utils/parsing/csvParser.js +132 -0
- package/dist/utils/parsing/csvParser.js.map +1 -0
- package/dist/utils/parsing/dateParser.d.ts +103 -0
- package/dist/utils/parsing/dateParser.d.ts.map +1 -0
- package/dist/utils/parsing/dateParser.js +142 -0
- package/dist/utils/parsing/dateParser.js.map +1 -0
- package/dist/utils/parsing/frontmatterParser.d.ts +91 -0
- package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -0
- package/dist/utils/parsing/frontmatterParser.js +163 -0
- package/dist/utils/parsing/frontmatterParser.js.map +1 -0
- package/dist/utils/parsing/index.d.ts +15 -0
- package/dist/utils/parsing/index.d.ts.map +1 -0
- package/dist/utils/parsing/index.js +15 -0
- package/dist/utils/parsing/index.js.map +1 -0
- package/dist/utils/parsing/jsonParser.d.ts +115 -0
- package/dist/utils/parsing/jsonParser.d.ts.map +1 -0
- package/dist/utils/parsing/jsonParser.js +177 -0
- package/dist/utils/parsing/jsonParser.js.map +1 -0
- package/dist/utils/parsing/pdfParser.d.ts +563 -0
- package/dist/utils/parsing/pdfParser.d.ts.map +1 -0
- package/dist/utils/parsing/pdfParser.js +775 -0
- package/dist/utils/parsing/pdfParser.js.map +1 -0
- package/dist/utils/parsing/thinkBlock.d.ts +31 -0
- package/dist/utils/parsing/thinkBlock.d.ts.map +1 -0
- package/dist/utils/parsing/thinkBlock.js +31 -0
- package/dist/utils/parsing/thinkBlock.js.map +1 -0
- package/dist/utils/parsing/xmlParser.d.ts +69 -0
- package/dist/utils/parsing/xmlParser.d.ts.map +1 -0
- package/dist/utils/parsing/xmlParser.js +140 -0
- package/dist/utils/parsing/xmlParser.js.map +1 -0
- package/dist/utils/parsing/yamlParser.d.ts +64 -0
- package/dist/utils/parsing/yamlParser.d.ts.map +1 -0
- package/dist/utils/parsing/yamlParser.js +129 -0
- package/dist/utils/parsing/yamlParser.js.map +1 -0
- package/dist/utils/scheduling/scheduler.d.ts +174 -0
- package/dist/utils/scheduling/scheduler.d.ts.map +1 -0
- package/dist/utils/scheduling/scheduler.js +248 -0
- package/dist/utils/scheduling/scheduler.js.map +1 -0
- package/dist/utils/security/idGenerator.d.ts +189 -0
- package/dist/utils/security/idGenerator.d.ts.map +1 -0
- package/dist/utils/security/idGenerator.js +301 -0
- package/dist/utils/security/idGenerator.js.map +1 -0
- package/dist/utils/security/index.d.ts +8 -0
- package/dist/utils/security/index.d.ts.map +1 -0
- package/dist/utils/security/index.js +8 -0
- package/dist/utils/security/index.js.map +1 -0
- package/dist/utils/security/rateLimiter.d.ts +171 -0
- package/dist/utils/security/rateLimiter.d.ts.map +1 -0
- package/dist/utils/security/rateLimiter.js +294 -0
- package/dist/utils/security/rateLimiter.js.map +1 -0
- package/dist/utils/security/sanitization.d.ts +430 -0
- package/dist/utils/security/sanitization.d.ts.map +1 -0
- package/dist/utils/security/sanitization.js +759 -0
- package/dist/utils/security/sanitization.js.map +1 -0
- package/dist/utils/telemetry/index.d.ts +12 -0
- package/dist/utils/telemetry/index.d.ts.map +1 -0
- package/dist/utils/telemetry/index.js +12 -0
- package/dist/utils/telemetry/index.js.map +1 -0
- package/dist/utils/telemetry/instrumentation.d.ts +62 -0
- package/dist/utils/telemetry/instrumentation.d.ts.map +1 -0
- package/dist/utils/telemetry/instrumentation.js +223 -0
- package/dist/utils/telemetry/instrumentation.js.map +1 -0
- package/dist/utils/telemetry/metrics.d.ts +170 -0
- package/dist/utils/telemetry/metrics.d.ts.map +1 -0
- package/dist/utils/telemetry/metrics.js +205 -0
- package/dist/utils/telemetry/metrics.js.map +1 -0
- package/dist/utils/telemetry/semconv.d.ts +147 -0
- package/dist/utils/telemetry/semconv.d.ts.map +1 -0
- package/dist/utils/telemetry/semconv.js +159 -0
- package/dist/utils/telemetry/semconv.js.map +1 -0
- package/dist/utils/telemetry/trace.d.ts +141 -0
- package/dist/utils/telemetry/trace.d.ts.map +1 -0
- package/dist/utils/telemetry/trace.js +193 -0
- package/dist/utils/telemetry/trace.js.map +1 -0
- package/dist/utils/types/guards.d.ts +209 -0
- package/dist/utils/types/guards.d.ts.map +1 -0
- package/dist/utils/types/guards.js +229 -0
- package/dist/utils/types/guards.js.map +1 -0
- package/dist/utils/types/index.d.ts +6 -0
- package/dist/utils/types/index.d.ts.map +1 -0
- package/dist/utils/types/index.js +6 -0
- package/dist/utils/types/index.js.map +1 -0
- package/dist/worker.d.ts +59 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +216 -0
- package/dist/worker.js.map +1 -0
- package/package.json +377 -0
- package/skills/README.md +38 -0
- package/skills/add-export/SKILL.md +49 -0
- package/skills/add-prompt/SKILL.md +97 -0
- package/skills/add-provider/SKILL.md +53 -0
- package/skills/add-resource/SKILL.md +107 -0
- package/skills/add-service/SKILL.md +113 -0
- package/skills/add-tool/SKILL.md +110 -0
- package/skills/api-auth/SKILL.md +173 -0
- package/skills/api-config/SKILL.md +68 -0
- package/skills/api-context/SKILL.md +321 -0
- package/skills/api-errors/SKILL.md +146 -0
- package/skills/api-services/SKILL.md +24 -0
- package/skills/api-services/references/graph.md +124 -0
- package/skills/api-services/references/llm.md +46 -0
- package/skills/api-services/references/speech.md +72 -0
- package/skills/api-testing/SKILL.md +263 -0
- package/skills/api-utils/SKILL.md +106 -0
- package/skills/api-utils/references/formatting.md +237 -0
- package/skills/api-utils/references/parsing.md +263 -0
- package/skills/api-utils/references/security.md +226 -0
- package/skills/api-workers/SKILL.md +165 -0
- package/skills/devcheck/SKILL.md +31 -0
- package/skills/maintenance/SKILL.md +52 -0
- package/skills/migrate-mcp-ts-template/SKILL.md +131 -0
- package/skills/release/SKILL.md +67 -0
- package/skills/setup/SKILL.md +89 -0
- package/skills/walkthrough-init/SKILL.md +50 -0
- package/templates/.env.example +17 -0
- package/templates/AGENTS.md +113 -0
- package/templates/CLAUDE.md +113 -0
- package/templates/_tsconfig.json +33 -0
- package/templates/biome.template.json +43 -0
- package/templates/package.json +26 -0
- package/templates/src/index.ts +16 -0
- package/templates/src/mcp-server/prompts/definitions/echo.prompt.ts +19 -0
- package/templates/src/mcp-server/resources/definitions/echo.resource.ts +30 -0
- package/templates/src/mcp-server/tools/definitions/echo.tool.ts +24 -0
- package/templates/vitest.config.ts +12 -0
- package/tsconfig.base.json +44 -0
- package/vitest.config.base.ts +38 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-resource
|
|
3
|
+
description: >
|
|
4
|
+
Scaffold a new MCP resource definition. Use when the user asks to add a resource, expose data via URI, or create a readable endpoint.
|
|
5
|
+
metadata:
|
|
6
|
+
author: cyanheads
|
|
7
|
+
version: "1.0"
|
|
8
|
+
audience: external
|
|
9
|
+
type: reference
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
|
|
14
|
+
Resources use the `resource()` builder from `@cyanheads/mcp-ts-core`. Each resource lives in `src/mcp-server/resources/definitions/` with a `.resource.ts` suffix and is registered in the barrel `index.ts`.
|
|
15
|
+
|
|
16
|
+
For the full `resource()` API, pagination utilities, and `Context` interface, read:
|
|
17
|
+
|
|
18
|
+
node_modules/@cyanheads/mcp-ts-core/CLAUDE.md
|
|
19
|
+
|
|
20
|
+
## Steps
|
|
21
|
+
|
|
22
|
+
1. **Ask the user** for the resource's URI template, purpose, and data shape
|
|
23
|
+
2. **Design the URI** — use `{paramName}` for path parameters (e.g., `myscheme://{itemId}/data`)
|
|
24
|
+
3. **Create the file** at `src/mcp-server/resources/definitions/{{resource-name}}.resource.ts`
|
|
25
|
+
4. **Register** the resource in `src/mcp-server/resources/definitions/index.ts`
|
|
26
|
+
5. **Run `bun run devcheck`** to verify
|
|
27
|
+
6. **Smoke-test** with `bun run dev:stdio` or `dev:http`
|
|
28
|
+
|
|
29
|
+
## Template
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
/**
|
|
33
|
+
* @fileoverview {{RESOURCE_DESCRIPTION}}
|
|
34
|
+
* @module mcp-server/resources/definitions/{{RESOURCE_NAME}}
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import { z } from 'zod';
|
|
38
|
+
import { resource } from '@cyanheads/mcp-ts-core';
|
|
39
|
+
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
40
|
+
|
|
41
|
+
export const {{RESOURCE_EXPORT}} = resource('{{scheme}}://{{{paramName}}}/data', {
|
|
42
|
+
description: '{{RESOURCE_DESCRIPTION}}',
|
|
43
|
+
mimeType: 'application/json',
|
|
44
|
+
params: z.object({
|
|
45
|
+
{{paramName}}: z.string().describe('{{PARAM_DESCRIPTION}}'),
|
|
46
|
+
}),
|
|
47
|
+
// auth: ['resource:{{resource_name}}:read'],
|
|
48
|
+
|
|
49
|
+
async handler(params, ctx) {
|
|
50
|
+
ctx.log.debug('Fetching resource', { {{paramName}}: params.{{paramName}} });
|
|
51
|
+
// Pure logic — throw McpError on failure, no try/catch
|
|
52
|
+
return { /* resource data */ };
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
list: async () => ({
|
|
56
|
+
resources: [
|
|
57
|
+
{
|
|
58
|
+
uri: '{{scheme}}://all',
|
|
59
|
+
name: '{{RESOURCE_LIST_NAME}}',
|
|
60
|
+
mimeType: 'application/json',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### With pagination
|
|
68
|
+
|
|
69
|
+
For resources returning large lists, use opaque cursor pagination:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { extractCursor, paginateArray } from '@cyanheads/mcp-ts-core/utils/pagination';
|
|
73
|
+
|
|
74
|
+
async handler(params, ctx) {
|
|
75
|
+
const allItems = await fetchAllItems(params);
|
|
76
|
+
const cursor = extractCursor(params);
|
|
77
|
+
const page = paginateArray(allItems, cursor, 20, 100, ctx);
|
|
78
|
+
return {
|
|
79
|
+
items: page.items,
|
|
80
|
+
nextCursor: page.nextCursor,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Barrel registration
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// src/mcp-server/resources/definitions/index.ts
|
|
89
|
+
import { {{RESOURCE_EXPORT}} } from './{{resource-name}}.resource.js';
|
|
90
|
+
export const allResourceDefinitions = [
|
|
91
|
+
// ... existing resources
|
|
92
|
+
{{RESOURCE_EXPORT}},
|
|
93
|
+
];
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Checklist
|
|
97
|
+
|
|
98
|
+
- [ ] File created at `src/mcp-server/resources/definitions/{{resource-name}}.resource.ts`
|
|
99
|
+
- [ ] URI template uses `{paramName}` syntax for path parameters
|
|
100
|
+
- [ ] All Zod `params` fields have `.describe()` annotations
|
|
101
|
+
- [ ] JSDoc `@fileoverview` and `@module` header present
|
|
102
|
+
- [ ] `handler(params, ctx)` is pure — throws `McpError`, no try/catch
|
|
103
|
+
- [ ] `list()` function provided if the resource is discoverable
|
|
104
|
+
- [ ] Pagination used for large result sets (`extractCursor`/`paginateArray`)
|
|
105
|
+
- [ ] Registered in `definitions/index.ts` barrel and `allResourceDefinitions`
|
|
106
|
+
- [ ] `bun run devcheck` passes
|
|
107
|
+
- [ ] Smoke-tested with `bun run dev:stdio` or `dev:http`
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-service
|
|
3
|
+
description: >
|
|
4
|
+
Scaffold a new service integration. Use when the user asks to add a service, integrate an external API, or create a reusable domain module with its own initialization and state.
|
|
5
|
+
metadata:
|
|
6
|
+
author: cyanheads
|
|
7
|
+
version: "1.0"
|
|
8
|
+
audience: external
|
|
9
|
+
type: reference
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
|
|
14
|
+
Services use the init/accessor pattern: initialized once in `createApp`'s `setup()` callback, then accessed at request time via a lazy getter. Each service lives in `src/services/[domain]/` with an init function and accessor.
|
|
15
|
+
|
|
16
|
+
Service methods receive `Context` for correlated logging (`ctx.log`) and tenant-scoped storage (`ctx.state`). Convention: `ctx.elicit` and `ctx.sample` should only be called from tool handlers, not from services.
|
|
17
|
+
|
|
18
|
+
For the full service pattern, `CoreServices`, and `Context` interface, read:
|
|
19
|
+
|
|
20
|
+
node_modules/@cyanheads/mcp-ts-core/CLAUDE.md
|
|
21
|
+
|
|
22
|
+
## Steps
|
|
23
|
+
|
|
24
|
+
1. **Ask the user** for the service domain name and what it integrates with
|
|
25
|
+
2. **Create the directory** at `src/services/{{domain}}/`
|
|
26
|
+
3. **Create the service file** at `src/services/{{domain}}/{{domain}}-service.ts`
|
|
27
|
+
4. **Create types** at `src/services/{{domain}}/types.ts` if needed
|
|
28
|
+
5. **Register in `setup()`** in the server's entry point (`src/index.ts`)
|
|
29
|
+
6. **Run `bun run devcheck`** to verify
|
|
30
|
+
|
|
31
|
+
## Template
|
|
32
|
+
|
|
33
|
+
### Service file
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
/**
|
|
37
|
+
* @fileoverview {{SERVICE_DESCRIPTION}}
|
|
38
|
+
* @module services/{{domain}}/{{domain}}-service
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
import type { AppConfig } from '@cyanheads/mcp-ts-core/config';
|
|
42
|
+
import type { StorageService } from '@cyanheads/mcp-ts-core/storage';
|
|
43
|
+
import type { Context } from '@cyanheads/mcp-ts-core';
|
|
44
|
+
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
45
|
+
|
|
46
|
+
export class {{ServiceName}} {
|
|
47
|
+
constructor(
|
|
48
|
+
private readonly config: AppConfig,
|
|
49
|
+
private readonly storage: StorageService,
|
|
50
|
+
) {}
|
|
51
|
+
|
|
52
|
+
async doWork(input: string, ctx: Context): Promise<string> {
|
|
53
|
+
ctx.log.debug('Processing', { input });
|
|
54
|
+
// Domain logic here
|
|
55
|
+
return `result: ${input}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// --- Init/accessor pattern ---
|
|
60
|
+
|
|
61
|
+
let _service: {{ServiceName}} | undefined;
|
|
62
|
+
|
|
63
|
+
export function init{{ServiceName}}(config: AppConfig, storage: StorageService): void {
|
|
64
|
+
_service = new {{ServiceName}}(config, storage);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function get{{ServiceName}}(): {{ServiceName}} {
|
|
68
|
+
if (!_service) {
|
|
69
|
+
throw new McpError(
|
|
70
|
+
JsonRpcErrorCode.InitializationFailed,
|
|
71
|
+
'{{ServiceName}} not initialized',
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return _service;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Entry point registration
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// src/index.ts
|
|
82
|
+
import { createApp } from '@cyanheads/mcp-ts-core';
|
|
83
|
+
import { init{{ServiceName}} } from './services/{{domain}}/{{domain}}-service.js';
|
|
84
|
+
|
|
85
|
+
await createApp({
|
|
86
|
+
tools: allToolDefinitions,
|
|
87
|
+
resources: allResourceDefinitions,
|
|
88
|
+
prompts: allPromptDefinitions,
|
|
89
|
+
setup(core) {
|
|
90
|
+
init{{ServiceName}}(core.config, core.storage);
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Usage in tool handlers
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { get{{ServiceName}} } from '@/services/{{domain}}/{{domain}}-service.js';
|
|
99
|
+
|
|
100
|
+
handler: async (input, ctx) => {
|
|
101
|
+
return get{{ServiceName}}().doWork(input.query, ctx);
|
|
102
|
+
},
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Checklist
|
|
106
|
+
|
|
107
|
+
- [ ] Directory created at `src/services/{{domain}}/`
|
|
108
|
+
- [ ] Service file created with init/accessor pattern
|
|
109
|
+
- [ ] JSDoc `@fileoverview` and `@module` header present
|
|
110
|
+
- [ ] Service methods accept `Context` for logging and storage
|
|
111
|
+
- [ ] `init` function registered in `setup()` callback in `src/index.ts`
|
|
112
|
+
- [ ] Accessor throws `McpError(InitializationFailed)` if not initialized
|
|
113
|
+
- [ ] `bun run devcheck` passes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-tool
|
|
3
|
+
description: >
|
|
4
|
+
Scaffold a new MCP tool definition. Use when the user asks to add a tool, create a new tool, or implement a new capability for the server.
|
|
5
|
+
metadata:
|
|
6
|
+
author: cyanheads
|
|
7
|
+
version: "1.0"
|
|
8
|
+
audience: external
|
|
9
|
+
type: reference
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
|
|
14
|
+
Tools use the `tool()` builder from `@cyanheads/mcp-ts-core`. Each tool lives in `src/mcp-server/tools/definitions/` with a `.tool.ts` suffix and is registered in the barrel `index.ts`.
|
|
15
|
+
|
|
16
|
+
For the full `tool()` API, `Context` interface, and error codes, read:
|
|
17
|
+
|
|
18
|
+
node_modules/@cyanheads/mcp-ts-core/CLAUDE.md
|
|
19
|
+
|
|
20
|
+
## Steps
|
|
21
|
+
|
|
22
|
+
1. **Ask the user** for the tool's name, purpose, and input/output shape
|
|
23
|
+
2. **Determine if long-running** — if the tool involves streaming, polling, or
|
|
24
|
+
multi-step async work, it should use `task: true`
|
|
25
|
+
3. **Create the file** at `src/mcp-server/tools/definitions/{{tool-name}}.tool.ts`
|
|
26
|
+
4. **Register** the tool in `src/mcp-server/tools/definitions/index.ts`
|
|
27
|
+
5. **Run `bun run devcheck`** to verify
|
|
28
|
+
6. **Smoke-test** with `bun run dev:stdio` or `dev:http`
|
|
29
|
+
|
|
30
|
+
## Template
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
/**
|
|
34
|
+
* @fileoverview {{TOOL_DESCRIPTION}}
|
|
35
|
+
* @module mcp-server/tools/definitions/{{TOOL_NAME}}
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import { z } from 'zod';
|
|
39
|
+
import { tool } from '@cyanheads/mcp-ts-core';
|
|
40
|
+
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
41
|
+
|
|
42
|
+
export const {{TOOL_EXPORT}} = tool('{{tool_name}}', {
|
|
43
|
+
description: '{{TOOL_DESCRIPTION}}',
|
|
44
|
+
annotations: { readOnlyHint: true },
|
|
45
|
+
input: z.object({
|
|
46
|
+
// All fields need .describe()
|
|
47
|
+
}),
|
|
48
|
+
output: z.object({
|
|
49
|
+
// All fields need .describe()
|
|
50
|
+
}),
|
|
51
|
+
// auth: ['tool:{{tool_name}}:read'],
|
|
52
|
+
|
|
53
|
+
async handler(input, ctx) {
|
|
54
|
+
ctx.log.info('Processing', { /* relevant input fields */ });
|
|
55
|
+
// Pure logic — throw McpError on failure, no try/catch
|
|
56
|
+
return { /* output */ };
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
format: (result) => [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Task tool variant
|
|
64
|
+
|
|
65
|
+
Add `task: true` and use `ctx.progress` for long-running operations:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
export const {{TOOL_EXPORT}} = tool('{{tool_name}}', {
|
|
69
|
+
description: '{{TOOL_DESCRIPTION}}',
|
|
70
|
+
task: true,
|
|
71
|
+
input: z.object({ /* ... */ }),
|
|
72
|
+
|
|
73
|
+
async handler(input, ctx) {
|
|
74
|
+
await ctx.progress!.setTotal(totalSteps);
|
|
75
|
+
for (const step of steps) {
|
|
76
|
+
if (ctx.signal.aborted) break;
|
|
77
|
+
await ctx.progress!.update(`Processing: ${step}`);
|
|
78
|
+
// ... do work ...
|
|
79
|
+
await ctx.progress!.increment();
|
|
80
|
+
}
|
|
81
|
+
return { /* output */ };
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Barrel registration
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// src/mcp-server/tools/definitions/index.ts
|
|
90
|
+
export { {{TOOL_EXPORT}} } from './{{tool-name}}.tool.js';
|
|
91
|
+
|
|
92
|
+
// Add to allToolDefinitions array
|
|
93
|
+
import { {{TOOL_EXPORT}} } from './{{tool-name}}.tool.js';
|
|
94
|
+
export const allToolDefinitions = [
|
|
95
|
+
// ... existing tools
|
|
96
|
+
{{TOOL_EXPORT}},
|
|
97
|
+
];
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Checklist
|
|
101
|
+
|
|
102
|
+
- [ ] File created at `src/mcp-server/tools/definitions/{{tool-name}}.tool.ts`
|
|
103
|
+
- [ ] All Zod schema fields have `.describe()` annotations
|
|
104
|
+
- [ ] JSDoc `@fileoverview` and `@module` header present
|
|
105
|
+
- [ ] `handler(input, ctx)` is pure — throws `McpError`, no try/catch
|
|
106
|
+
- [ ] `auth` scopes declared if the tool needs authorization
|
|
107
|
+
- [ ] `task: true` added if the tool is long-running
|
|
108
|
+
- [ ] Registered in `definitions/index.ts` barrel and `allToolDefinitions`
|
|
109
|
+
- [ ] `bun run devcheck` passes
|
|
110
|
+
- [ ] Smoke-tested with `bun run dev:stdio` or `dev:http`
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-auth
|
|
3
|
+
description: >
|
|
4
|
+
Authentication, authorization, and multi-tenancy patterns for `@cyanheads/mcp-ts-core`. Use when implementing auth scopes on tools/resources, configuring auth modes (none/jwt/oauth), working with JWT/OAuth env vars, or understanding how tenantId flows through ctx.state.
|
|
5
|
+
metadata:
|
|
6
|
+
author: cyanheads
|
|
7
|
+
version: "1.0"
|
|
8
|
+
audience: external
|
|
9
|
+
type: reference
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
The framework handles auth at the handler factory level — tools and resources declare required scopes declaratively, and the framework enforces them before calling the handler. No try/catch or manual scope checking required for the common case.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Inline Auth (Primary Pattern)
|
|
19
|
+
|
|
20
|
+
Declare required scopes directly on the tool or resource definition via the `auth` property. The handler factory checks `ctx.auth.scopes` against these before calling `handler`.
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { tool } from '@cyanheads/mcp-ts-core';
|
|
24
|
+
|
|
25
|
+
const myTool = tool('my_tool', {
|
|
26
|
+
auth: ['tool:my_tool:read'],
|
|
27
|
+
async handler(input, ctx) {
|
|
28
|
+
// Only reached if caller has 'tool:my_tool:read' scope
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
When `MCP_AUTH_MODE=none`, auth checks are skipped and defaults are allowed.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Dynamic Auth
|
|
38
|
+
|
|
39
|
+
For runtime-computed scopes (e.g., scopes that depend on input values like a team or resource ID), use `checkScopes` from `@cyanheads/mcp-ts-core/auth` inside the handler:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { checkScopes } from '@cyanheads/mcp-ts-core/auth';
|
|
43
|
+
|
|
44
|
+
handler: async (input, ctx) => {
|
|
45
|
+
checkScopes(ctx, [`team:${input.teamId}:write`]);
|
|
46
|
+
// Continues only if scope is satisfied
|
|
47
|
+
},
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Signature:** `checkScopes(ctx: Context, requiredScopes: string[]): void`
|
|
51
|
+
|
|
52
|
+
**Throws:**
|
|
53
|
+
- `McpError(Forbidden)` — auth is active and one or more required scopes are missing
|
|
54
|
+
- `McpError(Unauthorized)` — auth is enabled but no auth context exists on the request
|
|
55
|
+
- No-ops when `MCP_AUTH_MODE=none`
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Auth Modes
|
|
60
|
+
|
|
61
|
+
Set via `MCP_AUTH_MODE` environment variable.
|
|
62
|
+
|
|
63
|
+
| Mode | Value | Behavior |
|
|
64
|
+
|:-----|:------|:---------|
|
|
65
|
+
| Disabled | `none` | No auth enforcement. All requests allowed. |
|
|
66
|
+
| JWT | `jwt` | Local secret verification via `MCP_AUTH_SECRET_KEY`. Requires explicit `DEV_MCP_AUTH_BYPASS=true` to bypass in development. |
|
|
67
|
+
| OAuth | `oauth` | JWKS verification against an external issuer. |
|
|
68
|
+
|
|
69
|
+
### JWT Config
|
|
70
|
+
|
|
71
|
+
| Variable | Required | Purpose |
|
|
72
|
+
|:---------|:---------|:--------|
|
|
73
|
+
| `MCP_AUTH_SECRET_KEY` | Yes (unless bypass) | Signing secret for HS256 JWT verification. Must be ≥ 32 characters. |
|
|
74
|
+
| `DEV_MCP_AUTH_BYPASS` | No | Set to `true` to skip JWT verification in development. Blocked in `NODE_ENV=production`. |
|
|
75
|
+
| `DEV_MCP_CLIENT_ID` | No | Client ID injected when bypass is active (default: `'dev-client-id'`). |
|
|
76
|
+
| `DEV_MCP_SCOPES` | No | Comma-separated scopes injected when bypass is active (default: `['dev-scope']`). |
|
|
77
|
+
|
|
78
|
+
**Important:** With `MCP_AUTH_MODE=jwt`, a missing `MCP_AUTH_SECRET_KEY` is a **fatal startup error** unless `DEV_MCP_AUTH_BYPASS=true` is explicitly set. Setting `DEV_MCP_AUTH_BYPASS` in production (`NODE_ENV=production`) is rejected at config parse time.
|
|
79
|
+
|
|
80
|
+
### OAuth Config
|
|
81
|
+
|
|
82
|
+
| Variable | Required | Purpose |
|
|
83
|
+
|:---------|:---------|:--------|
|
|
84
|
+
| `OAUTH_ISSUER_URL` | Yes | Token issuer URL (used for JWKS discovery) |
|
|
85
|
+
| `OAUTH_AUDIENCE` | Yes | Expected `aud` claim value |
|
|
86
|
+
| `OAUTH_JWKS_URI` | No | Override JWKS endpoint (defaults to `{issuer}/.well-known/jwks.json`) |
|
|
87
|
+
|
|
88
|
+
### JWT Claims Mapping
|
|
89
|
+
|
|
90
|
+
| Claim | JWT Field | Purpose |
|
|
91
|
+
|:------|:----------|:--------|
|
|
92
|
+
| `clientId` | `cid` / `client_id` | Identifies the calling client |
|
|
93
|
+
| `scopes` | `scp` / `scope` | Space-separated list of granted scopes |
|
|
94
|
+
| `sub` | `sub` | Subject (user or service identity) |
|
|
95
|
+
| `tenantId` | `tid` | Tenant identifier — drives `ctx.state` scoping |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Endpoints
|
|
100
|
+
|
|
101
|
+
| Endpoint | Protected |
|
|
102
|
+
|:---------|:----------|
|
|
103
|
+
| `GET /healthz` | No |
|
|
104
|
+
| `GET /mcp` | No |
|
|
105
|
+
| `POST /mcp` | Yes (when auth enabled) |
|
|
106
|
+
| `OPTIONS /mcp` | Yes (when auth enabled) |
|
|
107
|
+
|
|
108
|
+
**CORS:** Set `MCP_ALLOWED_ORIGINS` to a comma-separated list of allowed origins, or `*` for open access.
|
|
109
|
+
|
|
110
|
+
**Stdio mode:** No HTTP auth layer. Authorization is handled entirely by the host process.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Multi-Tenancy
|
|
115
|
+
|
|
116
|
+
`ctx.state` is automatically scoped to the current tenant — no manual key prefixing needed.
|
|
117
|
+
|
|
118
|
+
### tenantId Sources
|
|
119
|
+
|
|
120
|
+
| Transport | Source | Value |
|
|
121
|
+
|:----------|:-------|:------|
|
|
122
|
+
| HTTP with auth | JWT `tid` claim | Auto-propagated from token |
|
|
123
|
+
| Stdio | Hardcoded default | `'default'` |
|
|
124
|
+
|
|
125
|
+
### Tenant ID Validation Rules
|
|
126
|
+
|
|
127
|
+
- Max 128 characters
|
|
128
|
+
- Characters: alphanumeric, hyphens, underscores, dots
|
|
129
|
+
- Must start and end with an alphanumeric character
|
|
130
|
+
- No path traversal sequences (`../`)
|
|
131
|
+
- No consecutive dots (`..`)
|
|
132
|
+
|
|
133
|
+
### Using ctx.state
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
handler: async (input, ctx) => {
|
|
137
|
+
// Automatically scoped to ctx.tenantId — no manual prefixing
|
|
138
|
+
await ctx.state.set('item:123', JSON.stringify(data));
|
|
139
|
+
const value = await ctx.state.get('item:123');
|
|
140
|
+
await ctx.state.delete('item:123');
|
|
141
|
+
|
|
142
|
+
const page = await ctx.state.list('item:', { cursor, limit: 20 });
|
|
143
|
+
// page: { items: Array<{ key, value }>, cursor?: string }
|
|
144
|
+
},
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`ctx.state` throws `McpError(InvalidRequest)` if `tenantId` is missing. In stdio mode, `tenantId` defaults to `'default'` so `ctx.state` works without auth.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Auth Context Shape
|
|
152
|
+
|
|
153
|
+
Available on `ctx.auth` inside handlers (when auth is enabled):
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
interface AuthContext {
|
|
157
|
+
clientId: string; // Required — 'cid' or 'client_id' JWT claim
|
|
158
|
+
scopes: string[]; // Required — derived from 'scp' or 'scope' claim
|
|
159
|
+
sub: string; // Required — 'sub' claim; falls back to clientId when absent
|
|
160
|
+
token: string; // Required — raw JWT or OAuth bearer token string
|
|
161
|
+
tenantId?: string; // Optional — 'tid' claim; present only for multi-tenant tokens
|
|
162
|
+
[key: string]: unknown; // Additional token payload properties
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Access directly for conditional logic:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
handler: async (input, ctx) => {
|
|
170
|
+
const isAdmin = ctx.auth?.scopes.includes('admin:write') ?? false;
|
|
171
|
+
// ...
|
|
172
|
+
},
|
|
173
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-config
|
|
3
|
+
description: >
|
|
4
|
+
Reference for core and server configuration in `@cyanheads/mcp-ts-core`. Covers env var tables, priority order, server-specific Zod schema pattern, and Workers lazy-parsing requirement.
|
|
5
|
+
metadata:
|
|
6
|
+
author: cyanheads
|
|
7
|
+
version: "1.0"
|
|
8
|
+
audience: external
|
|
9
|
+
type: reference
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Configuration has two layers: **core config** (managed by the framework, env-driven) and **server config** (your own Zod schema for domain-specific env vars). Never merge them.
|
|
15
|
+
|
|
16
|
+
Import: `AppConfig`, `parseConfig` from `@cyanheads/mcp-ts-core/config`.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Core Config
|
|
21
|
+
|
|
22
|
+
Managed by `@cyanheads/mcp-ts-core`. Validated via Zod from environment variables.
|
|
23
|
+
|
|
24
|
+
**Priority (highest to lowest):**
|
|
25
|
+
|
|
26
|
+
1. `name`/`version` overrides passed to `createApp()` or `createWorkerHandler()`
|
|
27
|
+
2. Environment variables
|
|
28
|
+
3. `package.json` fields
|
|
29
|
+
|
|
30
|
+
| Category | Key Variables |
|
|
31
|
+
|:---------|:-------------|
|
|
32
|
+
| Transport | `MCP_TRANSPORT_TYPE` (`stdio`\|`http`), `MCP_HTTP_PORT`, `MCP_HTTP_HOST`, `MCP_HTTP_ENDPOINT_PATH` |
|
|
33
|
+
| Auth | `MCP_AUTH_MODE` (`none`\|`jwt`\|`oauth`), `MCP_AUTH_SECRET_KEY`, `OAUTH_*` |
|
|
34
|
+
| Storage | `STORAGE_PROVIDER_TYPE` (`in-memory`\|`filesystem`\|`supabase`\|`cloudflare-r2`\|`cloudflare-kv`\|`cloudflare-d1`) |
|
|
35
|
+
| LLM | `OPENROUTER_API_KEY`, `OPENROUTER_APP_URL/NAME`, `LLM_DEFAULT_*` |
|
|
36
|
+
| Telemetry | `OTEL_ENABLED`, `OTEL_SERVICE_NAME/VERSION`, `OTEL_EXPORTER_OTLP_*` |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Server Config (Separate Schema)
|
|
41
|
+
|
|
42
|
+
Servers define their own Zod schema for domain-specific env vars. **Never merge with core's schema.**
|
|
43
|
+
|
|
44
|
+
Use the lazy init/accessor pattern — do not parse `process.env` at module top-level.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
// src/config/server-config.ts
|
|
48
|
+
import { z } from 'zod';
|
|
49
|
+
|
|
50
|
+
const ServerConfigSchema = z.object({
|
|
51
|
+
myApiKey: z.string().describe('External API key'),
|
|
52
|
+
maxResults: z.coerce.number().default(100),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export type ServerConfig = z.infer<typeof ServerConfigSchema>;
|
|
56
|
+
|
|
57
|
+
let _config: ServerConfig | undefined;
|
|
58
|
+
|
|
59
|
+
export function getServerConfig(): ServerConfig {
|
|
60
|
+
_config ??= ServerConfigSchema.parse({
|
|
61
|
+
myApiKey: process.env.MY_API_KEY,
|
|
62
|
+
maxResults: process.env.MY_MAX_RESULTS,
|
|
63
|
+
});
|
|
64
|
+
return _config;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Workers warning:** Do not eagerly parse `process.env` at module top-level. In Workers, env bindings are injected at request time via `injectEnvVars()` — after all static imports. Lazy parsing is mandatory for Worker compatibility.
|