@1mcp/agent 0.28.0 → 0.29.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/sessionTypes.d.ts +19 -0
- package/build/auth/sessionTypes.d.ts.map +1 -1
- package/build/commands/app/backups.d.ts.map +1 -1
- package/build/commands/app/backups.js +52 -42
- package/build/commands/app/backups.js.map +1 -1
- package/build/commands/app/consolidate.d.ts.map +1 -1
- package/build/commands/app/consolidate.js +66 -55
- package/build/commands/app/consolidate.js.map +1 -1
- package/build/commands/app/discover.d.ts.map +1 -1
- package/build/commands/app/discover.js +32 -25
- package/build/commands/app/discover.js.map +1 -1
- package/build/commands/app/index.d.ts.map +1 -1
- package/build/commands/app/index.js +2 -1
- package/build/commands/app/index.js.map +1 -1
- package/build/commands/app/list.d.ts.map +1 -1
- package/build/commands/app/list.js +35 -28
- package/build/commands/app/list.js.map +1 -1
- package/build/commands/app/restore.d.ts.map +1 -1
- package/build/commands/app/restore.js +74 -63
- package/build/commands/app/restore.js.map +1 -1
- package/build/commands/app/status.d.ts.map +1 -1
- package/build/commands/app/status.js +51 -43
- package/build/commands/app/status.js.map +1 -1
- package/build/commands/mcp/add.d.ts.map +1 -1
- package/build/commands/mcp/add.js +29 -23
- package/build/commands/mcp/add.js.map +1 -1
- package/build/commands/mcp/enable.d.ts.map +1 -1
- package/build/commands/mcp/enable.js +16 -15
- package/build/commands/mcp/enable.js.map +1 -1
- package/build/commands/mcp/index.d.ts.map +1 -1
- package/build/commands/mcp/index.js +2 -1
- package/build/commands/mcp/index.js.map +1 -1
- package/build/commands/mcp/install.d.ts.map +1 -1
- package/build/commands/mcp/install.js +44 -46
- package/build/commands/mcp/install.js.map +1 -1
- package/build/commands/mcp/list.d.ts.map +1 -1
- package/build/commands/mcp/list.js +51 -37
- package/build/commands/mcp/list.js.map +1 -1
- package/build/commands/mcp/remove.d.ts.map +1 -1
- package/build/commands/mcp/remove.js +23 -16
- package/build/commands/mcp/remove.js.map +1 -1
- package/build/commands/mcp/status.d.ts.map +1 -1
- package/build/commands/mcp/status.js +81 -73
- package/build/commands/mcp/status.js.map +1 -1
- package/build/commands/mcp/tokens.d.ts.map +1 -1
- package/build/commands/mcp/tokens.js +46 -47
- package/build/commands/mcp/tokens.js.map +1 -1
- package/build/commands/mcp/uninstall.d.ts.map +1 -1
- package/build/commands/mcp/uninstall.js +8 -6
- package/build/commands/mcp/uninstall.js.map +1 -1
- package/build/commands/mcp/update.d.ts.map +1 -1
- package/build/commands/mcp/update.js +11 -8
- package/build/commands/mcp/update.js.map +1 -1
- package/build/commands/mcp/utils/installWizard.d.ts.map +1 -1
- package/build/commands/mcp/utils/installWizard.js +3 -2
- package/build/commands/mcp/utils/installWizard.js.map +1 -1
- package/build/commands/mcp/utils/serverUtils.d.ts +8 -4
- package/build/commands/mcp/utils/serverUtils.d.ts.map +1 -1
- package/build/commands/mcp/utils/serverUtils.js +0 -3
- package/build/commands/mcp/utils/serverUtils.js.map +1 -1
- package/build/commands/mcp/wizard/components/serverDetailsDisplay.d.ts.map +1 -1
- package/build/commands/mcp/wizard/components/serverDetailsDisplay.js +4 -3
- package/build/commands/mcp/wizard/components/serverDetailsDisplay.js.map +1 -1
- package/build/commands/mcp/wizard/components/stepIndicator.d.ts.map +1 -1
- package/build/commands/mcp/wizard/components/stepIndicator.js +3 -2
- package/build/commands/mcp/wizard/components/stepIndicator.js.map +1 -1
- package/build/commands/mcp/wizard/components/welcomeScreen.d.ts.map +1 -1
- package/build/commands/mcp/wizard/components/welcomeScreen.js +2 -1
- package/build/commands/mcp/wizard/components/welcomeScreen.js.map +1 -1
- package/build/commands/mcp/wizard/configuration.d.ts.map +1 -1
- package/build/commands/mcp/wizard/configuration.js +10 -9
- package/build/commands/mcp/wizard/configuration.js.map +1 -1
- package/build/commands/mcp/wizard/display.d.ts.map +1 -1
- package/build/commands/mcp/wizard/display.js +9 -8
- package/build/commands/mcp/wizard/display.js.map +1 -1
- package/build/commands/mcp/wizard/search.d.ts.map +1 -1
- package/build/commands/mcp/wizard/search.js +4 -3
- package/build/commands/mcp/wizard/search.js.map +1 -1
- package/build/commands/preset/create.d.ts.map +1 -1
- package/build/commands/preset/create.js +7 -6
- package/build/commands/preset/create.js.map +1 -1
- package/build/commands/preset/delete.d.ts.map +1 -1
- package/build/commands/preset/delete.js +4 -2
- package/build/commands/preset/delete.js.map +1 -1
- package/build/commands/preset/edit.d.ts.map +1 -1
- package/build/commands/preset/edit.js +8 -5
- 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 +24 -15
- package/build/commands/preset/interactive.js.map +1 -1
- package/build/commands/preset/list.d.ts.map +1 -1
- package/build/commands/preset/list.js +12 -10
- package/build/commands/preset/list.js.map +1 -1
- package/build/commands/preset/show.d.ts.map +1 -1
- package/build/commands/preset/show.js +3 -2
- 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 -1
- package/build/commands/preset/test.js.map +1 -1
- package/build/commands/preset/url.d.ts.map +1 -1
- package/build/commands/preset/url.js +2 -1
- package/build/commands/preset/url.js.map +1 -1
- package/build/commands/proxy/index.d.ts.map +1 -1
- package/build/commands/proxy/index.js +5 -0
- package/build/commands/proxy/index.js.map +1 -1
- package/build/commands/proxy/proxy.d.ts.map +1 -1
- package/build/commands/proxy/proxy.js +1 -0
- package/build/commands/proxy/proxy.js.map +1 -1
- package/build/commands/registry/index.d.ts.map +1 -1
- package/build/commands/registry/index.js +2 -1
- package/build/commands/registry/index.js.map +1 -1
- package/build/commands/registry/search.d.ts.map +1 -1
- package/build/commands/registry/search.js +42 -37
- package/build/commands/registry/search.js.map +1 -1
- package/build/commands/registry/show.d.ts.map +1 -1
- package/build/commands/registry/show.js +8 -7
- package/build/commands/registry/show.js.map +1 -1
- package/build/commands/registry/status.d.ts.map +1 -1
- package/build/commands/registry/status.js +26 -16
- package/build/commands/registry/status.js.map +1 -1
- package/build/commands/registry/versions.d.ts.map +1 -1
- package/build/commands/registry/versions.js +8 -7
- package/build/commands/registry/versions.js.map +1 -1
- package/build/config/configChangeDetector.d.ts +8 -0
- package/build/config/configChangeDetector.d.ts.map +1 -0
- package/build/config/configChangeDetector.js +49 -0
- package/build/config/configChangeDetector.js.map +1 -0
- package/build/config/configLoader.d.ts +16 -0
- package/build/config/configLoader.d.ts.map +1 -0
- package/build/config/configLoader.js +155 -0
- package/build/config/configLoader.js.map +1 -0
- package/build/config/configManager.d.ts +49 -86
- package/build/config/configManager.d.ts.map +1 -1
- package/build/config/configManager.js +188 -301
- package/build/config/configManager.js.map +1 -1
- package/build/config/configWatcher.d.ts +18 -0
- package/build/config/configWatcher.d.ts.map +1 -0
- package/build/config/configWatcher.js +78 -0
- package/build/config/configWatcher.js.map +1 -0
- package/build/config/projectConfigTypes.d.ts +40 -0
- package/build/config/projectConfigTypes.d.ts.map +1 -1
- package/build/config/projectConfigTypes.js +21 -0
- package/build/config/projectConfigTypes.js.map +1 -1
- package/build/config/templateProcessor.d.ts +14 -0
- package/build/config/templateProcessor.d.ts.map +1 -0
- package/build/config/templateProcessor.js +102 -0
- package/build/config/templateProcessor.js.map +1 -0
- package/build/config/types.d.ts +36 -0
- package/build/config/types.d.ts.map +1 -0
- package/build/config/types.js +14 -0
- package/build/config/types.js.map +1 -0
- 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/capabilityManager.d.ts +3 -10
- package/build/core/capabilities/capabilityManager.d.ts.map +1 -1
- package/build/core/capabilities/internal/discoveryTools.d.ts.map +1 -1
- package/build/core/capabilities/internal/discoveryTools.js +25 -0
- package/build/core/capabilities/internal/discoveryTools.js.map +1 -1
- package/build/core/capabilities/internal/installationTools.d.ts.map +1 -1
- package/build/core/capabilities/internal/installationTools.js +14 -0
- package/build/core/capabilities/internal/installationTools.js.map +1 -1
- package/build/core/capabilities/internal/managementTools.d.ts.map +1 -1
- package/build/core/capabilities/internal/managementTools.js +25 -0
- package/build/core/capabilities/internal/managementTools.js.map +1 -1
- package/build/core/client/clientFactory.d.ts +7 -0
- package/build/core/client/clientFactory.d.ts.map +1 -0
- package/build/core/client/clientFactory.js +36 -0
- package/build/core/client/clientFactory.js.map +1 -0
- package/build/core/client/clientManager.d.ts +13 -101
- package/build/core/client/clientManager.d.ts.map +1 -1
- package/build/core/client/clientManager.js +115 -418
- package/build/core/client/clientManager.js.map +1 -1
- package/build/core/client/connectionHandler.d.ts +8 -0
- package/build/core/client/connectionHandler.d.ts.map +1 -0
- package/build/core/client/connectionHandler.js +80 -0
- package/build/core/client/connectionHandler.js.map +1 -0
- package/build/core/client/oauthFlowHandler.d.ts +10 -0
- package/build/core/client/oauthFlowHandler.d.ts.map +1 -0
- package/build/core/client/oauthFlowHandler.js +81 -0
- package/build/core/client/oauthFlowHandler.js.map +1 -0
- package/build/core/client/transportRecreator.d.ts +5 -0
- package/build/core/client/transportRecreator.d.ts.map +1 -0
- package/build/core/client/transportRecreator.js +23 -0
- package/build/core/client/transportRecreator.js.map +1 -0
- package/build/core/client/types.d.ts +7 -0
- package/build/core/client/types.d.ts.map +1 -0
- package/build/core/client/types.js +11 -0
- package/build/core/client/types.js.map +1 -0
- package/build/core/configChangeHandler.d.ts.map +1 -1
- package/build/core/configChangeHandler.js +11 -5
- package/build/core/configChangeHandler.js.map +1 -1
- package/build/core/context/globalContextManager.d.ts +58 -0
- package/build/core/context/globalContextManager.d.ts.map +1 -0
- package/build/core/context/globalContextManager.js +190 -0
- package/build/core/context/globalContextManager.js.map +1 -0
- package/build/core/filtering/clientFiltering.d.ts +1 -2
- package/build/core/filtering/clientFiltering.d.ts.map +1 -1
- package/build/core/filtering/clientTemplateTracker.d.ts +116 -0
- package/build/core/filtering/clientTemplateTracker.d.ts.map +1 -0
- package/build/core/filtering/clientTemplateTracker.js +286 -0
- package/build/core/filtering/clientTemplateTracker.js.map +1 -0
- package/build/core/filtering/filterCache.d.ts +121 -0
- package/build/core/filtering/filterCache.d.ts.map +1 -0
- package/build/core/filtering/filterCache.js +359 -0
- package/build/core/filtering/filterCache.js.map +1 -0
- package/build/core/filtering/index.d.ts +16 -0
- package/build/core/filtering/index.d.ts.map +1 -0
- package/build/core/filtering/index.js +16 -0
- package/build/core/filtering/index.js.map +1 -0
- package/build/core/filtering/templateFilteringService.d.ts +72 -0
- package/build/core/filtering/templateFilteringService.d.ts.map +1 -0
- package/build/core/filtering/templateFilteringService.js +293 -0
- package/build/core/filtering/templateFilteringService.js.map +1 -0
- package/build/core/filtering/templateIndex.d.ts +132 -0
- package/build/core/filtering/templateIndex.d.ts.map +1 -0
- package/build/core/filtering/templateIndex.js +368 -0
- package/build/core/filtering/templateIndex.js.map +1 -0
- package/build/core/flags/flagManager.d.ts +8 -4
- package/build/core/flags/flagManager.d.ts.map +1 -1
- package/build/core/flags/flagManager.js.map +1 -1
- package/build/core/protocol/requestHandlers.d.ts.map +1 -1
- package/build/core/protocol/requestHandlers.js +208 -46
- package/build/core/protocol/requestHandlers.js.map +1 -1
- package/build/core/server/clientInstancePool.d.ts +146 -0
- package/build/core/server/clientInstancePool.d.ts.map +1 -0
- package/build/core/server/clientInstancePool.js +407 -0
- package/build/core/server/clientInstancePool.js.map +1 -0
- package/build/core/server/connectionManager.d.ts +70 -0
- package/build/core/server/connectionManager.d.ts.map +1 -0
- package/build/core/server/connectionManager.js +240 -0
- package/build/core/server/connectionManager.js.map +1 -0
- package/build/core/server/mcpServerLifecycleManager.d.ts +55 -0
- package/build/core/server/mcpServerLifecycleManager.d.ts.map +1 -0
- package/build/core/server/mcpServerLifecycleManager.js +272 -0
- package/build/core/server/mcpServerLifecycleManager.js.map +1 -0
- package/build/core/server/serverManager.d.ts +56 -56
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +160 -431
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/server/templateConfigurationManager.d.ts +51 -0
- package/build/core/server/templateConfigurationManager.d.ts.map +1 -0
- package/build/core/server/templateConfigurationManager.js +160 -0
- package/build/core/server/templateConfigurationManager.js.map +1 -0
- package/build/core/server/templateServerManager.d.ts +92 -0
- package/build/core/server/templateServerManager.d.ts.map +1 -0
- package/build/core/server/templateServerManager.js +367 -0
- package/build/core/server/templateServerManager.js.map +1 -0
- package/build/core/tools/handlers/serverManagementHandler.d.ts +51 -1
- package/build/core/tools/handlers/serverManagementHandler.d.ts.map +1 -1
- package/build/core/tools/handlers/serverManagementHandler.js +42 -0
- package/build/core/tools/handlers/serverManagementHandler.js.map +1 -1
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts +11 -1
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/installation/types.d.ts +2 -4
- package/build/core/tools/internal/adapters/installation/types.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/installationAdapter.d.ts +2 -4
- package/build/core/tools/internal/adapters/installationAdapter.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/installationAdapter.js.map +1 -1
- package/build/core/tools/internal/adapters/management/managementAdapter.d.ts +2 -5
- package/build/core/tools/internal/adapters/management/managementAdapter.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/management/managementAdapter.js.map +1 -1
- package/build/core/tools/internal/adapters/management/types.d.ts +8 -4
- package/build/core/tools/internal/adapters/management/types.d.ts.map +1 -1
- package/build/core/tools/internal/index.d.ts +0 -31
- package/build/core/tools/internal/index.d.ts.map +1 -1
- package/build/core/tools/internal/index.js +4 -3
- package/build/core/tools/internal/index.js.map +1 -1
- package/build/core/tools/internal/schemas/index.d.ts +3 -3
- package/build/core/tools/internal/schemas/management.d.ts +3 -3
- package/build/core/types/server.d.ts +19 -0
- package/build/core/types/server.d.ts.map +1 -1
- package/build/core/types/server.js.map +1 -1
- package/build/core/types/transport.d.ts +178 -0
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +34 -0
- package/build/core/types/transport.js.map +1 -1
- package/build/core/validation/CustomJsonSchemaValidator.d.ts.map +1 -1
- package/build/core/validation/CustomJsonSchemaValidator.js +4 -3
- package/build/core/validation/CustomJsonSchemaValidator.js.map +1 -1
- package/build/domains/discovery/appPresets.d.ts.map +1 -1
- package/build/domains/discovery/appPresets.js +9 -7
- package/build/domains/discovery/appPresets.js.map +1 -1
- package/build/domains/installation/configurators/cliArgsConfigurator.d.ts.map +1 -1
- package/build/domains/installation/configurators/cliArgsConfigurator.js +8 -4
- package/build/domains/installation/configurators/cliArgsConfigurator.js.map +1 -1
- package/build/domains/installation/configurators/envVarConfigurator.d.ts.map +1 -1
- package/build/domains/installation/configurators/envVarConfigurator.js +8 -4
- package/build/domains/installation/configurators/envVarConfigurator.js.map +1 -1
- package/build/domains/installation/configurators/tagsConfigurator.d.ts +2 -4
- package/build/domains/installation/configurators/tagsConfigurator.d.ts.map +1 -1
- package/build/domains/installation/configurators/tagsConfigurator.js +4 -7
- package/build/domains/installation/configurators/tagsConfigurator.js.map +1 -1
- package/build/domains/installation/validators/conflictDetector.d.ts +6 -4
- package/build/domains/installation/validators/conflictDetector.d.ts.map +1 -1
- package/build/domains/installation/validators/conflictDetector.js +0 -3
- package/build/domains/installation/validators/conflictDetector.js.map +1 -1
- package/build/domains/preset/manager/presetManager.js +1 -1
- package/build/domains/preset/manager/presetManager.js.map +1 -1
- package/build/domains/preset/parsers/tagQueryEvaluator.d.ts +8 -4
- package/build/domains/preset/parsers/tagQueryEvaluator.d.ts.map +1 -1
- package/build/domains/preset/parsers/tagQueryEvaluator.js.map +1 -1
- package/build/domains/preset/services/presetErrorHandler.d.ts +0 -7
- package/build/domains/preset/services/presetErrorHandler.d.ts.map +1 -1
- package/build/domains/preset/services/presetErrorHandler.js +10 -37
- package/build/domains/preset/services/presetErrorHandler.js.map +1 -1
- package/build/domains/registry/cacheManager.d.ts +11 -1
- package/build/domains/registry/cacheManager.d.ts.map +1 -1
- package/build/domains/registry/cacheManager.js +21 -3
- package/build/domains/registry/cacheManager.js.map +1 -1
- package/build/domains/registry/formatters/serverDetailFormatter.d.ts.map +1 -1
- package/build/domains/registry/formatters/serverDetailFormatter.js +57 -8
- package/build/domains/registry/formatters/serverDetailFormatter.js.map +1 -1
- package/build/domains/registry/formatters/versionsFormatter.d.ts.map +1 -1
- package/build/domains/registry/formatters/versionsFormatter.js +8 -3
- package/build/domains/registry/formatters/versionsFormatter.js.map +1 -1
- package/build/logger/logger.d.ts +8 -4
- package/build/logger/logger.d.ts.map +1 -1
- package/build/logger/logger.js.map +1 -1
- package/build/server.d.ts +2 -1
- package/build/server.d.ts.map +1 -1
- package/build/server.js +16 -7
- package/build/server.js.map +1 -1
- package/build/template/handlebarsTemplateRenderer.d.ts +34 -0
- package/build/template/handlebarsTemplateRenderer.d.ts.map +1 -0
- package/build/template/handlebarsTemplateRenderer.js +92 -0
- package/build/template/handlebarsTemplateRenderer.js.map +1 -0
- package/build/template/index.d.ts +2 -0
- package/build/template/index.d.ts.map +1 -0
- package/build/template/index.js +3 -0
- package/build/template/index.js.map +1 -0
- package/build/transport/http/middlewares/securityMiddleware.js +1 -1
- package/build/transport/http/middlewares/securityMiddleware.js.map +1 -1
- package/build/transport/http/restorableStreamableTransport.d.ts +8 -4
- package/build/transport/http/restorableStreamableTransport.d.ts.map +1 -1
- package/build/transport/http/restorableStreamableTransport.js.map +1 -1
- package/build/transport/http/routes/sseRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/sseRoutes.js +15 -0
- package/build/transport/http/routes/sseRoutes.js.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +88 -12
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/server.d.ts +1 -0
- package/build/transport/http/server.d.ts.map +1 -1
- package/build/transport/http/server.js +1 -0
- package/build/transport/http/server.js.map +1 -1
- package/build/transport/http/storage/streamableSessionRepository.d.ts.map +1 -1
- package/build/transport/http/storage/streamableSessionRepository.js +2 -0
- package/build/transport/http/storage/streamableSessionRepository.js.map +1 -1
- package/build/transport/http/utils/contextExtractor.d.ts +23 -0
- package/build/transport/http/utils/contextExtractor.d.ts.map +1 -0
- package/build/transport/http/utils/contextExtractor.js +58 -0
- package/build/transport/http/utils/contextExtractor.js.map +1 -0
- package/build/transport/restartableStdioTransport.d.ts +8 -4
- package/build/transport/restartableStdioTransport.d.ts.map +1 -1
- package/build/transport/restartableStdioTransport.js.map +1 -1
- package/build/transport/stdioProxyTransport.d.ts +15 -0
- package/build/transport/stdioProxyTransport.d.ts.map +1 -1
- package/build/transport/stdioProxyTransport.js +168 -35
- package/build/transport/stdioProxyTransport.js.map +1 -1
- package/build/transport/transportFactory.d.ts +8 -0
- package/build/transport/transportFactory.d.ts.map +1 -1
- package/build/transport/transportFactory.js +47 -0
- package/build/transport/transportFactory.js.map +1 -1
- package/build/types/context.d.ts +120 -0
- package/build/types/context.d.ts.map +1 -0
- package/build/types/context.js +4 -0
- package/build/types/context.js.map +1 -0
- package/build/types/validation.d.ts +30 -0
- package/build/types/validation.d.ts.map +1 -0
- package/build/types/validation.js +5 -0
- package/build/types/validation.js.map +1 -0
- package/build/utils/client/clientInfoExtractor.d.ts +26 -0
- package/build/utils/client/clientInfoExtractor.d.ts.map +1 -0
- package/build/utils/client/clientInfoExtractor.js +65 -0
- package/build/utils/client/clientInfoExtractor.js.map +1 -0
- package/build/utils/core/errorHandling.d.ts +9 -5
- package/build/utils/core/errorHandling.d.ts.map +1 -1
- package/build/utils/core/errorHandling.js.map +1 -1
- package/build/utils/core/parsing.d.ts +8 -4
- package/build/utils/core/parsing.d.ts.map +1 -1
- package/build/utils/core/parsing.js.map +1 -1
- package/build/utils/crypto.d.ts +10 -0
- package/build/utils/crypto.d.ts.map +1 -0
- package/build/utils/crypto.js +20 -0
- package/build/utils/crypto.js.map +1 -0
- package/build/utils/ui/interactiveSelector.d.ts +16 -6
- package/build/utils/ui/interactiveSelector.d.ts.map +1 -1
- package/build/utils/ui/interactiveSelector.js +7 -31
- package/build/utils/ui/interactiveSelector.js.map +1 -1
- package/build/utils/ui/pagination.d.ts +6 -2
- package/build/utils/ui/pagination.d.ts.map +1 -1
- package/build/utils/ui/pagination.js.map +1 -1
- package/build/utils/ui/printer.d.ts +76 -0
- package/build/utils/ui/printer.d.ts.map +1 -0
- package/build/utils/ui/printer.js +172 -0
- package/build/utils/ui/printer.js.map +1 -0
- package/build/utils/ui/spinner.d.ts +19 -0
- package/build/utils/ui/spinner.d.ts.map +1 -0
- package/build/utils/ui/spinner.js +51 -0
- package/build/utils/ui/spinner.js.map +1 -0
- package/build/utils/ui/table.d.ts +16 -0
- package/build/utils/ui/table.d.ts.map +1 -0
- package/build/utils/ui/table.js +70 -0
- package/build/utils/ui/table.js.map +1 -0
- package/build/utils/validation/validationHelpers.d.ts +7 -3
- package/build/utils/validation/validationHelpers.d.ts.map +1 -1
- package/build/utils/validation/validationHelpers.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { setupCapabilities } from '../../core/capabilities/capabilityManager.js';
|
|
3
|
+
import { ServerStatus } from '../../core/types/index.js';
|
|
4
|
+
import { PresetNotificationService, } from '../../domains/preset/services/presetNotificationService.js';
|
|
5
|
+
import logger, { debugIf } from '../../logger/logger.js';
|
|
6
|
+
import { enhanceServerWithLogging } from '../../logger/mcpLoggingEnhancer.js';
|
|
7
|
+
import { executeOperation } from '../../utils/core/operationExecution.js';
|
|
8
|
+
/**
|
|
9
|
+
* Manages transport connection lifecycle and inbound connections
|
|
10
|
+
*/
|
|
11
|
+
export class ConnectionManager {
|
|
12
|
+
serverConfig;
|
|
13
|
+
serverCapabilities;
|
|
14
|
+
outboundConns;
|
|
15
|
+
inboundConns = new Map();
|
|
16
|
+
connectionSemaphore = new Map();
|
|
17
|
+
disconnectingIds = new Set();
|
|
18
|
+
constructor(serverConfig, serverCapabilities, outboundConns) {
|
|
19
|
+
this.serverConfig = serverConfig;
|
|
20
|
+
this.serverCapabilities = serverCapabilities;
|
|
21
|
+
this.outboundConns = outboundConns;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Connect a transport with the given session ID and configuration
|
|
25
|
+
*/
|
|
26
|
+
async connectTransport(transport, sessionId, opts, context, filteredInstructions) {
|
|
27
|
+
// Check if a connection is already in progress for this session
|
|
28
|
+
const existingConnection = this.connectionSemaphore.get(sessionId);
|
|
29
|
+
if (existingConnection) {
|
|
30
|
+
logger.warn(`Connection already in progress for session ${sessionId}, waiting...`);
|
|
31
|
+
await existingConnection;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// Check if transport is already connected
|
|
35
|
+
if (this.inboundConns.has(sessionId)) {
|
|
36
|
+
logger.warn(`Transport already connected for session ${sessionId}`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Create connection promise to prevent race conditions
|
|
40
|
+
const connectionPromise = this.performConnection(transport, sessionId, opts, context, filteredInstructions);
|
|
41
|
+
this.connectionSemaphore.set(sessionId, connectionPromise);
|
|
42
|
+
try {
|
|
43
|
+
await connectionPromise;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
// Clean up the semaphore entry
|
|
47
|
+
this.connectionSemaphore.delete(sessionId);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Disconnect a transport by session ID
|
|
52
|
+
*/
|
|
53
|
+
async disconnectTransport(sessionId, forceClose = false) {
|
|
54
|
+
// Prevent recursive disconnection calls
|
|
55
|
+
if (this.disconnectingIds.has(sessionId)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const server = this.inboundConns.get(sessionId);
|
|
59
|
+
if (server) {
|
|
60
|
+
this.disconnectingIds.add(sessionId);
|
|
61
|
+
try {
|
|
62
|
+
// Update status to Disconnected
|
|
63
|
+
server.status = ServerStatus.Disconnected;
|
|
64
|
+
// Only close the transport if explicitly requested
|
|
65
|
+
if (forceClose && server.server.transport) {
|
|
66
|
+
try {
|
|
67
|
+
server.server.transport.close();
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
logger.error(`Error closing transport for session ${sessionId}:`, error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Untrack client from preset notification service
|
|
74
|
+
const notificationService = PresetNotificationService.getInstance();
|
|
75
|
+
notificationService.untrackClient(sessionId);
|
|
76
|
+
debugIf(() => ({ message: 'Untracked client from preset notifications', meta: { sessionId } }));
|
|
77
|
+
this.inboundConns.delete(sessionId);
|
|
78
|
+
logger.info(`Disconnected transport for session ${sessionId}`);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
this.disconnectingIds.delete(sessionId);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get transport by session ID
|
|
87
|
+
*/
|
|
88
|
+
getTransport(sessionId) {
|
|
89
|
+
return this.inboundConns.get(sessionId)?.server.transport;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get all active transports
|
|
93
|
+
*/
|
|
94
|
+
getTransports() {
|
|
95
|
+
const transports = new Map();
|
|
96
|
+
for (const [id, server] of this.inboundConns.entries()) {
|
|
97
|
+
if (server.server.transport) {
|
|
98
|
+
transports.set(id, server.server.transport);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return transports;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get server connection by session ID
|
|
105
|
+
*/
|
|
106
|
+
getServer(sessionId) {
|
|
107
|
+
return this.inboundConns.get(sessionId);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get all inbound connections
|
|
111
|
+
*/
|
|
112
|
+
getInboundConnections() {
|
|
113
|
+
return this.inboundConns;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get count of active transports
|
|
117
|
+
*/
|
|
118
|
+
getActiveTransportsCount() {
|
|
119
|
+
return this.inboundConns.size;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Execute a server operation with error handling
|
|
123
|
+
*/
|
|
124
|
+
async executeServerOperation(inboundConn, operation, options = {}) {
|
|
125
|
+
// Check connection status before executing operation
|
|
126
|
+
if (inboundConn.status !== ServerStatus.Connected || !inboundConn.server.transport) {
|
|
127
|
+
throw new Error(`Cannot execute operation: server status is ${inboundConn.status}`);
|
|
128
|
+
}
|
|
129
|
+
return executeOperation(() => operation(inboundConn), 'server', options);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Perform the actual connection
|
|
133
|
+
*/
|
|
134
|
+
async performConnection(transport, sessionId, opts, context, filteredInstructions) {
|
|
135
|
+
// Set connection timeout
|
|
136
|
+
const connectionTimeoutMs = 30000; // 30 seconds
|
|
137
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
138
|
+
setTimeout(() => reject(new Error(`Connection timeout for session ${sessionId}`)), connectionTimeoutMs);
|
|
139
|
+
});
|
|
140
|
+
try {
|
|
141
|
+
await Promise.race([this.doConnect(transport, sessionId, opts, context, filteredInstructions), timeoutPromise]);
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
// Update status to Error if connection exists
|
|
145
|
+
const connection = this.inboundConns.get(sessionId);
|
|
146
|
+
if (connection) {
|
|
147
|
+
connection.status = ServerStatus.Error;
|
|
148
|
+
connection.lastError = error instanceof Error ? error : new Error(String(error));
|
|
149
|
+
}
|
|
150
|
+
logger.error(`Failed to connect transport for session ${sessionId}:`, error);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Do the actual connection work
|
|
156
|
+
*/
|
|
157
|
+
async doConnect(transport, sessionId, opts, context, filteredInstructions) {
|
|
158
|
+
// Create server capabilities with filtered instructions
|
|
159
|
+
const serverOptionsWithInstructions = {
|
|
160
|
+
...this.serverCapabilities,
|
|
161
|
+
instructions: filteredInstructions || undefined,
|
|
162
|
+
};
|
|
163
|
+
// Create a new server instance for this transport
|
|
164
|
+
const server = new Server(this.serverConfig, serverOptionsWithInstructions);
|
|
165
|
+
// Create server info object, merging context if provided
|
|
166
|
+
const serverInfo = {
|
|
167
|
+
server,
|
|
168
|
+
status: ServerStatus.Connecting,
|
|
169
|
+
connectedAt: new Date(),
|
|
170
|
+
...opts,
|
|
171
|
+
// Ensure context is properly set from the context parameter if opts.context is missing
|
|
172
|
+
// This ensures sessionId is available for session-scoped template server filtering
|
|
173
|
+
context: context ? { ...context, ...opts.context } : opts.context,
|
|
174
|
+
};
|
|
175
|
+
// Enhance server with logging middleware
|
|
176
|
+
enhanceServerWithLogging(server);
|
|
177
|
+
// Set up capabilities for this server instance
|
|
178
|
+
await setupCapabilities(this.outboundConns, serverInfo);
|
|
179
|
+
// Store the server instance
|
|
180
|
+
this.inboundConns.set(sessionId, serverInfo);
|
|
181
|
+
// Connect the transport to the new server instance
|
|
182
|
+
await server.connect(transport);
|
|
183
|
+
// Update status to Connected after successful connection
|
|
184
|
+
serverInfo.status = ServerStatus.Connected;
|
|
185
|
+
serverInfo.lastConnected = new Date();
|
|
186
|
+
// Register client with preset notification service if preset is used
|
|
187
|
+
if (opts.presetName) {
|
|
188
|
+
await this.registerClientForPresets(sessionId, opts.presetName, serverInfo);
|
|
189
|
+
}
|
|
190
|
+
logger.info(`Connected transport for session ${sessionId}`);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Register client with preset notification service
|
|
194
|
+
*/
|
|
195
|
+
async registerClientForPresets(sessionId, presetName, serverInfo) {
|
|
196
|
+
const notificationService = PresetNotificationService.getInstance();
|
|
197
|
+
const clientConnection = {
|
|
198
|
+
id: sessionId,
|
|
199
|
+
presetName,
|
|
200
|
+
sendNotification: async (method, params) => {
|
|
201
|
+
try {
|
|
202
|
+
if (serverInfo.status === ServerStatus.Connected && serverInfo.server.transport) {
|
|
203
|
+
await serverInfo.server.notification({ method, params: params || {} });
|
|
204
|
+
debugIf(() => ({ message: 'Sent notification to client', meta: { sessionId, method } }));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
logger.warn('Cannot send notification to disconnected client', { sessionId, method });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
logger.error('Failed to send notification to client', {
|
|
212
|
+
sessionId,
|
|
213
|
+
method,
|
|
214
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
215
|
+
});
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
isConnected: () => serverInfo.status === ServerStatus.Connected && !!serverInfo.server.transport,
|
|
220
|
+
};
|
|
221
|
+
notificationService.trackClient(clientConnection, presetName);
|
|
222
|
+
logger.info('Registered client for preset notifications', {
|
|
223
|
+
sessionId,
|
|
224
|
+
presetName,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Clean up all connections (for shutdown)
|
|
229
|
+
*/
|
|
230
|
+
async cleanup() {
|
|
231
|
+
// Clean up existing connections with forced close
|
|
232
|
+
for (const [sessionId] of this.inboundConns) {
|
|
233
|
+
await this.disconnectTransport(sessionId, true);
|
|
234
|
+
}
|
|
235
|
+
this.inboundConns.clear();
|
|
236
|
+
this.connectionSemaphore.clear();
|
|
237
|
+
this.disconnectingIds.clear();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=connectionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionManager.js","sourceRoot":"","sources":["../../../src/core/server/connectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAEhF,OAAO,EAAgE,YAAY,EAAE,MAAM,0BAA0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D,WAAW,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,KAAK,YAAY,CAAC,SAAS,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS;SACjG,CAAC;QAEF,mBAAmB,CAAC,WAAW,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,CAAC,IAAI,CAAC,4CAA4C,EAAE;YACxD,SAAS;YACT,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO;QAClB,kDAAkD;QAClD,KAAK,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5C,MAAM,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAClD,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
2
|
+
import type { OutboundConnections } from '../../core/types/client.js';
|
|
3
|
+
import { MCPServerParams } from '../../core/types/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Manages the lifecycle of MCP server instances (start, stop, restart)
|
|
6
|
+
*/
|
|
7
|
+
export declare class MCPServerLifecycleManager {
|
|
8
|
+
private mcpServers;
|
|
9
|
+
private clientManager?;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Start a new MCP server instance
|
|
13
|
+
*/
|
|
14
|
+
startServer(serverName: string, config: MCPServerParams, outboundConns: OutboundConnections, transports: Record<string, Transport>): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Stop a server instance
|
|
17
|
+
*/
|
|
18
|
+
stopServer(serverName: string, outboundConns: OutboundConnections, transports: Record<string, Transport>): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Restart a server instance
|
|
21
|
+
*/
|
|
22
|
+
restartServer(serverName: string, config: MCPServerParams, outboundConns: OutboundConnections, transports: Record<string, Transport>): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Get the status of all managed MCP servers
|
|
25
|
+
*/
|
|
26
|
+
getMcpServerStatus(): Map<string, {
|
|
27
|
+
running: boolean;
|
|
28
|
+
config: MCPServerParams;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a specific MCP server is running
|
|
32
|
+
*/
|
|
33
|
+
isMcpServerRunning(serverName: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Update metadata for a running server without restarting it
|
|
36
|
+
*/
|
|
37
|
+
updateServerMetadata(serverName: string, newConfig: MCPServerParams, outboundConns: OutboundConnections): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Process server configuration to handle environment variables
|
|
40
|
+
*/
|
|
41
|
+
private processServerConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Create a transport for the given server configuration
|
|
44
|
+
*/
|
|
45
|
+
private createServerTransport;
|
|
46
|
+
/**
|
|
47
|
+
* Connect to a server using ClientManager
|
|
48
|
+
*/
|
|
49
|
+
private connectToServer;
|
|
50
|
+
/**
|
|
51
|
+
* Disconnect from a server using ClientManager
|
|
52
|
+
*/
|
|
53
|
+
private disconnectFromServer;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=mcpServerLifecycleManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpServerLifecycleManager.d.ts","sourceRoot":"","sources":["../../../src/core/server/mcpServerLifecycleManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAK1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAyB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIlF;;GAEG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,UAAU,CAAyF;IAC3G,OAAO,CAAC,aAAa,CAAC,CAAgB;;IAMtC;;OAEG;IACU,WAAW,CACtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,mBAAmB,EAClC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC;IAyChB;;OAEG;IACU,UAAU,CACrB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,mBAAmB,EAClC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC;IAkChB;;OAEG;IACU,aAAa,CACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,mBAAmB,EAClC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC;IAqBhB;;OAEG;IACI,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,eAAe,CAAA;KAAE,CAAC;IAavF;;OAEG;IACI,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAItD;;OAEG;IACU,oBAAoB,CAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,eAAe,EAC1B,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,IAAI,CAAC;IA6ChB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA0B3B;;OAEG;YACW,qBAAqB;IAgCnC;;OAEG;YACW,eAAe;IAgC7B;;OAEG;YACW,oBAAoB;CA0BnC"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { processEnvironment } from '../../config/envProcessor.js';
|
|
2
|
+
import { ClientManager } from '../../core/client/clientManager.js';
|
|
3
|
+
import { getGlobalContextManager } from '../../core/context/globalContextManager.js';
|
|
4
|
+
import logger, { debugIf } from '../../logger/logger.js';
|
|
5
|
+
import { createTransports, createTransportsWithContext, inferTransportType } from '../../transport/transportFactory.js';
|
|
6
|
+
/**
|
|
7
|
+
* Manages the lifecycle of MCP server instances (start, stop, restart)
|
|
8
|
+
*/
|
|
9
|
+
export class MCPServerLifecycleManager {
|
|
10
|
+
mcpServers = new Map();
|
|
11
|
+
clientManager;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.clientManager = ClientManager.getOrCreateInstance();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Start a new MCP server instance
|
|
17
|
+
*/
|
|
18
|
+
async startServer(serverName, config, outboundConns, transports) {
|
|
19
|
+
try {
|
|
20
|
+
logger.info(`Starting MCP server: ${serverName}`);
|
|
21
|
+
// Check if server is already running
|
|
22
|
+
if (this.mcpServers.has(serverName)) {
|
|
23
|
+
logger.warn(`Server ${serverName} is already running`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Skip disabled servers
|
|
27
|
+
if (config.disabled) {
|
|
28
|
+
logger.info(`Server ${serverName} is disabled, skipping start`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Process environment variables in config
|
|
32
|
+
const processedConfig = this.processServerConfig(config);
|
|
33
|
+
// Infer transport type if not specified
|
|
34
|
+
const configWithType = inferTransportType(processedConfig, serverName);
|
|
35
|
+
// Create transport for the server
|
|
36
|
+
const transport = await this.createServerTransport(serverName, configWithType);
|
|
37
|
+
// Store server info
|
|
38
|
+
this.mcpServers.set(serverName, {
|
|
39
|
+
transport,
|
|
40
|
+
config: configWithType,
|
|
41
|
+
});
|
|
42
|
+
// Create client connection to the server using ClientManager
|
|
43
|
+
await this.connectToServer(serverName, transport, configWithType, outboundConns, transports);
|
|
44
|
+
logger.info(`Successfully started MCP server: ${serverName}`);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.error(`Failed to start MCP server ${serverName}:`, error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Stop a server instance
|
|
53
|
+
*/
|
|
54
|
+
async stopServer(serverName, outboundConns, transports) {
|
|
55
|
+
try {
|
|
56
|
+
logger.info(`Stopping MCP server: ${serverName}`);
|
|
57
|
+
// Check if server is running
|
|
58
|
+
const serverInfo = this.mcpServers.get(serverName);
|
|
59
|
+
if (!serverInfo) {
|
|
60
|
+
logger.warn(`Server ${serverName} is not running`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Disconnect client from the server using ClientManager
|
|
64
|
+
await this.disconnectFromServer(serverName, outboundConns, transports);
|
|
65
|
+
// Clean up transport
|
|
66
|
+
const { transport } = serverInfo;
|
|
67
|
+
try {
|
|
68
|
+
if (transport.close) {
|
|
69
|
+
await transport.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
logger.warn(`Error closing transport for server ${serverName}:`, error);
|
|
74
|
+
}
|
|
75
|
+
// Remove from tracking
|
|
76
|
+
this.mcpServers.delete(serverName);
|
|
77
|
+
logger.info(`Successfully stopped MCP server: ${serverName}`);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
logger.error(`Failed to stop MCP server ${serverName}:`, error);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Restart a server instance
|
|
86
|
+
*/
|
|
87
|
+
async restartServer(serverName, config, outboundConns, transports) {
|
|
88
|
+
try {
|
|
89
|
+
logger.info(`Restarting MCP server: ${serverName}`);
|
|
90
|
+
// Check if server is currently running and stop it
|
|
91
|
+
const isCurrentlyRunning = this.mcpServers.has(serverName);
|
|
92
|
+
if (isCurrentlyRunning) {
|
|
93
|
+
logger.info(`Stopping existing server ${serverName} before restart`);
|
|
94
|
+
await this.stopServer(serverName, outboundConns, transports);
|
|
95
|
+
}
|
|
96
|
+
// Start the server with new configuration
|
|
97
|
+
await this.startServer(serverName, config, outboundConns, transports);
|
|
98
|
+
logger.info(`Successfully restarted MCP server: ${serverName}`);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
logger.error(`Failed to restart MCP server ${serverName}:`, error);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the status of all managed MCP servers
|
|
107
|
+
*/
|
|
108
|
+
getMcpServerStatus() {
|
|
109
|
+
const status = new Map();
|
|
110
|
+
for (const [serverName, serverInfo] of this.mcpServers.entries()) {
|
|
111
|
+
status.set(serverName, {
|
|
112
|
+
running: true,
|
|
113
|
+
config: serverInfo.config,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return status;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check if a specific MCP server is running
|
|
120
|
+
*/
|
|
121
|
+
isMcpServerRunning(serverName) {
|
|
122
|
+
return this.mcpServers.has(serverName);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Update metadata for a running server without restarting it
|
|
126
|
+
*/
|
|
127
|
+
async updateServerMetadata(serverName, newConfig, outboundConns) {
|
|
128
|
+
try {
|
|
129
|
+
const serverInfo = this.mcpServers.get(serverName);
|
|
130
|
+
if (!serverInfo) {
|
|
131
|
+
logger.warn(`Cannot update metadata for ${serverName}: server not running`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
debugIf(() => ({
|
|
135
|
+
message: `Updating metadata for server ${serverName}`,
|
|
136
|
+
meta: {
|
|
137
|
+
oldConfig: serverInfo.config,
|
|
138
|
+
newConfig,
|
|
139
|
+
},
|
|
140
|
+
}));
|
|
141
|
+
// Update the stored configuration with new metadata
|
|
142
|
+
serverInfo.config = { ...serverInfo.config, ...newConfig };
|
|
143
|
+
// Update transport metadata if supported
|
|
144
|
+
const { transport } = serverInfo;
|
|
145
|
+
if (transport && 'tags' in transport) {
|
|
146
|
+
// Update tags and other metadata on transport
|
|
147
|
+
if (newConfig.tags) {
|
|
148
|
+
transport.tags = newConfig.tags;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Update outbound connections metadata
|
|
152
|
+
const outboundConn = outboundConns.get(serverName);
|
|
153
|
+
if (outboundConn && outboundConn.transport && 'tags' in outboundConn.transport) {
|
|
154
|
+
// Update tags in the outbound connection
|
|
155
|
+
outboundConn.transport.tags = newConfig.tags;
|
|
156
|
+
}
|
|
157
|
+
debugIf(() => ({
|
|
158
|
+
message: `Successfully updated metadata for server ${serverName}`,
|
|
159
|
+
meta: { newTags: newConfig.tags },
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
logger.error(`Failed to update metadata for server ${serverName}:`, error);
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Process server configuration to handle environment variables
|
|
169
|
+
*/
|
|
170
|
+
processServerConfig(config) {
|
|
171
|
+
try {
|
|
172
|
+
// Create a mutable copy for processing
|
|
173
|
+
const processedConfig = { ...config };
|
|
174
|
+
// Process environment variables if enabled - only pass env-related fields
|
|
175
|
+
const envConfig = {
|
|
176
|
+
inheritParentEnv: config.inheritParentEnv,
|
|
177
|
+
envFilter: config.envFilter,
|
|
178
|
+
env: config.env,
|
|
179
|
+
};
|
|
180
|
+
const processedEnv = processEnvironment(envConfig);
|
|
181
|
+
// Replace environment variables in the config while preserving all other fields
|
|
182
|
+
if (processedEnv.processedEnv && Object.keys(processedEnv.processedEnv).length > 0) {
|
|
183
|
+
processedConfig.env = processedEnv.processedEnv;
|
|
184
|
+
}
|
|
185
|
+
return processedConfig;
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
logger.warn(`Failed to process environment variables for server config:`, error);
|
|
189
|
+
return config;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Create a transport for the given server configuration
|
|
194
|
+
*/
|
|
195
|
+
async createServerTransport(serverName, config) {
|
|
196
|
+
try {
|
|
197
|
+
debugIf(() => ({
|
|
198
|
+
message: `Creating transport for server ${serverName}`,
|
|
199
|
+
meta: { serverName, type: config.type, command: config.command, url: config.url },
|
|
200
|
+
}));
|
|
201
|
+
// Create transport using the factory pattern with context awareness
|
|
202
|
+
const globalContextManager = getGlobalContextManager();
|
|
203
|
+
const currentContext = globalContextManager.getContext();
|
|
204
|
+
const transports = currentContext
|
|
205
|
+
? await createTransportsWithContext({ [serverName]: config }, currentContext)
|
|
206
|
+
: createTransports({ [serverName]: config });
|
|
207
|
+
const transport = transports[serverName];
|
|
208
|
+
if (!transport) {
|
|
209
|
+
throw new Error(`Failed to create transport for server ${serverName}`);
|
|
210
|
+
}
|
|
211
|
+
debugIf(() => ({
|
|
212
|
+
message: `Successfully created transport for server ${serverName}`,
|
|
213
|
+
meta: { serverName, transportType: config.type },
|
|
214
|
+
}));
|
|
215
|
+
return transport;
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
logger.error(`Failed to create transport for server ${serverName}:`, error);
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Connect to a server using ClientManager
|
|
224
|
+
*/
|
|
225
|
+
async connectToServer(serverName, transport, _config, outboundConns, transports) {
|
|
226
|
+
try {
|
|
227
|
+
if (!this.clientManager) {
|
|
228
|
+
throw new Error('ClientManager not initialized');
|
|
229
|
+
}
|
|
230
|
+
// Create client connection using the existing ClientManager infrastructure
|
|
231
|
+
const clients = await this.clientManager.createClients({ [serverName]: transport });
|
|
232
|
+
// Update our local outbound connections
|
|
233
|
+
const newClient = clients.get(serverName);
|
|
234
|
+
if (newClient) {
|
|
235
|
+
outboundConns.set(serverName, newClient);
|
|
236
|
+
transports[serverName] = transport;
|
|
237
|
+
}
|
|
238
|
+
debugIf(() => ({
|
|
239
|
+
message: `Successfully connected to server ${serverName}`,
|
|
240
|
+
meta: { serverName, status: newClient?.status },
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
logger.error(`Failed to connect to server ${serverName}:`, error);
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Disconnect from a server using ClientManager
|
|
250
|
+
*/
|
|
251
|
+
async disconnectFromServer(serverName, outboundConns, transports) {
|
|
252
|
+
try {
|
|
253
|
+
if (!this.clientManager) {
|
|
254
|
+
throw new Error('ClientManager not initialized');
|
|
255
|
+
}
|
|
256
|
+
// Remove from outbound connections
|
|
257
|
+
outboundConns.delete(serverName);
|
|
258
|
+
delete transports[serverName];
|
|
259
|
+
// ClientManager doesn't have explicit disconnect method, so we clean up our references
|
|
260
|
+
// The actual transport cleanup happens in stopServer
|
|
261
|
+
debugIf(() => ({
|
|
262
|
+
message: `Successfully disconnected from server ${serverName}`,
|
|
263
|
+
meta: { serverName },
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
logger.error(`Failed to disconnect from server ${serverName}:`, error);
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//# sourceMappingURL=mcpServerLifecycleManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpServerLifecycleManager.js","sourceRoot":"","sources":["../../../src/core/server/mcpServerLifecycleManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,OAAO,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,M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