@1mcp/agent 0.32.1 → 0.33.0-beta1
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/build/auth/oauthAuthorizationFlow.d.ts +145 -0
- package/build/auth/oauthAuthorizationFlow.d.ts.map +1 -0
- package/build/auth/oauthAuthorizationFlow.js +257 -0
- package/build/auth/oauthAuthorizationFlow.js.map +1 -0
- package/build/auth/sdkOAuthServerProvider.d.ts +4 -0
- package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -1
- package/build/auth/sdkOAuthServerProvider.js +4 -0
- package/build/auth/sdkOAuthServerProvider.js.map +1 -1
- package/build/auth/storage/fileStorageService.d.ts.map +1 -1
- package/build/auth/storage/fileStorageService.js +9 -5
- package/build/auth/storage/fileStorageService.js.map +1 -1
- package/build/commands/cliSetup/setupFiles.d.ts +2 -4
- package/build/commands/cliSetup/setupFiles.d.ts.map +1 -1
- package/build/commands/cliSetup/setupFiles.js +8 -46
- package/build/commands/cliSetup/setupFiles.js.map +1 -1
- package/build/commands/inspect/inspect.d.ts +3 -0
- package/build/commands/inspect/inspect.d.ts.map +1 -1
- package/build/commands/inspect/inspect.js +90 -83
- package/build/commands/inspect/inspect.js.map +1 -1
- package/build/commands/instructions/instructions.d.ts.map +1 -1
- package/build/commands/instructions/instructions.js +11 -68
- package/build/commands/instructions/instructions.js.map +1 -1
- package/build/commands/mcp/install.d.ts.map +1 -1
- package/build/commands/mcp/install.js +62 -145
- package/build/commands/mcp/install.js.map +1 -1
- package/build/commands/mcp/installSource.d.ts +13 -0
- package/build/commands/mcp/installSource.d.ts.map +1 -0
- package/build/commands/mcp/installSource.js +69 -0
- package/build/commands/mcp/installSource.js.map +1 -0
- package/build/commands/mcp/uninstall.d.ts.map +1 -1
- package/build/commands/mcp/uninstall.js +20 -15
- package/build/commands/mcp/uninstall.js.map +1 -1
- package/build/commands/preset/edit.d.ts.map +1 -1
- package/build/commands/preset/edit.js +2 -0
- package/build/commands/preset/edit.js.map +1 -1
- package/build/commands/preset/interactive.d.ts.map +1 -1
- package/build/commands/preset/interactive.js +2 -0
- package/build/commands/preset/interactive.js.map +1 -1
- package/build/commands/preset/show.d.ts.map +1 -1
- package/build/commands/preset/show.js +2 -0
- package/build/commands/preset/show.js.map +1 -1
- package/build/commands/preset/test.d.ts.map +1 -1
- package/build/commands/preset/test.js +2 -0
- package/build/commands/preset/test.js.map +1 -1
- package/build/commands/proxy/proxy.d.ts.map +1 -1
- package/build/commands/proxy/proxy.js +11 -22
- package/build/commands/proxy/proxy.js.map +1 -1
- package/build/commands/registry/options.d.ts +14 -7
- package/build/commands/registry/options.d.ts.map +1 -1
- package/build/commands/registry/options.js +14 -7
- package/build/commands/registry/options.js.map +1 -1
- package/build/commands/run/run.d.ts +1 -0
- package/build/commands/run/run.d.ts.map +1 -1
- package/build/commands/run/run.js +124 -156
- package/build/commands/run/run.js.map +1 -1
- package/build/commands/serve/index.d.ts +5 -0
- package/build/commands/serve/index.d.ts.map +1 -1
- package/build/commands/serve/index.js +6 -1
- package/build/commands/serve/index.js.map +1 -1
- package/build/commands/serve/serve.d.ts +1 -0
- package/build/commands/serve/serve.d.ts.map +1 -1
- package/build/commands/serve/serve.js +5 -103
- package/build/commands/serve/serve.js.map +1 -1
- package/build/commands/serve/serveOptions.d.ts +6 -0
- package/build/commands/serve/serveOptions.d.ts.map +1 -0
- package/build/commands/serve/serveOptions.js +90 -0
- package/build/commands/serve/serveOptions.js.map +1 -0
- package/build/commands/shared/baseConfigUtils.d.ts +1 -25
- package/build/commands/shared/baseConfigUtils.d.ts.map +1 -1
- package/build/commands/shared/baseConfigUtils.js +3 -193
- package/build/commands/shared/baseConfigUtils.js.map +1 -1
- package/build/commands/shared/clientSurfaceAttachment.d.ts +131 -0
- package/build/commands/shared/clientSurfaceAttachment.d.ts.map +1 -0
- package/build/commands/shared/clientSurfaceAttachment.js +205 -0
- package/build/commands/shared/clientSurfaceAttachment.js.map +1 -0
- package/build/commands/shared/configParsingUtils.d.ts +9 -0
- package/build/commands/shared/configParsingUtils.d.ts.map +1 -0
- package/build/commands/shared/configParsingUtils.js +179 -0
- package/build/commands/shared/configParsingUtils.js.map +1 -0
- package/build/commands/shared/serveClient.d.ts.map +1 -1
- package/build/commands/shared/serveClient.js +35 -12
- package/build/commands/shared/serveClient.js.map +1 -1
- package/build/commands/shared/serveTargetResolver.d.ts.map +1 -1
- package/build/commands/shared/serveTargetResolver.js +42 -3
- package/build/commands/shared/serveTargetResolver.js.map +1 -1
- package/build/config/configLoader.d.ts +0 -1
- package/build/config/configLoader.d.ts.map +1 -1
- package/build/config/configLoader.js +12 -7
- package/build/config/configLoader.js.map +1 -1
- package/build/config/envProcessor.d.ts +3 -8
- package/build/config/envProcessor.d.ts.map +1 -1
- package/build/config/envProcessor.js +17 -34
- package/build/config/envProcessor.js.map +1 -1
- package/build/config/mcpConfigMerge.d.ts.map +1 -1
- package/build/config/mcpConfigMerge.js +15 -8
- package/build/config/mcpConfigMerge.js.map +1 -1
- package/build/constants/mcp.d.ts +1 -1
- package/build/constants/mcp.d.ts.map +1 -1
- package/build/constants/mcp.js +1 -1
- package/build/constants/mcp.js.map +1 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.d.ts +2 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.d.ts.map +1 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.js +4 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.js.map +1 -1
- package/build/core/capabilities/capabilityCatalog.d.ts +88 -0
- package/build/core/capabilities/capabilityCatalog.d.ts.map +1 -0
- package/build/core/capabilities/capabilityCatalog.js +235 -0
- package/build/core/capabilities/capabilityCatalog.js.map +1 -0
- package/build/core/capabilities/capabilityNotificationFacts.d.ts +9 -0
- package/build/core/capabilities/capabilityNotificationFacts.d.ts.map +1 -0
- package/build/core/capabilities/capabilityNotificationFacts.js +11 -0
- package/build/core/capabilities/capabilityNotificationFacts.js.map +1 -0
- package/build/core/capabilities/metaToolProvider.d.ts +2 -0
- package/build/core/capabilities/metaToolProvider.d.ts.map +1 -1
- package/build/core/capabilities/metaToolProvider.js +37 -77
- package/build/core/capabilities/metaToolProvider.js.map +1 -1
- package/build/core/capabilities/toolRegistry.d.ts +2 -1
- package/build/core/capabilities/toolRegistry.d.ts.map +1 -1
- package/build/core/capabilities/toolRegistry.js +2 -0
- package/build/core/capabilities/toolRegistry.js.map +1 -1
- package/build/core/configChangeHandler.d.ts +7 -2
- package/build/core/configChangeHandler.d.ts.map +1 -1
- package/build/core/configChangeHandler.js +47 -23
- package/build/core/configChangeHandler.js.map +1 -1
- package/build/core/filtering/filterSelection.d.ts +72 -0
- package/build/core/filtering/filterSelection.d.ts.map +1 -0
- package/build/core/filtering/filterSelection.js +262 -0
- package/build/core/filtering/filterSelection.js.map +1 -0
- package/build/core/instructions/instructionsDistribution.d.ts +52 -0
- package/build/core/instructions/instructionsDistribution.d.ts.map +1 -0
- package/build/core/instructions/instructionsDistribution.js +124 -0
- package/build/core/instructions/instructionsDistribution.js.map +1 -0
- package/build/core/loading/loadingStateTracker.d.ts +19 -0
- package/build/core/loading/loadingStateTracker.d.ts.map +1 -1
- package/build/core/loading/loadingStateTracker.js +37 -0
- package/build/core/loading/loadingStateTracker.js.map +1 -1
- package/build/core/loading/mcpLoadingManager.d.ts +103 -8
- package/build/core/loading/mcpLoadingManager.d.ts.map +1 -1
- package/build/core/loading/mcpLoadingManager.js +301 -31
- package/build/core/loading/mcpLoadingManager.js.map +1 -1
- package/build/core/protocol/notificationHandlers.js +2 -2
- package/build/core/protocol/notificationHandlers.js.map +1 -1
- package/build/core/protocol/promptRequestHandlers.d.ts +4 -0
- package/build/core/protocol/promptRequestHandlers.d.ts.map +1 -0
- package/build/core/protocol/promptRequestHandlers.js +64 -0
- package/build/core/protocol/promptRequestHandlers.js.map +1 -0
- package/build/core/protocol/requestHandlerUtils.d.ts +8 -0
- package/build/core/protocol/requestHandlerUtils.d.ts.map +1 -0
- package/build/core/protocol/requestHandlerUtils.js +48 -0
- package/build/core/protocol/requestHandlerUtils.js.map +1 -0
- package/build/core/protocol/requestHandlers.d.ts +2 -0
- package/build/core/protocol/requestHandlers.d.ts.map +1 -1
- package/build/core/protocol/requestHandlers.js +7 -391
- package/build/core/protocol/requestHandlers.js.map +1 -1
- package/build/core/protocol/resourceRequestHandlers.d.ts +3 -0
- package/build/core/protocol/resourceRequestHandlers.d.ts.map +1 -0
- package/build/core/protocol/resourceRequestHandlers.js +76 -0
- package/build/core/protocol/resourceRequestHandlers.js.map +1 -0
- package/build/core/protocol/toolRequestHandlers.d.ts +4 -0
- package/build/core/protocol/toolRequestHandlers.d.ts.map +1 -0
- package/build/core/protocol/toolRequestHandlers.js +132 -0
- package/build/core/protocol/toolRequestHandlers.js.map +1 -0
- package/build/core/server/adapters/TemplateServerAdapter.d.ts +0 -5
- package/build/core/server/adapters/TemplateServerAdapter.d.ts.map +1 -1
- package/build/core/server/adapters/TemplateServerAdapter.js +7 -30
- package/build/core/server/adapters/TemplateServerAdapter.js.map +1 -1
- package/build/core/server/clientInstanceFactory.d.ts +13 -0
- package/build/core/server/clientInstanceFactory.d.ts.map +1 -0
- package/build/core/server/clientInstanceFactory.js +32 -0
- package/build/core/server/clientInstanceFactory.js.map +1 -0
- package/build/core/server/clientInstancePool.d.ts +8 -49
- package/build/core/server/clientInstancePool.d.ts.map +1 -1
- package/build/core/server/clientInstancePool.js +61 -72
- package/build/core/server/clientInstancePool.js.map +1 -1
- package/build/core/server/clientInstancePoolTypes.d.ts +52 -0
- package/build/core/server/clientInstancePoolTypes.d.ts.map +1 -0
- package/build/core/server/clientInstancePoolTypes.js +10 -0
- package/build/core/server/clientInstancePoolTypes.js.map +1 -0
- package/build/core/server/connectionResolver.d.ts.map +1 -1
- package/build/core/server/connectionResolver.js +34 -31
- package/build/core/server/connectionResolver.js.map +1 -1
- package/build/core/server/mcpServerLifecycleManager.d.ts +9 -1
- package/build/core/server/mcpServerLifecycleManager.d.ts.map +1 -1
- package/build/core/server/mcpServerLifecycleManager.js +22 -0
- package/build/core/server/mcpServerLifecycleManager.js.map +1 -1
- package/build/core/server/requestContextPreparation.d.ts +38 -0
- package/build/core/server/requestContextPreparation.d.ts.map +1 -0
- package/build/core/server/requestContextPreparation.js +49 -0
- package/build/core/server/requestContextPreparation.js.map +1 -0
- package/build/core/server/serverManager.d.ts +8 -0
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +84 -2
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/server/templateIdentity.d.ts +44 -0
- package/build/core/server/templateIdentity.d.ts.map +1 -0
- package/build/core/server/templateIdentity.js +95 -0
- package/build/core/server/templateIdentity.js.map +1 -0
- package/build/core/server/templateServerCleanup.d.ts +23 -0
- package/build/core/server/templateServerCleanup.d.ts.map +1 -0
- package/build/core/server/templateServerCleanup.js +155 -0
- package/build/core/server/templateServerCleanup.js.map +1 -0
- package/build/core/server/templateServerManager.d.ts +12 -3
- package/build/core/server/templateServerManager.d.ts.map +1 -1
- package/build/core/server/templateServerManager.js +82 -127
- package/build/core/server/templateServerManager.js.map +1 -1
- package/build/core/tools/internal/adapters/installation/types.d.ts +16 -11
- package/build/core/tools/internal/adapters/installation/types.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/installationAdapter.d.ts +3 -13
- package/build/core/tools/internal/adapters/installationAdapter.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/installationAdapter.js +85 -69
- package/build/core/tools/internal/adapters/installationAdapter.js.map +1 -1
- package/build/core/tools/internal/installationHandlers.d.ts.map +1 -1
- package/build/core/tools/internal/installationHandlers.js +10 -4
- package/build/core/tools/internal/installationHandlers.js.map +1 -1
- package/build/core/tools/internal/integration.domainMocks.testSetup.d.ts +2 -0
- package/build/core/tools/internal/integration.domainMocks.testSetup.d.ts.map +1 -0
- package/build/core/tools/internal/integration.domainMocks.testSetup.js +66 -0
- package/build/core/tools/internal/integration.domainMocks.testSetup.js.map +1 -0
- package/build/core/tools/internal/integration.testSetup.d.ts +2 -0
- package/build/core/tools/internal/integration.testSetup.d.ts.map +1 -0
- package/build/core/tools/internal/integration.testSetup.js +469 -0
- package/build/core/tools/internal/integration.testSetup.js.map +1 -0
- package/build/core/tools/internal/schemas/index.d.ts +6 -0
- package/build/core/tools/internal/schemas/index.d.ts.map +1 -1
- package/build/core/tools/internal/schemas/installation.d.ts +6 -0
- package/build/core/tools/internal/schemas/installation.d.ts.map +1 -1
- package/build/core/tools/internal/schemas/installation.js +13 -1
- package/build/core/tools/internal/schemas/installation.js.map +1 -1
- package/build/domains/config-change/backupRetention.d.ts +14 -0
- package/build/domains/config-change/backupRetention.d.ts.map +1 -0
- package/build/domains/config-change/backupRetention.js +36 -0
- package/build/domains/config-change/backupRetention.js.map +1 -0
- package/build/domains/config-change/configChange.d.ts +4 -0
- package/build/domains/config-change/configChange.d.ts.map +1 -0
- package/build/domains/config-change/configChange.js +346 -0
- package/build/domains/config-change/configChange.js.map +1 -0
- package/build/domains/config-change/configLock.d.ts +6 -0
- package/build/domains/config-change/configLock.d.ts.map +1 -0
- package/build/domains/config-change/configLock.js +62 -0
- package/build/domains/config-change/configLock.js.map +1 -0
- package/build/domains/config-change/types.d.ts +64 -0
- package/build/domains/config-change/types.d.ts.map +1 -0
- package/build/domains/config-change/types.js +2 -0
- package/build/domains/config-change/types.js.map +1 -0
- package/build/domains/installation/index.d.ts +4 -3
- package/build/domains/installation/index.d.ts.map +1 -1
- package/build/domains/installation/index.js +5 -3
- package/build/domains/installation/index.js.map +1 -1
- package/build/domains/installation/serverInstallationSourceResolution.d.ts +6 -0
- package/build/domains/installation/serverInstallationSourceResolution.d.ts.map +1 -0
- package/build/domains/installation/serverInstallationSourceResolution.js +210 -0
- package/build/domains/installation/serverInstallationSourceResolution.js.map +1 -0
- package/build/domains/installation/serverInstallationTypes.d.ts +105 -0
- package/build/domains/installation/serverInstallationTypes.d.ts.map +1 -0
- package/build/domains/installation/serverInstallationTypes.js +2 -0
- package/build/domains/installation/serverInstallationTypes.js.map +1 -0
- package/build/domains/installation/serverInstallationWorkflow.d.ts +4 -0
- package/build/domains/installation/serverInstallationWorkflow.d.ts.map +1 -0
- package/build/domains/installation/serverInstallationWorkflow.js +148 -0
- package/build/domains/installation/serverInstallationWorkflow.js.map +1 -0
- package/build/domains/preset/manager/presetManager.d.ts +0 -4
- package/build/domains/preset/manager/presetManager.d.ts.map +1 -1
- package/build/domains/preset/manager/presetManager.js +19 -153
- package/build/domains/preset/manager/presetManager.js.map +1 -1
- package/build/domains/preset/manager/presetManagerCleanup.d.ts +15 -0
- package/build/domains/preset/manager/presetManagerCleanup.d.ts.map +1 -0
- package/build/domains/preset/manager/presetManagerCleanup.js +34 -0
- package/build/domains/preset/manager/presetManagerCleanup.js.map +1 -0
- package/build/domains/preset/manager/presetStorage.d.ts +4 -0
- package/build/domains/preset/manager/presetStorage.d.ts.map +1 -0
- package/build/domains/preset/manager/presetStorage.js +27 -0
- package/build/domains/preset/manager/presetStorage.js.map +1 -0
- package/build/domains/preset/manager/presetTesting.d.ts +8 -0
- package/build/domains/preset/manager/presetTesting.d.ts.map +1 -0
- package/build/domains/preset/manager/presetTesting.js +38 -0
- package/build/domains/preset/manager/presetTesting.js.map +1 -0
- package/build/domains/preset/manager/presetValidation.d.ts +3 -0
- package/build/domains/preset/manager/presetValidation.d.ts.map +1 -0
- package/build/domains/preset/manager/presetValidation.js +41 -0
- package/build/domains/preset/manager/presetValidation.js.map +1 -0
- package/build/domains/registry/cacheManager.d.ts.map +1 -1
- package/build/domains/registry/cacheManager.js +1 -0
- package/build/domains/registry/cacheManager.js.map +1 -1
- package/build/domains/registry/mcpRegistryClient.d.ts.map +1 -1
- package/build/domains/registry/mcpRegistryClient.js +2 -1
- package/build/domains/registry/mcpRegistryClient.js.map +1 -1
- package/build/server.d.ts.map +1 -1
- package/build/server.js +1 -0
- package/build/server.js.map +1 -1
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +3 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -1
- package/build/transport/http/middlewares/scopeAuthMiddleware.js +18 -28
- package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -1
- package/build/transport/http/middlewares/tagsExtractor.d.ts.map +1 -1
- package/build/transport/http/middlewares/tagsExtractor.js +46 -255
- package/build/transport/http/middlewares/tagsExtractor.js.map +1 -1
- package/build/transport/http/routes/cliTokenRoute.d.ts.map +1 -1
- package/build/transport/http/routes/cliTokenRoute.js +20 -14
- package/build/transport/http/routes/cliTokenRoute.js.map +1 -1
- package/build/transport/http/routes/inspectRequestContext.d.ts +5 -0
- package/build/transport/http/routes/inspectRequestContext.d.ts.map +1 -0
- package/build/transport/http/routes/inspectRequestContext.js +59 -0
- package/build/transport/http/routes/inspectRequestContext.js.map +1 -0
- package/build/transport/http/routes/inspectRoutes.d.ts +3 -3
- package/build/transport/http/routes/inspectRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/inspectRoutes.js +60 -83
- package/build/transport/http/routes/inspectRoutes.js.map +1 -1
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +99 -223
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts +2 -2
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +39 -84
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/routes/toolRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/toolRoutes.js +138 -39
- package/build/transport/http/routes/toolRoutes.js.map +1 -1
- package/build/transport/http/server.d.ts.map +1 -1
- package/build/transport/http/server.js +93 -0
- package/build/transport/http/server.js.map +1 -1
- package/build/transport/http/streamableSessionLifecycle.d.ts +90 -0
- package/build/transport/http/streamableSessionLifecycle.d.ts.map +1 -0
- package/build/transport/http/streamableSessionLifecycle.js +348 -0
- package/build/transport/http/streamableSessionLifecycle.js.map +1 -0
- package/build/transport/http/utils/contextExtractor.d.ts +1 -1
- package/build/transport/http/utils/contextExtractor.d.ts.map +1 -1
- package/build/transport/http/utils/contextExtractor.js +1 -33
- package/build/transport/http/utils/contextExtractor.js.map +1 -1
- package/build/transport/stdioProxyTransport.d.ts +1 -0
- package/build/transport/stdioProxyTransport.d.ts.map +1 -1
- package/build/transport/stdioProxyTransport.js +3 -0
- package/build/transport/stdioProxyTransport.js.map +1 -1
- package/build/transport/transportFactory.d.ts +1 -2
- package/build/transport/transportFactory.d.ts.map +1 -1
- package/build/transport/transportFactory.js +54 -4
- package/build/transport/transportFactory.js.map +1 -1
- package/build/transport/transportFactory.testSetup.d.ts +2 -0
- package/build/transport/transportFactory.testSetup.d.ts.map +1 -0
- package/build/transport/transportFactory.testSetup.js +83 -0
- package/build/transport/transportFactory.testSetup.js.map +1 -0
- package/build/utils/context/sessionIdentity.d.ts +9 -0
- package/build/utils/context/sessionIdentity.d.ts.map +1 -0
- package/build/utils/context/sessionIdentity.js +39 -0
- package/build/utils/context/sessionIdentity.js.map +1 -0
- package/build/utils/ui/interactiveSelector.d.ts +0 -25
- package/build/utils/ui/interactiveSelector.d.ts.map +1 -1
- package/build/utils/ui/interactiveSelector.js +12 -329
- package/build/utils/ui/interactiveSelector.js.map +1 -1
- package/build/utils/ui/interactiveSelectorPrompts.d.ts +7 -0
- package/build/utils/ui/interactiveSelectorPrompts.d.ts.map +1 -0
- package/build/utils/ui/interactiveSelectorPrompts.js +60 -0
- package/build/utils/ui/interactiveSelectorPrompts.js.map +1 -0
- package/build/utils/ui/interactiveSelectorQuery.d.ts +5 -0
- package/build/utils/ui/interactiveSelectorQuery.d.ts.map +1 -0
- package/build/utils/ui/interactiveSelectorQuery.js +67 -0
- package/build/utils/ui/interactiveSelectorQuery.js.map +1 -0
- package/build/utils/ui/interactiveSelectorTagUi.d.ts +7 -0
- package/build/utils/ui/interactiveSelectorTagUi.d.ts.map +1 -0
- package/build/utils/ui/interactiveSelectorTagUi.js +129 -0
- package/build/utils/ui/interactiveSelectorTagUi.js.map +1 -0
- package/package.json +2 -2
- package/build/transport/http/utils/sessionService.d.ts +0 -106
- package/build/transport/http/utils/sessionService.d.ts.map +0 -1
- package/build/transport/http/utils/sessionService.js +0 -342
- package/build/transport/http/utils/sessionService.js.map +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ReadResourceRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { MCP_URI_SEPARATOR } from '../../constants.js';
|
|
3
|
+
import { byCapabilities } from '../../core/filtering/clientFiltering.js';
|
|
4
|
+
import { FilteringService } from '../../core/filtering/filteringService.js';
|
|
5
|
+
import { withErrorHandling } from '../../utils/core/errorHandling.js';
|
|
6
|
+
import { buildUri, parseUri } from '../../utils/core/parsing.js';
|
|
7
|
+
import { getRequestTimeout } from '../../utils/core/timeoutUtils.js';
|
|
8
|
+
import { handlePagination } from '../../utils/ui/pagination.js';
|
|
9
|
+
import { filterConnectionsForSession, getRequestSession, resolveOutboundConnection } from './requestHandlerUtils.js';
|
|
10
|
+
export function registerResourceHandlers(outboundConns, inboundConn) {
|
|
11
|
+
const sessionId = getRequestSession(inboundConn);
|
|
12
|
+
inboundConn.server.setRequestHandler(ListResourcesRequestSchema, withErrorHandling(async (request) => {
|
|
13
|
+
const sessionFilteredConns = filterConnectionsForSession(outboundConns, sessionId);
|
|
14
|
+
const capabilityFilteredClients = byCapabilities({ resources: {} })(sessionFilteredConns);
|
|
15
|
+
const filteredClients = FilteringService.getFilteredConnections(capabilityFilteredClients, inboundConn);
|
|
16
|
+
const result = await handlePagination(filteredClients, request.params || {}, (client, params, opts) => client.listResources(params, opts), (outboundConn, result) => result.resources?.map((resource) => ({
|
|
17
|
+
...resource,
|
|
18
|
+
uri: buildUri(outboundConn.name, resource.uri, MCP_URI_SEPARATOR),
|
|
19
|
+
})) ?? [], inboundConn.enablePagination ?? false);
|
|
20
|
+
return {
|
|
21
|
+
resources: result.items,
|
|
22
|
+
nextCursor: result.nextCursor,
|
|
23
|
+
};
|
|
24
|
+
}, 'Error listing resources'));
|
|
25
|
+
inboundConn.server.setRequestHandler(ListResourceTemplatesRequestSchema, withErrorHandling(async (request) => {
|
|
26
|
+
const sessionFilteredConns = filterConnectionsForSession(outboundConns, sessionId);
|
|
27
|
+
const capabilityFilteredClients = byCapabilities({ resources: {} })(sessionFilteredConns);
|
|
28
|
+
const filteredClients = FilteringService.getFilteredConnections(capabilityFilteredClients, inboundConn);
|
|
29
|
+
const result = await handlePagination(filteredClients, request.params || {}, (client, params, opts) => client.listResourceTemplates(params, opts), (outboundConn, result) => result.resourceTemplates?.map((template) => ({
|
|
30
|
+
...template,
|
|
31
|
+
uriTemplate: buildUri(outboundConn.name, template.uriTemplate, MCP_URI_SEPARATOR),
|
|
32
|
+
})) ?? [], inboundConn.enablePagination ?? false);
|
|
33
|
+
return {
|
|
34
|
+
resourceTemplates: result.items,
|
|
35
|
+
nextCursor: result.nextCursor,
|
|
36
|
+
};
|
|
37
|
+
}, 'Error listing resource templates'));
|
|
38
|
+
inboundConn.server.setRequestHandler(SubscribeRequestSchema, withErrorHandling(async (request) => {
|
|
39
|
+
const { clientName, resourceName } = parseUri(request.params.uri, MCP_URI_SEPARATOR);
|
|
40
|
+
const outboundConn = resolveOutboundConnection(clientName, sessionId, outboundConns, inboundConn);
|
|
41
|
+
if (!outboundConn) {
|
|
42
|
+
throw new Error(`Unknown client: ${clientName}`);
|
|
43
|
+
}
|
|
44
|
+
return outboundConn.client.subscribeResource({ ...request.params, uri: resourceName }, {
|
|
45
|
+
timeout: getRequestTimeout(outboundConn.transport),
|
|
46
|
+
});
|
|
47
|
+
}, 'Error subscribing to resource'));
|
|
48
|
+
inboundConn.server.setRequestHandler(UnsubscribeRequestSchema, withErrorHandling(async (request) => {
|
|
49
|
+
const { clientName, resourceName } = parseUri(request.params.uri, MCP_URI_SEPARATOR);
|
|
50
|
+
const outboundConn = resolveOutboundConnection(clientName, sessionId, outboundConns, inboundConn);
|
|
51
|
+
if (!outboundConn) {
|
|
52
|
+
throw new Error(`Unknown client: ${clientName}`);
|
|
53
|
+
}
|
|
54
|
+
return outboundConn.client.unsubscribeResource({ ...request.params, uri: resourceName }, {
|
|
55
|
+
timeout: getRequestTimeout(outboundConn.transport),
|
|
56
|
+
});
|
|
57
|
+
}, 'Error unsubscribing from resource'));
|
|
58
|
+
inboundConn.server.setRequestHandler(ReadResourceRequestSchema, withErrorHandling(async (request) => {
|
|
59
|
+
const { clientName, resourceName } = parseUri(request.params.uri, MCP_URI_SEPARATOR);
|
|
60
|
+
const outboundConn = resolveOutboundConnection(clientName, sessionId, outboundConns, inboundConn);
|
|
61
|
+
if (!outboundConn) {
|
|
62
|
+
throw new Error(`Unknown client: ${clientName}`);
|
|
63
|
+
}
|
|
64
|
+
const resource = await outboundConn.client.readResource({ ...request.params, uri: resourceName }, {
|
|
65
|
+
timeout: getRequestTimeout(outboundConn.transport),
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
...resource,
|
|
69
|
+
contents: resource.contents.map((content) => ({
|
|
70
|
+
...content,
|
|
71
|
+
uri: buildUri(outboundConn.name, content.uri, MCP_URI_SEPARATOR),
|
|
72
|
+
})),
|
|
73
|
+
};
|
|
74
|
+
}, 'Error reading resource'));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=resourceRequestHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceRequestHandlers.js","sourceRoot":"","sources":["../../../src/core/protocol/resourceRequestHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,0BAA0B,EAE1B,kCAAkC,EAClC,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,cAAc,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boundConnections } from '../../core/types/index.js';
|
|
3
|
+
export declare function registerToolHandlers(outboundConns: OutboundConnections, inboundConn: InboundConnection, lazyLoadingOrchestrator?: LazyLoadingOrchestrator): void;
|
|
4
|
+
//# sourceMappingURL=toolRequestHandlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolRequestHandlers.d.ts","sourceRoot":"","sources":["../../../src/core/protocol/toolRequestHandlers.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAI5F,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAclF,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,mBAAmB,EAClC,WAAW,EAAE,iBAAiB,EAC9B,uBAAuB,CAAC,EAAE,uBAAuB,GAChD,IAAI,CA0IN"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { CallToolRequestSchema, CallToolResultSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { McpConfigManager } from '../../config/mcpConfigManager.js';
|
|
3
|
+
import { MCP_URI_SEPARATOR } from '../../constants.js';
|
|
4
|
+
import { InternalCapabilitiesProvider } from '../../core/capabilities/internalCapabilitiesProvider.js';
|
|
5
|
+
import { byCapabilities } from '../../core/filtering/clientFiltering.js';
|
|
6
|
+
import { FilteringService } from '../../core/filtering/filteringService.js';
|
|
7
|
+
import { getDisabledToolError } from '../../core/server/disabledTools.js';
|
|
8
|
+
import logger, { infoIf } from '../../logger/logger.js';
|
|
9
|
+
import { withErrorHandling } from '../../utils/core/errorHandling.js';
|
|
10
|
+
import { buildUri, parseUri } from '../../utils/core/parsing.js';
|
|
11
|
+
import { getRequestTimeout } from '../../utils/core/timeoutUtils.js';
|
|
12
|
+
import { createCapabilityCatalogFromConnections, filterConnectionsForSession, getRequestSession, resolveOutboundConnection, } from './requestHandlerUtils.js';
|
|
13
|
+
export function registerToolHandlers(outboundConns, inboundConn, lazyLoadingOrchestrator) {
|
|
14
|
+
const sessionId = getRequestSession(inboundConn);
|
|
15
|
+
const lazyLoadingEnabled = lazyLoadingOrchestrator?.isEnabled();
|
|
16
|
+
const getServerConfigs = () => McpConfigManager.getInstance().getTransportConfig();
|
|
17
|
+
inboundConn.server.setRequestHandler(ListToolsRequestSchema, withErrorHandling(async (request) => {
|
|
18
|
+
if (lazyLoadingEnabled && lazyLoadingOrchestrator) {
|
|
19
|
+
const sessionFilteredConns = filterConnectionsForSession(outboundConns, sessionId);
|
|
20
|
+
const capabilityFilteredClients = byCapabilities({ tools: {} })(sessionFilteredConns);
|
|
21
|
+
const filteredClients = FilteringService.getFilteredConnections(capabilityFilteredClients, inboundConn);
|
|
22
|
+
const filteredServerNames = new Set(Array.from(filteredClients.values()).map((conn) => conn.name));
|
|
23
|
+
infoIf(() => ({
|
|
24
|
+
message: 'Lazy loading: filtered servers',
|
|
25
|
+
meta: {
|
|
26
|
+
totalOutbound: outboundConns.size,
|
|
27
|
+
sessionFiltered: sessionFilteredConns.size,
|
|
28
|
+
capabilityFiltered: capabilityFilteredClients.size,
|
|
29
|
+
finalFiltered: filteredClients.size,
|
|
30
|
+
filteredServerNames: Array.from(filteredServerNames),
|
|
31
|
+
inboundConfig: {
|
|
32
|
+
tagFilterMode: inboundConn.tagFilterMode,
|
|
33
|
+
tags: inboundConn.tags,
|
|
34
|
+
tagExpression: inboundConn.tagExpression,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
const capabilities = await lazyLoadingOrchestrator.getCapabilitiesForFilteredServers(filteredServerNames, sessionId);
|
|
39
|
+
const internalProvider = InternalCapabilitiesProvider.getInstance();
|
|
40
|
+
await internalProvider.initialize();
|
|
41
|
+
const internalTools = internalProvider.getAvailableTools();
|
|
42
|
+
const lazyToolNames = ['tool_list', 'tool_schema', 'tool_invoke'];
|
|
43
|
+
const nonLazyTools = internalTools.filter((tool) => !lazyToolNames.includes(tool.name));
|
|
44
|
+
const internalToolsWithPrefix = nonLazyTools.map((tool) => ({
|
|
45
|
+
...tool,
|
|
46
|
+
name: buildUri('1mcp', tool.name, MCP_URI_SEPARATOR),
|
|
47
|
+
}));
|
|
48
|
+
return {
|
|
49
|
+
tools: [...capabilities.tools, ...internalToolsWithPrefix],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const sessionFilteredConns = filterConnectionsForSession(outboundConns, sessionId);
|
|
53
|
+
const capabilityFilteredClients = byCapabilities({ tools: {} })(sessionFilteredConns);
|
|
54
|
+
const filteredClients = FilteringService.getFilteredConnections(capabilityFilteredClients, inboundConn);
|
|
55
|
+
const catalog = await createCapabilityCatalogFromConnections(filteredClients, getServerConfigs);
|
|
56
|
+
const result = await catalog.listVisibleTools(request.params || {}, sessionId);
|
|
57
|
+
const internalProvider = InternalCapabilitiesProvider.getInstance();
|
|
58
|
+
await internalProvider.initialize();
|
|
59
|
+
const internalTools = internalProvider.getAvailableTools();
|
|
60
|
+
const internalToolsWithPrefix = internalTools.map((tool) => ({
|
|
61
|
+
...tool,
|
|
62
|
+
name: buildUri('1mcp', tool.name, MCP_URI_SEPARATOR),
|
|
63
|
+
}));
|
|
64
|
+
const externalTools = result.tools.map((tool) => ({
|
|
65
|
+
...tool,
|
|
66
|
+
name: buildUri(tool.server, tool.name, MCP_URI_SEPARATOR),
|
|
67
|
+
inputSchema: tool.inputSchema ?? { type: 'object' },
|
|
68
|
+
}));
|
|
69
|
+
return {
|
|
70
|
+
tools: [...externalTools, ...internalToolsWithPrefix],
|
|
71
|
+
nextCursor: result.nextCursor,
|
|
72
|
+
};
|
|
73
|
+
}, 'Error listing tools'));
|
|
74
|
+
inboundConn.server.setRequestHandler(CallToolRequestSchema, withErrorHandling(async (request) => {
|
|
75
|
+
const toolName = request.params.name;
|
|
76
|
+
const isUnprefixedMetaTool = lazyLoadingEnabled && lazyLoadingOrchestrator && lazyLoadingOrchestrator.isMetaTool(toolName);
|
|
77
|
+
if (isUnprefixedMetaTool && lazyLoadingOrchestrator) {
|
|
78
|
+
let result;
|
|
79
|
+
try {
|
|
80
|
+
result = await lazyLoadingOrchestrator.callMetaTool(toolName, request.params.arguments, sessionId);
|
|
81
|
+
}
|
|
82
|
+
catch (metaToolError) {
|
|
83
|
+
logger.error(`Meta-tool ${toolName} execution failed: ${metaToolError}`);
|
|
84
|
+
throw new Error(`Meta-tool ${toolName} failed: ${metaToolError instanceof Error ? metaToolError.message : String(metaToolError)}`);
|
|
85
|
+
}
|
|
86
|
+
return structuredToolResult(result);
|
|
87
|
+
}
|
|
88
|
+
if (lazyLoadingEnabled && !toolName.includes(MCP_URI_SEPARATOR)) {
|
|
89
|
+
return structuredToolResult({
|
|
90
|
+
error: {
|
|
91
|
+
type: 'not_found',
|
|
92
|
+
message: `Unknown tool: ${toolName}. In lazy loading mode, use meta-tools (tool_list, tool_schema, tool_invoke) to discover and call tools.`,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const { clientName, resourceName: extractedToolName } = parseUri(toolName, MCP_URI_SEPARATOR);
|
|
97
|
+
if (clientName === '1mcp') {
|
|
98
|
+
const internalProvider = InternalCapabilitiesProvider.getInstance();
|
|
99
|
+
await internalProvider.initialize();
|
|
100
|
+
const result = await internalProvider.executeTool(extractedToolName, request.params.arguments, sessionId);
|
|
101
|
+
return structuredToolResult(result);
|
|
102
|
+
}
|
|
103
|
+
const outboundConn = resolveOutboundConnection(clientName, sessionId, outboundConns, inboundConn);
|
|
104
|
+
if (!outboundConn) {
|
|
105
|
+
throw new Error(`Unknown client: ${clientName}`);
|
|
106
|
+
}
|
|
107
|
+
const disabledError = getDisabledToolError(getServerConfigs(), clientName, extractedToolName);
|
|
108
|
+
if (disabledError) {
|
|
109
|
+
return structuredToolResult({
|
|
110
|
+
error: {
|
|
111
|
+
type: disabledError.type,
|
|
112
|
+
message: disabledError.message,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return outboundConn.client.callTool({ ...request.params, name: extractedToolName }, CallToolResultSchema, {
|
|
117
|
+
timeout: getRequestTimeout(outboundConn.transport),
|
|
118
|
+
});
|
|
119
|
+
}, 'Error calling tool'));
|
|
120
|
+
}
|
|
121
|
+
function structuredToolResult(result) {
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: 'text',
|
|
126
|
+
text: JSON.stringify(result, null, 2),
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
structuredContent: result,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=toolRequestHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolRequestHandlers.js","sourceRoot":"","sources":["../../../src/core/protocol/toolRequestHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EAEpB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AAEtG,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAGzE,OAAO,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EACL,sCAAsC,EACtC,2BAA2B,EAC3B,iBAAiB,EACjB,yBAAyB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AAoB,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,YAAY,GAAG,yBAAyB,CAAC,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;QAClG,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,aAAa,GAAG,oBAAoB,CAAC,gBAAgB,EAAE,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;QAC9F,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,oBAAoB,CAAC;gBAC1B,KAAK,EAAE;oBACL,IAAI,EAAE,aAAa,CAAC,IAAI;oBACxB,OAAO,EAAE,aAAa,CAAC,OAAO;iBAC/B;aACF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,oBAAoB,EAAE;YACxG,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAAC,SAAS,CAAC;SACnD,CAAC,CAAC;IACL,CAAC,EAAE,oBAAoB,CAAC,CACzB,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAe;IAC3C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;QACD,iBAAiB,EAAE,MAAM;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -20,11 +20,6 @@ export declare class TemplateServerAdapter implements ServerAdapter {
|
|
|
20
20
|
private readonly templateManager;
|
|
21
21
|
readonly type = ServerType.Template;
|
|
22
22
|
constructor(name: string, config: MCPServerParams, outboundConns: OutboundConnections, templateManager: TemplateServerManager);
|
|
23
|
-
/**
|
|
24
|
-
* Build the possible connection keys for a session.
|
|
25
|
-
* Returns keys in priority order: session-scoped first, then hash-based.
|
|
26
|
-
*/
|
|
27
|
-
private buildConnectionKeys;
|
|
28
23
|
/**
|
|
29
24
|
* Resolve the outbound connection for this template server.
|
|
30
25
|
* Uses session-based resolution with hash lookup for shareable servers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateServerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/core/server/adapters/TemplateServerAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"TemplateServerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/core/server/adapters/TemplateServerAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIhE,OAAO,EAAiC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnH;;;;;;;;;;GAUG;AACH,qBAAa,qBAAsB,YAAW,aAAa;IAIvD,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IANlC,QAAQ,CAAC,IAAI,uBAAuB;gBAGzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,eAAe,EACf,aAAa,EAAE,mBAAmB,EAClC,eAAe,EAAE,qBAAqB;IAGzD;;;OAGG;IACH,iBAAiB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,kBAAkB,GAAG,SAAS;IA0B1E;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY;IAKhD;;OAEG;IACH,WAAW,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO;IAK7C;;;OAGG;IACH,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAQ9D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { debugIf
|
|
1
|
+
import { debugIf } from '../../../logger/logger.js';
|
|
2
|
+
import { ConnectionResolver } from '../connectionResolver.js';
|
|
2
3
|
import { mapClientStatusToServerStatus, ServerStatus, ServerType } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* TemplateServerAdapter handles template-based MCP servers with dynamic connections.
|
|
@@ -23,27 +24,6 @@ export class TemplateServerAdapter {
|
|
|
23
24
|
this.outboundConns = outboundConns;
|
|
24
25
|
this.templateManager = templateManager;
|
|
25
26
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Build the possible connection keys for a session.
|
|
28
|
-
* Returns keys in priority order: session-scoped first, then hash-based.
|
|
29
|
-
*/
|
|
30
|
-
buildConnectionKeys(sessionId) {
|
|
31
|
-
const keys = [`${this.name}:${sessionId}`];
|
|
32
|
-
try {
|
|
33
|
-
const renderedHash = this.templateManager.getRenderedHashForSession(sessionId, this.name);
|
|
34
|
-
if (renderedHash) {
|
|
35
|
-
keys.push(`${this.name}:${renderedHash}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
40
|
-
errorIf(() => ({
|
|
41
|
-
message: `Failed to get rendered hash for template server`,
|
|
42
|
-
meta: { serverName: this.name, sessionId, error: errorMessage },
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
return keys;
|
|
46
|
-
}
|
|
47
27
|
/**
|
|
48
28
|
* Resolve the outbound connection for this template server.
|
|
49
29
|
* Uses session-based resolution with hash lookup for shareable servers.
|
|
@@ -57,16 +37,13 @@ export class TemplateServerAdapter {
|
|
|
57
37
|
}));
|
|
58
38
|
return undefined;
|
|
59
39
|
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (conn) {
|
|
64
|
-
return conn;
|
|
65
|
-
}
|
|
40
|
+
const resolved = new ConnectionResolver(this.outboundConns, this.templateManager).resolveWithKey(this.name, sessionId);
|
|
41
|
+
if (resolved) {
|
|
42
|
+
return resolved.connection;
|
|
66
43
|
}
|
|
67
44
|
debugIf(() => ({
|
|
68
45
|
message: 'TemplateServerAdapter: No connection found for template server',
|
|
69
|
-
meta: { serverName: this.name, sessionId
|
|
46
|
+
meta: { serverName: this.name, sessionId },
|
|
70
47
|
}));
|
|
71
48
|
return undefined;
|
|
72
49
|
}
|
|
@@ -93,7 +70,7 @@ export class TemplateServerAdapter {
|
|
|
93
70
|
if (!sessionId) {
|
|
94
71
|
return undefined;
|
|
95
72
|
}
|
|
96
|
-
return this.
|
|
73
|
+
return new ConnectionResolver(this.outboundConns, this.templateManager).resolveWithKey(this.name, sessionId)?.key;
|
|
97
74
|
}
|
|
98
75
|
}
|
|
99
76
|
//# sourceMappingURL=TemplateServerAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateServerAdapter.js","sourceRoot":"","sources":["../../../../src/core/server/adapters/TemplateServerAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TemplateServerAdapter.js","sourceRoot":"","sources":["../../../../src/core/server/adapters/TemplateServerAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,O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;QAC7C,OAAO,IAAI,CAAC,CAAC,CAAC,6BAA6B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;IACvF,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAAuB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,MAAM,KAAK,YAAY,CAAC,SAAS,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,OAAuB;QACtC,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,CAAC;QACrC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC;IACpH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MCPServerParams } from '../../core/types/transport.js';
|
|
2
|
+
import type { PooledClientInstance } from './clientInstancePoolTypes.js';
|
|
3
|
+
export interface CreatePooledInstanceParams {
|
|
4
|
+
instanceId: string;
|
|
5
|
+
instanceKey: string;
|
|
6
|
+
templateName: string;
|
|
7
|
+
processedConfig: MCPServerParams;
|
|
8
|
+
renderedHash: string;
|
|
9
|
+
clientId: string;
|
|
10
|
+
idleTimeout: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function createPooledClientInstance({ instanceId, instanceKey, templateName, processedConfig, renderedHash, clientId, idleTimeout, }: CreatePooledInstanceParams): Promise<PooledClientInstance>;
|
|
13
|
+
//# sourceMappingURL=clientInstanceFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientInstanceFactory.d.ts","sourceRoot":"","sources":["../../../src/core/server/clientInstanceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,eAAe,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,0BAA0B,CAAC,EAC/C,UAAU,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,WAAW,GACZ,EAAE,0BAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmC5D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createTransportsWithContext } from '../../transport/transportFactory.js';
|
|
2
|
+
import { getConnectionTimeout } from '../../utils/core/timeoutUtils.js';
|
|
3
|
+
export async function createPooledClientInstance({ instanceId, instanceKey, templateName, processedConfig, renderedHash, clientId, idleTimeout, }) {
|
|
4
|
+
const transports = await createTransportsWithContext({
|
|
5
|
+
[templateName]: processedConfig,
|
|
6
|
+
}, undefined);
|
|
7
|
+
const transport = transports[templateName];
|
|
8
|
+
if (!transport) {
|
|
9
|
+
throw new Error(`Failed to create transport for template ${templateName}`);
|
|
10
|
+
}
|
|
11
|
+
const { ClientManager } = await import('../../core/client/clientManager.js');
|
|
12
|
+
const clientManager = ClientManager.getOrCreateInstance();
|
|
13
|
+
const client = clientManager.createPooledClientInstance();
|
|
14
|
+
const connectionTimeout = getConnectionTimeout(transport);
|
|
15
|
+
await client.connect(transport, connectionTimeout ? { timeout: connectionTimeout } : undefined);
|
|
16
|
+
return {
|
|
17
|
+
id: instanceId,
|
|
18
|
+
instanceKey,
|
|
19
|
+
templateName,
|
|
20
|
+
client,
|
|
21
|
+
transport,
|
|
22
|
+
renderedHash,
|
|
23
|
+
processedConfig,
|
|
24
|
+
referenceCount: 1,
|
|
25
|
+
createdAt: new Date(),
|
|
26
|
+
lastUsedAt: new Date(),
|
|
27
|
+
status: 'active',
|
|
28
|
+
clientIds: new Set([clientId]),
|
|
29
|
+
idleTimeout,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=clientInstanceFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientInstanceFactory.js","sourceRoot":"","sources":["../../../src/core/server/clientInstanceFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAcvE,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,EAC/C,UAAU,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,WAAW,GACgB;IAC3B,MAAM,UAAU,GAAG,MAAM,2BAA2B,CAClD;QACE,CAAC,YAAY,CAAC,EAAE,eAAe;KAChC,EACD,SAAS,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,2CAA2C,YAAY,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,mCAAmC,CAAC,CAAC;IAC5E,MAAM,aAAa,GAAG,aAAa,CAAC,mBAAmB,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,aAAa,CAAC,0BAA0B,EAAE,CAAC;IAE1D,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC1D,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEhG,OAAO;QACL,EAAE,EAAE,UAAU;QACd,WAAW;QACX,YAAY;QACZ,MAAM;QACN,SAAS;QACT,YAAY;QACZ,eAAe;QACf,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,IAAI,IAAI,EAAE;QACrB,UAAU,EAAE,IAAI,IAAI,EAAE;QACtB,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC9B,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -1,49 +1,7 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
import { AuthProviderTransport } from '../../core/types/index.js';
|
|
3
1
|
import type { MCPServerParams } from '../../core/types/transport.js';
|
|
4
2
|
import type { ContextData } from '../../types/context.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export interface ClientPoolOptions {
|
|
9
|
-
/** Maximum number of instances per template (0 = unlimited) */
|
|
10
|
-
maxInstances?: number;
|
|
11
|
-
/** Time in milliseconds to wait before terminating idle instances */
|
|
12
|
-
idleTimeout?: number;
|
|
13
|
-
/** Interval in milliseconds to run cleanup checks */
|
|
14
|
-
cleanupInterval?: number;
|
|
15
|
-
/** Maximum total instances across all templates (0 = unlimited) */
|
|
16
|
-
maxTotalInstances?: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Represents a pooled client instance connected to an upstream MCP server
|
|
20
|
-
*/
|
|
21
|
-
export interface PooledClientInstance {
|
|
22
|
-
/** Unique identifier for this instance */
|
|
23
|
-
id: string;
|
|
24
|
-
/** Name of the template this instance was created from */
|
|
25
|
-
templateName: string;
|
|
26
|
-
/** MCP client instance */
|
|
27
|
-
client: Client;
|
|
28
|
-
/** Transport connected to upstream server */
|
|
29
|
-
transport: AuthProviderTransport;
|
|
30
|
-
/** Hash of the rendered configuration used to create this instance */
|
|
31
|
-
renderedHash: string;
|
|
32
|
-
/** Processed server configuration */
|
|
33
|
-
processedConfig: MCPServerParams;
|
|
34
|
-
/** Number of clients currently connected to this instance */
|
|
35
|
-
referenceCount: number;
|
|
36
|
-
/** Timestamp when this instance was created */
|
|
37
|
-
createdAt: Date;
|
|
38
|
-
/** Timestamp of last client activity */
|
|
39
|
-
lastUsedAt: Date;
|
|
40
|
-
/** Current status of the instance */
|
|
41
|
-
status: 'active' | 'idle' | 'terminating';
|
|
42
|
-
/** Set of client IDs connected to this instance */
|
|
43
|
-
clientIds: Set<string>;
|
|
44
|
-
/** Template-specific idle timeout */
|
|
45
|
-
idleTimeout: number;
|
|
46
|
-
}
|
|
3
|
+
import { ClientPoolOptions, PooledClientInstance } from './clientInstancePoolTypes.js';
|
|
4
|
+
export type { ClientPoolOptions, PooledClientInstance };
|
|
47
5
|
/**
|
|
48
6
|
* Manages a pool of MCP client instances created from templates
|
|
49
7
|
*
|
|
@@ -59,6 +17,7 @@ export declare class ClientInstancePool {
|
|
|
59
17
|
private options;
|
|
60
18
|
private cleanupTimer?;
|
|
61
19
|
private instanceCounter;
|
|
20
|
+
private pendingCreations;
|
|
62
21
|
constructor(options?: Partial<ClientPoolOptions>);
|
|
63
22
|
/**
|
|
64
23
|
* Creates or retrieves a client instance for the given template and variables
|
|
@@ -75,11 +34,15 @@ export declare class ClientInstancePool {
|
|
|
75
34
|
/**
|
|
76
35
|
* Removes a client from an instance
|
|
77
36
|
*/
|
|
78
|
-
removeClientFromInstance(instanceKey: string, clientId: string): void;
|
|
37
|
+
removeClientFromInstance(instanceKey: string, clientId: string, idleSince?: Date): void;
|
|
79
38
|
/**
|
|
80
39
|
* Gets an instance by its key
|
|
81
40
|
*/
|
|
82
41
|
getInstance(instanceKey: string): PooledClientInstance | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Gets an instance key by its generated instance ID
|
|
44
|
+
*/
|
|
45
|
+
getInstanceKeyById(instanceId: string): string | undefined;
|
|
83
46
|
/**
|
|
84
47
|
* Gets all instances for a specific template
|
|
85
48
|
*/
|
|
@@ -110,10 +73,6 @@ export declare class ClientInstancePool {
|
|
|
110
73
|
templateCount: number;
|
|
111
74
|
totalClients: number;
|
|
112
75
|
};
|
|
113
|
-
/**
|
|
114
|
-
* Creates a new client instance and connects to upstream server
|
|
115
|
-
*/
|
|
116
|
-
private createNewInstance;
|
|
117
76
|
/**
|
|
118
77
|
* Gets template configuration with proper defaults
|
|
119
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientInstancePool.d.ts","sourceRoot":"","sources":["../../../src/core/server/clientInstancePool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clientInstancePool.d.ts","sourceRoot":"","sources":["../../../src/core/server/clientInstancePool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,iBAAiB,EAAwB,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAE7G,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,CAAC;AAExD;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,mBAAmB,CAAkC;IAC7D,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,YAAY,CAAC,CAAiC;IACtD,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,gBAAgB,CAAoD;gBAEhE,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAM;IAUpD;;OAEG;IACG,yBAAyB,CAC7B,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC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