@1mcp/agent 0.39.0-beta.3 → 0.39.0-beta.4
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/admin/assets/{admin-OAuthServicesWorkspace-D_GlqLxL.js → admin-OAuthServicesWorkspace-CKR1HA-8.js} +1 -1
- package/build/admin/assets/{admin-console-CMRxMjQo.js → admin-console-OfHKqRm-.js} +3 -3
- package/build/admin/index.html +1 -1
- package/build/auth/oauthAuthority.d.ts +149 -0
- package/build/auth/oauthAuthority.d.ts.map +1 -0
- package/build/auth/oauthAuthority.js +101 -0
- package/build/auth/oauthAuthority.js.map +1 -0
- package/build/auth/oauthAuthorizationFlow.d.ts +7 -1
- package/build/auth/oauthAuthorizationFlow.d.ts.map +1 -1
- package/build/auth/oauthAuthorizationFlow.js +60 -74
- package/build/auth/oauthAuthorizationFlow.js.map +1 -1
- package/build/auth/oauthEndpointFetch.d.ts +20 -0
- package/build/auth/oauthEndpointFetch.d.ts.map +1 -0
- package/build/auth/oauthEndpointFetch.js +246 -0
- package/build/auth/oauthEndpointFetch.js.map +1 -0
- package/build/auth/sessionTypes.d.ts +1 -1
- package/build/auth/storage/clientSessionRepository.d.ts +19 -0
- package/build/auth/storage/clientSessionRepository.d.ts.map +1 -1
- package/build/auth/storage/clientSessionRepository.js +178 -0
- package/build/auth/storage/clientSessionRepository.js.map +1 -1
- package/build/auth/storage/fileStorageService.d.ts +9 -1
- package/build/auth/storage/fileStorageService.d.ts.map +1 -1
- package/build/auth/storage/fileStorageService.js +32 -5
- package/build/auth/storage/fileStorageService.js.map +1 -1
- package/build/auth/storage/inboundOAuthStorage.d.ts +14 -0
- package/build/auth/storage/inboundOAuthStorage.d.ts.map +1 -0
- package/build/auth/storage/inboundOAuthStorage.js +29 -0
- package/build/auth/storage/inboundOAuthStorage.js.map +1 -0
- package/build/auth/storage/nativeCredentialStore.d.ts +44 -0
- package/build/auth/storage/nativeCredentialStore.d.ts.map +1 -0
- package/build/auth/storage/nativeCredentialStore.js +177 -0
- package/build/auth/storage/nativeCredentialStore.js.map +1 -0
- package/build/auth/storage/oauthStorageService.d.ts +8 -1
- package/build/auth/storage/oauthStorageService.d.ts.map +1 -1
- package/build/auth/storage/oauthStorageService.js +69 -47
- package/build/auth/storage/oauthStorageService.js.map +1 -1
- package/build/auth/storage/protectedRecordStorage.d.ts +129 -0
- package/build/auth/storage/protectedRecordStorage.d.ts.map +1 -0
- package/build/auth/storage/protectedRecordStorage.js +1139 -0
- package/build/auth/storage/protectedRecordStorage.js.map +1 -0
- package/build/auth/storage/sessionRepository.d.ts.map +1 -1
- package/build/auth/storage/sessionRepository.js +10 -0
- package/build/auth/storage/sessionRepository.js.map +1 -1
- package/build/auth/storage/upstreamOAuthStorage.d.ts +15 -0
- package/build/auth/storage/upstreamOAuthStorage.d.ts.map +1 -0
- package/build/auth/storage/upstreamOAuthStorage.js +25 -0
- package/build/auth/storage/upstreamOAuthStorage.js.map +1 -0
- package/build/auth/storage/upstreamOAuthStoragePath.d.ts +3 -0
- package/build/auth/storage/upstreamOAuthStoragePath.d.ts.map +1 -0
- package/build/auth/storage/upstreamOAuthStoragePath.js +8 -0
- package/build/auth/storage/upstreamOAuthStoragePath.js.map +1 -0
- package/build/commands/auth/exportOAuthCredentials.d.ts +9 -0
- package/build/commands/auth/exportOAuthCredentials.d.ts.map +1 -0
- package/build/commands/auth/exportOAuthCredentials.js +71 -0
- package/build/commands/auth/exportOAuthCredentials.js.map +1 -0
- package/build/commands/auth/exportUpstreamCredentials.d.ts +5 -0
- package/build/commands/auth/exportUpstreamCredentials.d.ts.map +1 -0
- package/build/commands/auth/exportUpstreamCredentials.js +6 -0
- package/build/commands/auth/exportUpstreamCredentials.js.map +1 -0
- package/build/commands/auth/index.d.ts.map +1 -1
- package/build/commands/auth/index.js +23 -1
- package/build/commands/auth/index.js.map +1 -1
- package/build/commands/inspect/inspectUtils.d.ts.map +1 -1
- package/build/commands/inspect/inspectUtils.js +2 -3
- package/build/commands/inspect/inspectUtils.js.map +1 -1
- package/build/commands/run/runUtils.js +2 -2
- package/build/commands/run/runUtils.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 +5 -0
- package/build/commands/serve/index.js.map +1 -1
- package/build/commands/serve/serveBackground.d.ts.map +1 -1
- package/build/commands/serve/serveBackground.js +1 -0
- package/build/commands/serve/serveBackground.js.map +1 -1
- package/build/config/configLoader.d.ts.map +1 -1
- package/build/config/configLoader.js +13 -0
- package/build/config/configLoader.js.map +1 -1
- package/build/config/configManager.d.ts.map +1 -1
- package/build/config/configManager.js +44 -2
- package/build/config/configManager.js.map +1 -1
- package/build/config/configWatcher.d.ts.map +1 -1
- package/build/config/configWatcher.js +3 -1
- package/build/config/configWatcher.js.map +1 -1
- package/build/config/envProcessor.d.ts.map +1 -1
- package/build/config/envProcessor.js +3 -1
- package/build/config/envProcessor.js.map +1 -1
- package/build/config/mcpConfigManager.d.ts.map +1 -1
- package/build/config/mcpConfigManager.js +4 -1
- package/build/config/mcpConfigManager.js.map +1 -1
- package/build/config/projectConfigLoader.d.ts.map +1 -1
- package/build/config/projectConfigLoader.js +7 -0
- package/build/config/projectConfigLoader.js.map +1 -1
- package/build/constants/mcp.d.ts +1 -1
- package/build/constants/mcp.js +1 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.d.ts.map +1 -1
- package/build/core/capabilities/asyncLoadingOrchestrator.js +31 -2
- package/build/core/capabilities/asyncLoadingOrchestrator.js.map +1 -1
- package/build/core/capabilities/capabilityAggregator.d.ts +3 -1
- package/build/core/capabilities/capabilityAggregator.d.ts.map +1 -1
- package/build/core/capabilities/capabilityAggregator.js +9 -2
- package/build/core/capabilities/capabilityAggregator.js.map +1 -1
- package/build/core/capabilities/capabilityCatalog.d.ts +24 -1
- package/build/core/capabilities/capabilityCatalog.d.ts.map +1 -1
- package/build/core/capabilities/capabilityCatalog.js +410 -39
- package/build/core/capabilities/capabilityCatalog.js.map +1 -1
- package/build/core/capabilities/capabilityPagination.d.ts +18 -1
- package/build/core/capabilities/capabilityPagination.d.ts.map +1 -1
- package/build/core/capabilities/capabilityPagination.js +101 -15
- package/build/core/capabilities/capabilityPagination.js.map +1 -1
- package/build/core/capabilities/capabilityVisibility.d.ts +13 -1
- package/build/core/capabilities/capabilityVisibility.d.ts.map +1 -1
- package/build/core/capabilities/capabilityVisibility.js +24 -1
- package/build/core/capabilities/capabilityVisibility.js.map +1 -1
- package/build/core/capabilities/catalogGeneration.d.ts.map +1 -1
- package/build/core/capabilities/catalogGeneration.js +20 -1
- package/build/core/capabilities/catalogGeneration.js.map +1 -1
- package/build/core/capabilities/configuredToolSnapshot.d.ts +1 -0
- package/build/core/capabilities/configuredToolSnapshot.d.ts.map +1 -1
- package/build/core/capabilities/configuredToolSnapshot.js +30 -4
- package/build/core/capabilities/configuredToolSnapshot.js.map +1 -1
- package/build/core/capabilities/lazyLoadingOrchestrator.d.ts +2 -0
- package/build/core/capabilities/lazyLoadingOrchestrator.d.ts.map +1 -1
- package/build/core/capabilities/lazyLoadingOrchestrator.js +20 -4
- package/build/core/capabilities/lazyLoadingOrchestrator.js.map +1 -1
- package/build/core/capabilities/metaToolProvider.d.ts +3 -1
- package/build/core/capabilities/metaToolProvider.d.ts.map +1 -1
- package/build/core/capabilities/metaToolProvider.js +42 -4
- package/build/core/capabilities/metaToolProvider.js.map +1 -1
- package/build/core/capabilities/runtimeCapabilityCatalog.d.ts +15 -2
- package/build/core/capabilities/runtimeCapabilityCatalog.d.ts.map +1 -1
- package/build/core/capabilities/runtimeCapabilityCatalog.js +153 -16
- package/build/core/capabilities/runtimeCapabilityCatalog.js.map +1 -1
- package/build/core/capabilities/schemaCache.d.ts.map +1 -1
- package/build/core/capabilities/schemaCache.js +41 -0
- package/build/core/capabilities/schemaCache.js.map +1 -1
- package/build/core/capabilities/schemas/metaToolSchemas.d.ts +1 -0
- package/build/core/capabilities/schemas/metaToolSchemas.d.ts.map +1 -1
- package/build/core/capabilities/schemas/metaToolSchemas.js +1 -0
- package/build/core/capabilities/schemas/metaToolSchemas.js.map +1 -1
- package/build/core/capabilities/toolRegistry.d.ts +7 -3
- package/build/core/capabilities/toolRegistry.d.ts.map +1 -1
- package/build/core/capabilities/toolRegistry.js +28 -9
- package/build/core/capabilities/toolRegistry.js.map +1 -1
- package/build/core/instructions/instructionAggregator.d.ts.map +1 -1
- package/build/core/instructions/instructionAggregator.js +3 -1
- package/build/core/instructions/instructionAggregator.js.map +1 -1
- package/build/core/instructions/templateTypes.d.ts +1 -1
- package/build/core/instructions/templateTypes.d.ts.map +1 -1
- package/build/core/instructions/templateTypes.js +3 -3
- package/build/core/loading/loadingStateTracker.d.ts.map +1 -1
- package/build/core/loading/loadingStateTracker.js +11 -2
- package/build/core/loading/loadingStateTracker.js.map +1 -1
- package/build/core/loading/mcpLoadingManager.d.ts.map +1 -1
- package/build/core/loading/mcpLoadingManager.js +6 -2
- package/build/core/loading/mcpLoadingManager.js.map +1 -1
- package/build/core/protocol/requestHandlerUtils.d.ts +2 -2
- package/build/core/protocol/requestHandlerUtils.d.ts.map +1 -1
- package/build/core/protocol/requestHandlerUtils.js +7 -4
- package/build/core/protocol/requestHandlerUtils.js.map +1 -1
- package/build/core/server/agentConfig.d.ts +1 -0
- package/build/core/server/agentConfig.d.ts.map +1 -1
- package/build/core/server/agentConfig.js +1 -0
- package/build/core/server/agentConfig.js.map +1 -1
- package/build/core/server/disabledTools.d.ts +1 -1
- package/build/core/server/disabledTools.d.ts.map +1 -1
- package/build/core/server/disabledTools.js +18 -25
- package/build/core/server/disabledTools.js.map +1 -1
- package/build/core/server/processIdentity.d.ts.map +1 -1
- package/build/core/server/processIdentity.js +67 -18
- package/build/core/server/processIdentity.js.map +1 -1
- package/build/core/server/runtimeLaunchIpc.d.ts +14 -1
- package/build/core/server/runtimeLaunchIpc.d.ts.map +1 -1
- package/build/core/server/runtimeReplacementConfig.d.ts +14 -1
- package/build/core/server/runtimeReplacementConfig.d.ts.map +1 -1
- package/build/core/server/toolDescriptionOverrides.d.ts +1 -0
- package/build/core/server/toolDescriptionOverrides.d.ts.map +1 -1
- package/build/core/server/toolDescriptionOverrides.js +30 -5
- package/build/core/server/toolDescriptionOverrides.js.map +1 -1
- package/build/core/tools/handlers/serverManagementHandler.d.ts +21 -0
- package/build/core/tools/handlers/serverManagementHandler.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts +3 -0
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts.map +1 -1
- package/build/core/tools/internal/schemas/discovery.d.ts +1 -1
- package/build/core/tools/internal/schemas/index.d.ts +1 -1
- package/build/core/types/transport.d.ts +25 -2
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +12 -0
- package/build/core/types/transport.js.map +1 -1
- package/build/domains/admin/configuredToolInventory.d.ts.map +1 -1
- package/build/domains/admin/configuredToolInventory.js +47 -9
- package/build/domains/admin/configuredToolInventory.js.map +1 -1
- package/build/domains/admin/runtimeConfiguredToolInspectionService.d.ts.map +1 -1
- package/build/domains/admin/runtimeConfiguredToolInspectionService.js +13 -3
- package/build/domains/admin/runtimeConfiguredToolInspectionService.js.map +1 -1
- package/build/gateway/adapters/modern/modernInboundEraAdapter.d.ts.map +1 -1
- package/build/gateway/adapters/modern/modernInboundEraAdapter.js +3 -3
- package/build/gateway/adapters/modern/modernInboundEraAdapter.js.map +1 -1
- package/build/gateway/adapters/modern/modernOutboundEraAdapter.d.ts.map +1 -1
- package/build/gateway/adapters/modern/modernOutboundEraAdapter.js +4 -0
- package/build/gateway/adapters/modern/modernOutboundEraAdapter.js.map +1 -1
- package/build/gateway/contracts/gatewayFailure.d.ts +39 -1
- package/build/gateway/contracts/gatewayFailure.d.ts.map +1 -1
- package/build/gateway/contracts/gatewayFailure.js +139 -0
- package/build/gateway/contracts/gatewayFailure.js.map +1 -1
- package/build/gateway/interactions/nativeInputResponses.d.ts +16 -0
- package/build/gateway/interactions/nativeInputResponses.d.ts.map +1 -0
- package/build/gateway/interactions/nativeInputResponses.js +76 -0
- package/build/gateway/interactions/nativeInputResponses.js.map +1 -0
- package/build/gateway/interactions/validateInteractionResponse.d.ts.map +1 -1
- package/build/gateway/interactions/validateInteractionResponse.js +20 -1
- package/build/gateway/interactions/validateInteractionResponse.js.map +1 -1
- package/build/gateway/ports/outboundEraAdapter.d.ts +2 -0
- package/build/gateway/ports/outboundEraAdapter.d.ts.map +1 -1
- package/build/logger/diagnosticRedaction.d.ts +3 -0
- package/build/logger/diagnosticRedaction.d.ts.map +1 -0
- package/build/logger/diagnosticRedaction.js +12 -0
- package/build/logger/diagnosticRedaction.js.map +1 -0
- package/build/logger/httpDiagnostics.d.ts +25 -0
- package/build/logger/httpDiagnostics.d.ts.map +1 -0
- package/build/logger/httpDiagnostics.js +125 -0
- package/build/logger/httpDiagnostics.js.map +1 -0
- package/build/logger/localDiagnosticRecord.d.ts +11 -0
- package/build/logger/localDiagnosticRecord.d.ts.map +1 -0
- package/build/logger/localDiagnosticRecord.js +9 -0
- package/build/logger/localDiagnosticRecord.js.map +1 -0
- package/build/logger/localDiagnostics.d.ts +5 -0
- package/build/logger/localDiagnostics.d.ts.map +1 -0
- package/build/logger/localDiagnostics.js +116 -0
- package/build/logger/localDiagnostics.js.map +1 -0
- package/build/logger/logger.d.ts +7 -0
- package/build/logger/logger.d.ts.map +1 -1
- package/build/logger/logger.js +14 -0
- package/build/logger/logger.js.map +1 -1
- package/build/observability/events/registry.d.ts +163 -49
- package/build/observability/events/registry.d.ts.map +1 -1
- package/build/observability/events/registry.js +136 -49
- package/build/observability/events/registry.js.map +1 -1
- package/build/observability/privacy/fields.d.ts +3 -1
- package/build/observability/privacy/fields.d.ts.map +1 -1
- package/build/observability/privacy/fields.js +23 -0
- package/build/observability/privacy/fields.js.map +1 -1
- package/build/sdk/contracts/catalogCoverageInvalidation.d.ts +4 -0
- package/build/sdk/contracts/catalogCoverageInvalidation.d.ts.map +1 -0
- package/build/sdk/contracts/catalogCoverageInvalidation.js +13 -0
- package/build/sdk/contracts/catalogCoverageInvalidation.js.map +1 -0
- package/build/sdk/contracts/mcpParamHeaders.d.ts +17 -0
- package/build/sdk/contracts/mcpParamHeaders.d.ts.map +1 -0
- package/build/sdk/contracts/mcpParamHeaders.js +134 -0
- package/build/sdk/contracts/mcpParamHeaders.js.map +1 -0
- package/build/sdk/contracts/requestProgress.d.ts +29 -0
- package/build/sdk/contracts/requestProgress.d.ts.map +1 -0
- package/build/sdk/contracts/requestProgress.js +126 -0
- package/build/sdk/contracts/requestProgress.js.map +1 -0
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.d.ts +77 -84
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.d.ts.map +1 -1
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.js +632 -209
- package/build/sdk/legacy/auth/sdkOAuthClientProvider.js.map +1 -1
- package/build/sdk/legacy/auth/sdkOAuthServerProvider.d.ts.map +1 -1
- package/build/sdk/legacy/auth/sdkOAuthServerProvider.js +25 -7
- package/build/sdk/legacy/auth/sdkOAuthServerProvider.js.map +1 -1
- package/build/sdk/legacy/client/runtime/clientManager.d.ts +5 -1
- package/build/sdk/legacy/client/runtime/clientManager.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/clientManager.js +213 -6
- package/build/sdk/legacy/client/runtime/clientManager.js.map +1 -1
- package/build/sdk/legacy/client/runtime/connectionHandler.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/connectionHandler.js +70 -4
- package/build/sdk/legacy/client/runtime/connectionHandler.js.map +1 -1
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.d.ts +2 -1
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.js +11 -2
- package/build/sdk/legacy/client/runtime/legacyInteractionLease.js.map +1 -1
- package/build/sdk/legacy/client/runtime/legacySdkClientAdapter.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/legacySdkClientAdapter.js +28 -2
- package/build/sdk/legacy/client/runtime/legacySdkClientAdapter.js.map +1 -1
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.d.ts +2 -0
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.d.ts.map +1 -0
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.js +2 -0
- package/build/sdk/legacy/client/runtime/mcpParamHeaders.js.map +1 -0
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.d.ts +6 -0
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.js +117 -6
- package/build/sdk/legacy/client/runtime/modernSdkClientAdapter.js.map +1 -1
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.d.ts +1 -1
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.d.ts.map +1 -1
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.js +68 -16
- package/build/sdk/legacy/client/runtime/oauthFlowHandler.js.map +1 -1
- package/build/sdk/legacy/commands/serve.d.ts +1 -0
- package/build/sdk/legacy/commands/serve.d.ts.map +1 -1
- package/build/sdk/legacy/commands/serve.js +28 -2
- package/build/sdk/legacy/commands/serve.js.map +1 -1
- package/build/sdk/legacy/server/protocol/notificationHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/notificationHandlers.js +2 -6
- package/build/sdk/legacy/server/protocol/notificationHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.d.ts +1 -1
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.js +31 -11
- package/build/sdk/legacy/server/protocol/privateInteractionConnection.js.map +1 -1
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.js +4 -4
- package/build/sdk/legacy/server/protocol/promptRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/requestInteractionScope.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/requestInteractionScope.js +62 -10
- package/build/sdk/legacy/server/protocol/requestInteractionScope.js.map +1 -1
- package/build/sdk/legacy/server/protocol/requestProviderProgress.d.ts +8 -0
- package/build/sdk/legacy/server/protocol/requestProviderProgress.d.ts.map +1 -0
- package/build/sdk/legacy/server/protocol/requestProviderProgress.js +29 -0
- package/build/sdk/legacy/server/protocol/requestProviderProgress.js.map +1 -0
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js +20 -2
- package/build/sdk/legacy/server/protocol/resourceRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.d.ts.map +1 -1
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.js +151 -60
- package/build/sdk/legacy/server/protocol/toolRequestHandlers.js.map +1 -1
- package/build/sdk/legacy/server/retained-sdk/LICENSE +21 -0
- package/build/sdk/legacy/server/retained-sdk/provenance.json +17 -0
- package/build/sdk/legacy/server/retained-sdk/streamableHttp.js +160 -0
- package/build/sdk/legacy/server/retained-sdk/webStandardStreamableHttp.js +950 -0
- package/build/sdk/legacy/server/runtime/clientInstancePool.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/clientInstancePool.js +34 -6
- package/build/sdk/legacy/server/runtime/clientInstancePool.js.map +1 -1
- package/build/sdk/legacy/server/runtime/mcpLoggingEnhancer.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/mcpLoggingEnhancer.js +4 -2
- package/build/sdk/legacy/server/runtime/mcpLoggingEnhancer.js.map +1 -1
- package/build/sdk/legacy/server/runtime/serverManager.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/serverManager.js +3 -1
- package/build/sdk/legacy/server/runtime/serverManager.js.map +1 -1
- package/build/sdk/legacy/server/runtime/templateServerManager.d.ts.map +1 -1
- package/build/sdk/legacy/server/runtime/templateServerManager.js +32 -7
- package/build/sdk/legacy/server/runtime/templateServerManager.js.map +1 -1
- package/build/sdk/legacy/server/streamableHttp.js +1 -1
- package/build/sdk/legacy/shared/resourceTemplateRouting.d.ts.map +1 -1
- package/build/sdk/legacy/shared/resourceTemplateRouting.js +29 -11
- package/build/sdk/legacy/shared/resourceTemplateRouting.js.map +1 -1
- package/build/sdk/legacy/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -1
- package/build/sdk/legacy/transport/http/middlewares/scopeAuthMiddleware.js +12 -1
- package/build/sdk/legacy/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -1
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.d.ts +4 -0
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.d.ts.map +1 -1
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js +11 -0
- package/build/sdk/legacy/transport/http/modernInboundLegacyBridge.js.map +1 -1
- package/build/sdk/legacy/transport/http/server.d.ts.map +1 -1
- package/build/sdk/legacy/transport/http/server.js +16 -2
- package/build/sdk/legacy/transport/http/server.js.map +1 -1
- package/build/sdk/legacy/transport/transportFactory.d.ts.map +1 -1
- package/build/sdk/legacy/transport/transportFactory.js +34 -12
- package/build/sdk/legacy/transport/transportFactory.js.map +1 -1
- package/build/transport/http/middlewares/httpRequestLogger.d.ts +4 -2
- package/build/transport/http/middlewares/httpRequestLogger.d.ts.map +1 -1
- package/build/transport/http/middlewares/httpRequestLogger.js +135 -16
- package/build/transport/http/middlewares/httpRequestLogger.js.map +1 -1
- package/build/transport/http/routes/cliTokenRoute.d.ts.map +1 -1
- package/build/transport/http/routes/cliTokenRoute.js +1 -0
- package/build/transport/http/routes/cliTokenRoute.js.map +1 -1
- package/build/transport/http/routes/healthRoutes.d.ts +11 -1
- package/build/transport/http/routes/healthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/healthRoutes.js +6 -2
- package/build/transport/http/routes/healthRoutes.js.map +1 -1
- package/build/transport/http/routes/inspectHelpers.d.ts.map +1 -1
- package/build/transport/http/routes/inspectHelpers.js +4 -3
- package/build/transport/http/routes/inspectHelpers.js.map +1 -1
- package/build/transport/http/routes/modernHttpRoutes.d.ts +4 -0
- package/build/transport/http/routes/modernHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/modernHttpRoutes.js +168 -24
- package/build/transport/http/routes/modernHttpRoutes.js.map +1 -1
- package/build/transport/http/routes/modernInteractionBinding.d.ts +2 -1
- package/build/transport/http/routes/modernInteractionBinding.d.ts.map +1 -1
- package/build/transport/http/routes/modernInteractionBinding.js +7 -4
- package/build/transport/http/routes/modernInteractionBinding.js.map +1 -1
- package/build/transport/http/routes/modernToolHeaderRegistry.d.ts +16 -0
- package/build/transport/http/routes/modernToolHeaderRegistry.d.ts.map +1 -0
- package/build/transport/http/routes/modernToolHeaderRegistry.js +161 -0
- package/build/transport/http/routes/modernToolHeaderRegistry.js.map +1 -0
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +6 -3
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/toolRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/toolRoutes.js +18 -2
- package/build/transport/http/routes/toolRoutes.js.map +1 -1
- package/build/utils/core/parsing.d.ts +2 -0
- package/build/utils/core/parsing.d.ts.map +1 -1
- package/build/utils/core/parsing.js +19 -0
- package/build/utils/core/parsing.js.map +1 -1
- package/build/utils/core/resourceUris.d.ts +6 -0
- package/build/utils/core/resourceUris.d.ts.map +1 -0
- package/build/utils/core/resourceUris.js +104 -0
- package/build/utils/core/resourceUris.js.map +1 -0
- package/build/utils/core/toolNames.d.ts +8 -0
- package/build/utils/core/toolNames.d.ts.map +1 -0
- package/build/utils/core/toolNames.js +56 -0
- package/build/utils/core/toolNames.js.map +1 -0
- package/package.json +68 -64
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
1
2
|
import { requestLegacyAdapter } from '../client/legacyAdapterRequest.js';
|
|
2
3
|
import { ConnectionResolver } from '../server/connectionResolver.js';
|
|
3
4
|
import { getDisabledSourceToolError, isSourceToolDisabled } from '../server/disabledTools.js';
|
|
5
|
+
import { parseTemplateConnectionKey } from '../server/templateIdentity.js';
|
|
4
6
|
import { applySourceToolDescription } from '../server/toolDescriptionOverrides.js';
|
|
5
7
|
import { ClientStatus, } from '../types/index.js';
|
|
6
8
|
import { SchemaBoundaryError } from '../validation/schemaBoundary.js';
|
|
7
9
|
import { admitToolSchemas, prepareToolValidation, projectToolSchemas, schemaInputErrorResult, } from '../validation/toolSchemaBoundary.js';
|
|
8
10
|
import { gatewayFailureFromUnknown } from '../../gateway/contracts/gatewayFailure.js';
|
|
11
|
+
import { writeLocalDiagnostic } from '../../logger/localDiagnostics.js';
|
|
9
12
|
import logger from '../../logger/logger.js';
|
|
10
|
-
import {
|
|
13
|
+
import { ownData } from '../../observability/privacy/fields.js';
|
|
14
|
+
import { ErrorCode } from '../../sdk/contracts/index.js';
|
|
15
|
+
import { MCPError } from '../../utils/core/errorTypes.js';
|
|
16
|
+
import { buildPublicToolName } from '../../utils/core/toolNames.js';
|
|
17
|
+
import { CAPABILITY_PAGINATION_META_KEY, getCapabilityFailureFacts, getCapabilityPaginationGeneration, setCapabilityFailureFacts, walkCapabilityPages, } from './capabilityPagination.js';
|
|
11
18
|
import { getCapabilityVisibleServerNames } from './capabilityVisibility.js';
|
|
12
19
|
import { ToolRegistry } from './toolRegistry.js';
|
|
13
20
|
const NEVER_REFRESH = {
|
|
@@ -16,12 +23,58 @@ const NEVER_REFRESH = {
|
|
|
16
23
|
changed: false,
|
|
17
24
|
shouldNotifyListChanged: false,
|
|
18
25
|
};
|
|
26
|
+
const catalogCursorOwners = new WeakMap();
|
|
27
|
+
const contextCatalogCursorOwners = new WeakMap();
|
|
28
|
+
const visibilityCatalogCursorOwners = new WeakMap();
|
|
29
|
+
/** Listener-owned authority; never reconstructed from transport fields or serialized data. */
|
|
30
|
+
export function createCatalogCursorOwner() {
|
|
31
|
+
const owner = Object.freeze({});
|
|
32
|
+
catalogCursorOwners.set(owner, Date.now() + TOOL_LISTING_TTL_MS);
|
|
33
|
+
return owner;
|
|
34
|
+
}
|
|
35
|
+
export function revokeCatalogCursorOwner(owner) {
|
|
36
|
+
catalogCursorOwners.delete(owner);
|
|
37
|
+
}
|
|
38
|
+
export function isCatalogCursorOwnerCurrent(owner) {
|
|
39
|
+
const expiresAt = catalogCursorOwners.get(owner);
|
|
40
|
+
return expiresAt !== undefined && expiresAt > Date.now();
|
|
41
|
+
}
|
|
42
|
+
export function bindCatalogCursorOwner(context, owner) {
|
|
43
|
+
if (!isCatalogCursorOwnerCurrent(owner))
|
|
44
|
+
throw new MCPError('Capability cursor owner is unavailable', ErrorCode.InvalidParams);
|
|
45
|
+
contextCatalogCursorOwners.set(context, owner);
|
|
46
|
+
}
|
|
47
|
+
export function attachCatalogCursorOwner(visibility, context) {
|
|
48
|
+
const owner = context && contextCatalogCursorOwners.get(context);
|
|
49
|
+
// Preserve revoked identity: a request cannot silently fall back to session authority.
|
|
50
|
+
if (owner)
|
|
51
|
+
visibilityCatalogCursorOwners.set(visibility, owner);
|
|
52
|
+
}
|
|
53
|
+
const TOOL_LISTING_TTL_MS = 15 * 60 * 1000;
|
|
54
|
+
const MAX_TOOL_LISTING_SNAPSHOTS = 1000;
|
|
55
|
+
const MAX_TOOL_LISTING_BYTES = 32 * 1024 * 1024;
|
|
56
|
+
const MAX_VISIBILITY_TOOL_LISTINGS = 250;
|
|
57
|
+
const MAX_VISIBILITY_TOOL_LISTING_BYTES = 8 * 1024 * 1024;
|
|
58
|
+
const MAX_ACTIVE_TOOL_ADMISSIONS = 1000;
|
|
59
|
+
const MAX_TOOL_ADMISSION_OUTCOMES = 32768;
|
|
60
|
+
const toolListingStates = new WeakMap();
|
|
19
61
|
export class CapabilityCatalog {
|
|
20
62
|
deps;
|
|
21
63
|
connectionResolver;
|
|
64
|
+
toolListings;
|
|
65
|
+
withheldTools;
|
|
66
|
+
listingState;
|
|
22
67
|
constructor(deps) {
|
|
23
68
|
this.deps = deps;
|
|
24
69
|
this.connectionResolver = new ConnectionResolver(deps.outboundConnections, deps.templateHashProvider);
|
|
70
|
+
let state = toolListingStates.get(deps.outboundConnections);
|
|
71
|
+
if (!state) {
|
|
72
|
+
state = { listings: new Map(), withheldTools: new Map(), activeAttempts: new Set(), nextAttempt: 0 };
|
|
73
|
+
toolListingStates.set(deps.outboundConnections, state);
|
|
74
|
+
}
|
|
75
|
+
this.toolListings = state.listings;
|
|
76
|
+
this.withheldTools = state.withheldTools;
|
|
77
|
+
this.listingState = state;
|
|
25
78
|
}
|
|
26
79
|
/**
|
|
27
80
|
* List one aggregate page while keeping provider traversal, cursor binding, and
|
|
@@ -85,49 +138,290 @@ export class CapabilityCatalog {
|
|
|
85
138
|
});
|
|
86
139
|
}
|
|
87
140
|
async listVisibleTools(options = {}, visibility, queryOptions = {}) {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
141
|
+
const continuation = this.decodeToolListingCursor(options.cursor);
|
|
142
|
+
const effectiveVisibility = visibility ?? this.deps.defaultVisibility;
|
|
143
|
+
const owner = effectiveVisibility && visibilityCatalogCursorOwners.get(effectiveVisibility);
|
|
144
|
+
const assertOwnerCurrent = () => {
|
|
145
|
+
if (owner && !isCatalogCursorOwnerCurrent(owner)) {
|
|
146
|
+
throw new MCPError('Capability cursor owner is unavailable', ErrorCode.InvalidParams);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
assertOwnerCurrent();
|
|
150
|
+
const visibilityKey = this.toolListingVisibility(visibility);
|
|
151
|
+
if (continuation) {
|
|
152
|
+
const snapshot = this.toolListings.get(continuation.walk);
|
|
153
|
+
if (!snapshot ||
|
|
154
|
+
snapshot.expiresAt <= Date.now() ||
|
|
155
|
+
snapshot.owner !== owner ||
|
|
156
|
+
snapshot.visibility !== visibilityKey ||
|
|
157
|
+
snapshot.generation !== getCapabilityPaginationGeneration(this.deps.outboundConnections, 'tools') ||
|
|
158
|
+
!snapshot.registry.isCurrent()) {
|
|
159
|
+
throw new MCPError('Invalid capability pagination cursor', ErrorCode.InvalidParams);
|
|
160
|
+
}
|
|
161
|
+
return this.toolListingPage(continuation.walk, snapshot, { ...options, cursor: continuation.cursor }, visibility);
|
|
162
|
+
}
|
|
163
|
+
await this.pruneToolAdmissionOutcomes(queryOptions.toolRegistry);
|
|
164
|
+
if (this.listingState.activeAttempts.size >= MAX_ACTIVE_TOOL_ADMISSIONS) {
|
|
165
|
+
throw new MCPError('Capability admission capacity exceeded', -32000);
|
|
166
|
+
}
|
|
167
|
+
const attempt = ++this.listingState.nextAttempt;
|
|
168
|
+
this.listingState.activeAttempts.add(attempt);
|
|
169
|
+
try {
|
|
170
|
+
const refresh = await this.resolveRefreshFacts(queryOptions.refreshIntent ?? 'never', 'list');
|
|
171
|
+
const sourceRegistry = queryOptions.toolRegistry ?? (await this.deps.getToolRegistry());
|
|
172
|
+
const registry = await this.visibleToolRegistry(visibility, sourceRegistry);
|
|
173
|
+
const admitted = [];
|
|
174
|
+
const timedOutSources = [];
|
|
175
|
+
const serverNames = Array.from(new Set(registry.getAllTools().map((tool) => tool.server))).sort();
|
|
176
|
+
const configSignature = this.toolListingConfigSignature(serverNames);
|
|
177
|
+
const currentConnections = new Map(registry.getAllTools().flatMap((tool) => {
|
|
178
|
+
const key = tool.connectionKey ?? tool.server;
|
|
179
|
+
const connection = this.deps.outboundConnections.get(key);
|
|
180
|
+
return connection ? [[key, connection]] : [];
|
|
181
|
+
}));
|
|
182
|
+
const currentAdapters = new Map(Array.from(currentConnections, ([key, connection]) => [key, connection.adapter]));
|
|
183
|
+
const isListingCurrent = () => registry.isCurrent() &&
|
|
184
|
+
this.toolListingConfigSignature(serverNames) === configSignature &&
|
|
185
|
+
Array.from(currentConnections).every(([key, connection]) => this.deps.outboundConnections.get(key) === connection &&
|
|
186
|
+
connection.adapter === currentAdapters.get(key) &&
|
|
187
|
+
connection.status === ClientStatus.Connected);
|
|
188
|
+
for (const tool of registry.getAllTools()) {
|
|
93
189
|
const key = tool.connectionKey ?? tool.server;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
tool
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
190
|
+
try {
|
|
191
|
+
const definition = tool.definition ??
|
|
192
|
+
this.deps.schemaCache.getIfCached(key, tool.name) ??
|
|
193
|
+
(this.deps.loadSchema ? await this.deps.loadSchema(key, tool.name, queryOptions.signal) : undefined);
|
|
194
|
+
if (!definition)
|
|
195
|
+
continue;
|
|
196
|
+
const contracts = await admitToolSchemas(definition, {
|
|
197
|
+
routeKey: JSON.stringify([key, tool.name]),
|
|
198
|
+
generation: this.deps.outboundConnections.get(key)?.adapter.connectionId ?? 'internal',
|
|
199
|
+
sourceRevision: this.deps.outboundConnections.get(key)?.adapter.protocolRevision,
|
|
200
|
+
signal: queryOptions.signal,
|
|
201
|
+
});
|
|
202
|
+
this.recordToolAdmission(JSON.stringify([key, tool.name]), attempt, false, sourceRegistry, currentConnections.get(key), currentAdapters.get(key));
|
|
203
|
+
admitted.push({
|
|
204
|
+
tool: projectToolSchemas(definition, contracts),
|
|
205
|
+
server: tool.server,
|
|
206
|
+
connectionKey: key,
|
|
207
|
+
tags: tool.tags,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
if (!(error instanceof SchemaBoundaryError))
|
|
212
|
+
throw error;
|
|
213
|
+
if (tool.route?.origin === 'internal')
|
|
214
|
+
throw error;
|
|
215
|
+
if (!this.deps.outboundConnections.has(key))
|
|
216
|
+
throw error;
|
|
217
|
+
if (error.phase !== 'admission')
|
|
218
|
+
throw error;
|
|
219
|
+
if (error.code === 'schema_evaluation_unavailable')
|
|
220
|
+
throw error;
|
|
221
|
+
if (error.code === 'schema_evaluation_timeout') {
|
|
222
|
+
timedOutSources.push(key);
|
|
223
|
+
this.recordToolAdmission(JSON.stringify([key, tool.name]), attempt, true, sourceRegistry, currentConnections.get(key), currentAdapters.get(key));
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (error.retryable)
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
111
229
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
230
|
+
assertOwnerCurrent();
|
|
231
|
+
if (!isListingCurrent()) {
|
|
232
|
+
throw new MCPError('Capability catalog changed during listing', -32000, { retryable: true });
|
|
115
233
|
}
|
|
234
|
+
const generation = getCapabilityPaginationGeneration(this.deps.outboundConnections, 'tools');
|
|
235
|
+
const meta = this.toolAdmissionMeta(registry.getListingMeta(), timedOutSources, generation);
|
|
236
|
+
const snapshot = {
|
|
237
|
+
owner,
|
|
238
|
+
registry: ToolRegistry.fromToolsWithServer(admitted, meta).withConnections(registry.getConnections(), () => registry.isCurrent() &&
|
|
239
|
+
this.toolListingConfigSignature(serverNames) === configSignature &&
|
|
240
|
+
Array.from(currentConnections).every(([key, connection]) => this.deps.outboundConnections.get(key) === connection &&
|
|
241
|
+
connection.adapter === currentAdapters.get(key) &&
|
|
242
|
+
connection.status === ClientStatus.Connected)),
|
|
243
|
+
generation,
|
|
244
|
+
visibility: visibilityKey,
|
|
245
|
+
refresh,
|
|
246
|
+
expiresAt: Date.now() + TOOL_LISTING_TTL_MS,
|
|
247
|
+
bytes: 0,
|
|
248
|
+
};
|
|
249
|
+
const walk = randomUUID();
|
|
250
|
+
for (const [id, saved] of this.toolListings) {
|
|
251
|
+
if (saved.expiresAt <= Date.now() || (saved.owner && !isCatalogCursorOwnerCurrent(saved.owner)))
|
|
252
|
+
this.toolListings.delete(id);
|
|
253
|
+
}
|
|
254
|
+
const result = this.toolListingPage(walk, snapshot, { ...options, cursor: undefined }, visibility);
|
|
255
|
+
if (result.nextCursor) {
|
|
256
|
+
snapshot.bytes = Buffer.byteLength(JSON.stringify(snapshot.registry.getAllTools()));
|
|
257
|
+
const visibilityListings = Array.from(this.toolListings.values()).filter((saved) => saved.owner === owner && saved.visibility === visibilityKey);
|
|
258
|
+
const visibilityBytes = visibilityListings.reduce((total, saved) => total + saved.bytes, 0);
|
|
259
|
+
if (visibilityListings.length >= MAX_VISIBILITY_TOOL_LISTINGS) {
|
|
260
|
+
throw new MCPError('Capability cursor capacity exceeded', -32000);
|
|
261
|
+
}
|
|
262
|
+
if (visibilityBytes + snapshot.bytes > MAX_VISIBILITY_TOOL_LISTING_BYTES) {
|
|
263
|
+
throw new MCPError('Capability cursor capacity exceeded', -32000);
|
|
264
|
+
}
|
|
265
|
+
const capturedBytes = Array.from(this.toolListings.values()).reduce((total, saved) => total + saved.bytes, 0);
|
|
266
|
+
if (capturedBytes + snapshot.bytes > MAX_TOOL_LISTING_BYTES) {
|
|
267
|
+
throw new MCPError('Capability cursor capacity exceeded', -32000);
|
|
268
|
+
}
|
|
269
|
+
if (this.toolListings.size >= MAX_TOOL_LISTING_SNAPSHOTS) {
|
|
270
|
+
throw new MCPError('Capability cursor capacity exceeded', -32000);
|
|
271
|
+
}
|
|
272
|
+
assertOwnerCurrent();
|
|
273
|
+
this.toolListings.set(walk, snapshot);
|
|
274
|
+
// Only publication of a new bounded walk grants its full issuance lifetime.
|
|
275
|
+
// Continuations retain their snapshot deadline and cannot renew authority.
|
|
276
|
+
if (owner)
|
|
277
|
+
catalogCursorOwners.set(owner, Math.max(catalogCursorOwners.get(owner), snapshot.expiresAt));
|
|
278
|
+
}
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
this.listingState.activeAttempts.delete(attempt);
|
|
283
|
+
await this.pruneToolAdmissionOutcomes(queryOptions.toolRegistry);
|
|
284
|
+
assertOwnerCurrent();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async pruneToolAdmissionOutcomes(requestRegistry) {
|
|
288
|
+
const currentRegistry = requestRegistry ?? (await this.deps.getToolRegistry());
|
|
289
|
+
const oldestAttempt = Math.min(...this.listingState.activeAttempts);
|
|
290
|
+
for (const [key, outcome] of this.withheldTools) {
|
|
291
|
+
if (!outcome.withheld) {
|
|
292
|
+
if (outcome.attempt <= oldestAttempt)
|
|
293
|
+
this.withheldTools.delete(key);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const [connectionKey] = JSON.parse(key);
|
|
297
|
+
const connection = this.deps.outboundConnections.get(connectionKey);
|
|
298
|
+
const obsolete = outcome.registry !== currentRegistry ||
|
|
299
|
+
outcome.connection !== connection ||
|
|
300
|
+
outcome.adapter !== connection?.adapter;
|
|
301
|
+
if (!obsolete)
|
|
302
|
+
continue;
|
|
303
|
+
if (outcome.attempt > oldestAttempt) {
|
|
304
|
+
this.withheldTools.set(key, { attempt: outcome.attempt, withheld: false });
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.withheldTools.delete(key);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
recordToolAdmission(key, attempt, withheld, registry, connection, adapter) {
|
|
312
|
+
const previous = this.withheldTools.get(key);
|
|
313
|
+
if (previous && previous.attempt > attempt)
|
|
314
|
+
return;
|
|
315
|
+
const [connectionKey] = JSON.parse(key);
|
|
316
|
+
const currentConnection = this.deps.outboundConnections.get(connectionKey);
|
|
317
|
+
if (connection !== currentConnection || adapter !== currentConnection?.adapter)
|
|
318
|
+
return;
|
|
319
|
+
if (!withheld && !Array.from(this.listingState.activeAttempts).some((active) => active < attempt)) {
|
|
320
|
+
this.withheldTools.delete(key);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (!this.withheldTools.has(key) && this.withheldTools.size >= MAX_TOOL_ADMISSION_OUTCOMES) {
|
|
324
|
+
throw new MCPError('Capability admission capacity exceeded', -32000);
|
|
116
325
|
}
|
|
117
|
-
|
|
326
|
+
if (!withheld) {
|
|
327
|
+
this.withheldTools.set(key, { attempt, withheld: false });
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.withheldTools.set(key, { attempt, withheld: true, registry, connection, adapter });
|
|
331
|
+
}
|
|
332
|
+
toolListingConfigSignature(serverNames) {
|
|
333
|
+
const configs = this.deps.getServerConfigs();
|
|
334
|
+
return createHash('sha256')
|
|
335
|
+
.update(JSON.stringify(serverNames.map((name) => [name, configs[name]])))
|
|
336
|
+
.digest('hex');
|
|
337
|
+
}
|
|
338
|
+
toolListingPage(walk, snapshot, options, visibility) {
|
|
339
|
+
const result = snapshot.registry.listTools(options);
|
|
118
340
|
const tools = result.tools;
|
|
119
|
-
const servers = Array.from(new Set(tools.map((tool) => tool.server))).sort();
|
|
120
|
-
const routes = tools
|
|
121
|
-
.map((tool) => this.resolveRoute(tool, visibility))
|
|
122
|
-
.filter((route) => route !== undefined);
|
|
123
341
|
return {
|
|
124
342
|
...result,
|
|
343
|
+
...(result.nextCursor
|
|
344
|
+
? { nextCursor: Buffer.from(JSON.stringify({ walk, cursor: result.nextCursor })).toString('base64url') }
|
|
345
|
+
: {}),
|
|
125
346
|
tools,
|
|
126
|
-
servers,
|
|
127
|
-
routes
|
|
128
|
-
|
|
347
|
+
servers: Array.from(new Set(tools.map((tool) => tool.server))).sort(),
|
|
348
|
+
routes: tools
|
|
349
|
+
.map((tool) => this.resolveRoute(tool, visibility))
|
|
350
|
+
.filter((route) => route !== undefined),
|
|
351
|
+
refresh: snapshot.refresh,
|
|
129
352
|
};
|
|
130
353
|
}
|
|
354
|
+
decodeToolListingCursor(cursor) {
|
|
355
|
+
if (!cursor)
|
|
356
|
+
return undefined;
|
|
357
|
+
if (cursor.length > 4096)
|
|
358
|
+
throw new MCPError('Invalid capability pagination cursor', ErrorCode.InvalidParams);
|
|
359
|
+
try {
|
|
360
|
+
const decoded = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
|
|
361
|
+
if (!decoded || typeof decoded !== 'object' || !('walk' in decoded)) {
|
|
362
|
+
throw new MCPError('Invalid capability pagination cursor', ErrorCode.InvalidParams);
|
|
363
|
+
}
|
|
364
|
+
if (typeof decoded.walk !== 'string' || !('cursor' in decoded) || typeof decoded.cursor !== 'string') {
|
|
365
|
+
throw new MCPError('Invalid capability pagination cursor', ErrorCode.InvalidParams);
|
|
366
|
+
}
|
|
367
|
+
return { walk: decoded.walk, cursor: decoded.cursor };
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
if (error instanceof MCPError)
|
|
371
|
+
throw error;
|
|
372
|
+
throw new MCPError('Invalid capability pagination cursor', ErrorCode.InvalidParams);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
toolListingVisibility(visibility) {
|
|
376
|
+
const effective = visibility ?? this.deps.defaultVisibility;
|
|
377
|
+
const owner = effective && visibilityCatalogCursorOwners.get(effective);
|
|
378
|
+
const staticCandidates = effective &&
|
|
379
|
+
Array.from(effective.serverCandidates.keys()).every((key) => parseTemplateConnectionKey(key).kind === 'static');
|
|
380
|
+
return JSON.stringify({
|
|
381
|
+
sessionId: owner && staticCandidates ? undefined : effective?.sessionId,
|
|
382
|
+
candidates: effective ? Array.from(effective.serverCandidates).sort(([a], [b]) => a.localeCompare(b)) : null,
|
|
383
|
+
filters: effective?.filterSelection,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
async requiresToolListingRecovery(visibility) {
|
|
387
|
+
return (await this.visibleToolRegistry(visibility)).getListingMeta() !== undefined;
|
|
388
|
+
}
|
|
389
|
+
toolAdmissionMeta(inherited, timedOutSources, generation) {
|
|
390
|
+
if (timedOutSources.length === 0)
|
|
391
|
+
return inherited;
|
|
392
|
+
const facts = new Map(getCapabilityFailureFacts(inherited));
|
|
393
|
+
for (const source of timedOutSources) {
|
|
394
|
+
const previous = facts.get(source);
|
|
395
|
+
facts.set(source, {
|
|
396
|
+
...previous,
|
|
397
|
+
upstream_tool_admission_timeout: (previous?.upstream_tool_admission_timeout ?? 0) + 1,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
const failureCategories = { upstream_list_failed: 0, upstream_tool_admission_timeout: 0 };
|
|
401
|
+
for (const fact of facts.values()) {
|
|
402
|
+
failureCategories.upstream_list_failed += fact.upstream_list_failed ?? 0;
|
|
403
|
+
failureCategories.upstream_tool_admission_timeout += fact.upstream_tool_admission_timeout ?? 0;
|
|
404
|
+
}
|
|
405
|
+
const previous = inherited?.[CAPABILITY_PAGINATION_META_KEY];
|
|
406
|
+
return setCapabilityFailureFacts({
|
|
407
|
+
...inherited,
|
|
408
|
+
[CAPABILITY_PAGINATION_META_KEY]: {
|
|
409
|
+
...previous,
|
|
410
|
+
partial: true,
|
|
411
|
+
complete: false,
|
|
412
|
+
generation,
|
|
413
|
+
failedSourceCount: facts.size,
|
|
414
|
+
failureCategories: {
|
|
415
|
+
...(failureCategories.upstream_list_failed
|
|
416
|
+
? { upstream_list_failed: failureCategories.upstream_list_failed }
|
|
417
|
+
: {}),
|
|
418
|
+
upstream_tool_admission_timeout: failureCategories.upstream_tool_admission_timeout,
|
|
419
|
+
},
|
|
420
|
+
retryable: true,
|
|
421
|
+
recovery: 'restart-walk',
|
|
422
|
+
},
|
|
423
|
+
}, facts);
|
|
424
|
+
}
|
|
131
425
|
async describeVisibleTool(args, visibility, queryOptions = {}) {
|
|
132
426
|
const refresh = await this.resolveRefreshFacts(queryOptions.refreshIntent ?? 'never', 'describe');
|
|
133
427
|
const access = await this.resolveVisibleToolAccess(args, visibility, queryOptions.toolRegistry);
|
|
@@ -208,9 +502,20 @@ export class CapabilityCatalog {
|
|
|
208
502
|
}
|
|
209
503
|
}
|
|
210
504
|
async invokeVisibleTool(args, visibility, queryOptions = {}) {
|
|
505
|
+
const startedAt = performance.now();
|
|
506
|
+
const requested = { callId: randomUUID(), requestedServer: args.server, requestedTool: args.toolName };
|
|
507
|
+
writeLocalDiagnostic('info', 'tool.requested', requested);
|
|
508
|
+
writeLocalDiagnostic('debug', 'tool.arguments', () => ({ ...requested, arguments: args.args }));
|
|
211
509
|
const refresh = await this.resolveRefreshFacts(queryOptions.refreshIntent ?? 'never', 'invoke');
|
|
212
510
|
const access = await this.resolveVisibleToolAccess(args, visibility, queryOptions.toolRegistry);
|
|
213
511
|
if (access.error) {
|
|
512
|
+
writeLocalDiagnostic('warn', 'tool.rejected', {
|
|
513
|
+
...requested,
|
|
514
|
+
phase: 'routing',
|
|
515
|
+
outcome: queryOptions.signal?.aborted ? 'cancelled' : access.error.type,
|
|
516
|
+
error: access.error,
|
|
517
|
+
durationMs: performance.now() - startedAt,
|
|
518
|
+
});
|
|
214
519
|
return {
|
|
215
520
|
result: {},
|
|
216
521
|
server: args.server ?? '',
|
|
@@ -221,9 +526,24 @@ export class CapabilityCatalog {
|
|
|
221
526
|
}
|
|
222
527
|
const { route } = access;
|
|
223
528
|
const connection = access.connection ?? this.deps.outboundConnections.get(route.connectionKey);
|
|
529
|
+
const diagnosticRoute = {
|
|
530
|
+
...requested,
|
|
531
|
+
server: route.server,
|
|
532
|
+
tool: route.toolName,
|
|
533
|
+
origin: route.origin,
|
|
534
|
+
routingScope: (visibility?.sessionId ?? this.deps.defaultVisibility?.sessionId) ? 'session' : 'default',
|
|
535
|
+
timeoutMs: connection?.requestTimeoutMs,
|
|
536
|
+
};
|
|
537
|
+
writeLocalDiagnostic('info', 'tool.routed', diagnosticRoute);
|
|
224
538
|
if (!connection ||
|
|
225
539
|
connection.status !== ClientStatus.Connected ||
|
|
226
540
|
this.deps.outboundConnections.get(route.connectionKey) !== connection) {
|
|
541
|
+
writeLocalDiagnostic('warn', 'tool.rejected', {
|
|
542
|
+
...diagnosticRoute,
|
|
543
|
+
phase: 'connection',
|
|
544
|
+
outcome: queryOptions.signal?.aborted ? 'cancelled' : 'unavailable',
|
|
545
|
+
durationMs: performance.now() - startedAt,
|
|
546
|
+
});
|
|
227
547
|
return {
|
|
228
548
|
result: {},
|
|
229
549
|
server: route.server,
|
|
@@ -236,6 +556,7 @@ export class CapabilityCatalog {
|
|
|
236
556
|
refresh,
|
|
237
557
|
};
|
|
238
558
|
}
|
|
559
|
+
let phase = 'schema_admission';
|
|
239
560
|
try {
|
|
240
561
|
const adapter = connection.adapter;
|
|
241
562
|
const definition = access.tool.definition ??
|
|
@@ -252,7 +573,9 @@ export class CapabilityCatalog {
|
|
|
252
573
|
signal: queryOptions.signal,
|
|
253
574
|
};
|
|
254
575
|
const contracts = await admitToolSchemas(definition, binding);
|
|
576
|
+
phase = 'input_validation';
|
|
255
577
|
const validateOutput = await prepareToolValidation(contracts, args.args, binding);
|
|
578
|
+
phase = 'routing_revalidation';
|
|
256
579
|
const current = await this.resolveVisibleToolAccess(args, visibility, queryOptions.toolRegistry);
|
|
257
580
|
if (queryOptions.signal?.aborted ||
|
|
258
581
|
current.error ||
|
|
@@ -261,14 +584,45 @@ export class CapabilityCatalog {
|
|
|
261
584
|
JSON.stringify(current.route) !== JSON.stringify(route) ||
|
|
262
585
|
(current.tool.definition && JSON.stringify(current.tool.definition) !== JSON.stringify(definition)))
|
|
263
586
|
throw new SchemaBoundaryError('schema_invalid');
|
|
587
|
+
phase = 'upstream';
|
|
588
|
+
writeLocalDiagnostic('debug', 'tool.dispatch', () => ({ ...diagnosticRoute, phase }));
|
|
264
589
|
const result = await requestLegacyAdapter(adapter, 'tools/call', {
|
|
265
590
|
name: route.toolName,
|
|
266
591
|
arguments: args.args,
|
|
267
592
|
}, { signal: queryOptions.signal, timeoutMs: connection.requestTimeoutMs });
|
|
593
|
+
phase = 'output_validation';
|
|
268
594
|
await validateOutput(result);
|
|
595
|
+
let outcome = 'success';
|
|
596
|
+
if (ownData(result, 'isError') === true)
|
|
597
|
+
outcome = 'upstream_error';
|
|
598
|
+
writeLocalDiagnostic('info', 'tool.completed', {
|
|
599
|
+
...diagnosticRoute,
|
|
600
|
+
outcome,
|
|
601
|
+
durationMs: performance.now() - startedAt,
|
|
602
|
+
});
|
|
603
|
+
writeLocalDiagnostic('debug', 'tool.result', () => ({ ...diagnosticRoute, result }));
|
|
269
604
|
return { result, server: route.server, tool: route.toolName, route, refresh };
|
|
270
605
|
}
|
|
271
606
|
catch (error) {
|
|
607
|
+
const errorCode = ownData(error, 'code');
|
|
608
|
+
const timedOut = errorCode === 'schema_evaluation_timeout' || errorCode === ErrorCode.RequestTimeout;
|
|
609
|
+
const failureKind = gatewayFailureFromUnknown(error, 'transport').kind;
|
|
610
|
+
let outcome = 'failed';
|
|
611
|
+
if (queryOptions.signal?.aborted || failureKind === 'cancelled')
|
|
612
|
+
outcome = 'cancelled';
|
|
613
|
+
else if (timedOut || failureKind === 'deadline-exceeded')
|
|
614
|
+
outcome = 'timeout';
|
|
615
|
+
else if (error instanceof SchemaBoundaryError)
|
|
616
|
+
outcome = 'validation_failed';
|
|
617
|
+
const failureFields = {
|
|
618
|
+
...diagnosticRoute,
|
|
619
|
+
phase,
|
|
620
|
+
outcome,
|
|
621
|
+
error,
|
|
622
|
+
durationMs: performance.now() - startedAt,
|
|
623
|
+
};
|
|
624
|
+
writeLocalDiagnostic('warn', 'tool.failed', failureFields);
|
|
625
|
+
writeLocalDiagnostic('debug', 'tool.failure-details', () => failureFields);
|
|
272
626
|
if (error instanceof SchemaBoundaryError && error.code === 'schema_input_invalid')
|
|
273
627
|
return { result: schemaInputErrorResult(), server: route.server, tool: route.toolName, route, refresh };
|
|
274
628
|
if (error instanceof SchemaBoundaryError)
|
|
@@ -343,7 +697,7 @@ export class CapabilityCatalog {
|
|
|
343
697
|
server: tool.server,
|
|
344
698
|
connectionKey: tool.connectionKey,
|
|
345
699
|
tags: tool.tags,
|
|
346
|
-
}))).withConnections(registry.getConnections(), () => registry.isCurrent());
|
|
700
|
+
})), registry.getListingMeta()).withConnections(registry.getConnections(), () => registry.isCurrent());
|
|
347
701
|
}
|
|
348
702
|
async resolveVisibleToolAccess(args, visibility, requestRegistry) {
|
|
349
703
|
if (!args.server || !args.toolName) {
|
|
@@ -354,7 +708,9 @@ export class CapabilityCatalog {
|
|
|
354
708
|
},
|
|
355
709
|
};
|
|
356
710
|
}
|
|
357
|
-
const
|
|
711
|
+
const sourceRegistry = requestRegistry ?? (await this.deps.getToolRegistry());
|
|
712
|
+
await this.pruneToolAdmissionOutcomes(sourceRegistry);
|
|
713
|
+
const visibleRegistry = await this.visibleToolRegistry(visibility, sourceRegistry);
|
|
358
714
|
if (typeof visibleRegistry.getTool !== 'function') {
|
|
359
715
|
return {
|
|
360
716
|
error: {
|
|
@@ -364,7 +720,8 @@ export class CapabilityCatalog {
|
|
|
364
720
|
};
|
|
365
721
|
}
|
|
366
722
|
const tool = visibleRegistry.getTool(args.server, args.toolName);
|
|
367
|
-
|
|
723
|
+
const withheld = tool && this.isToolWithheld(tool, sourceRegistry);
|
|
724
|
+
if (!tool || withheld) {
|
|
368
725
|
const disabledError = this.isServerVisible(args.server, visibility)
|
|
369
726
|
? getDisabledSourceToolError(this.deps.getServerConfigs(), args.server, args.toolName)
|
|
370
727
|
: undefined;
|
|
@@ -386,6 +743,20 @@ export class CapabilityCatalog {
|
|
|
386
743
|
}
|
|
387
744
|
return { route, tool, connection: visibleRegistry.getConnections()?.get(route.connectionKey) };
|
|
388
745
|
}
|
|
746
|
+
isToolWithheld(tool, registry) {
|
|
747
|
+
const key = tool.connectionKey ?? tool.server;
|
|
748
|
+
const outcome = this.withheldTools.get(JSON.stringify([key, tool.name]));
|
|
749
|
+
if (!outcome?.withheld)
|
|
750
|
+
return false;
|
|
751
|
+
if (outcome.registry !== registry)
|
|
752
|
+
return false;
|
|
753
|
+
const connection = this.deps.outboundConnections.get(key);
|
|
754
|
+
if (outcome.connection !== connection)
|
|
755
|
+
return false;
|
|
756
|
+
if (outcome.adapter !== connection?.adapter)
|
|
757
|
+
return false;
|
|
758
|
+
return true;
|
|
759
|
+
}
|
|
389
760
|
isServerVisible(server, visibility) {
|
|
390
761
|
const effectiveVisibility = visibility ?? this.deps.defaultVisibility;
|
|
391
762
|
return effectiveVisibility === undefined || getCapabilityVisibleServerNames(effectiveVisibility).has(server);
|
|
@@ -403,7 +774,7 @@ export class CapabilityCatalog {
|
|
|
403
774
|
kind: 'tools',
|
|
404
775
|
origin: 'external',
|
|
405
776
|
upstreamIdentity: tool.name,
|
|
406
|
-
publicIdentity: tool.route?.publicIdentity ??
|
|
777
|
+
publicIdentity: tool.route?.publicIdentity ?? buildPublicToolName(tool.server, tool.name),
|
|
407
778
|
server: tool.server,
|
|
408
779
|
toolName: tool.name,
|
|
409
780
|
connectionKey: registryConnectionKey,
|
|
@@ -419,7 +790,7 @@ export class CapabilityCatalog {
|
|
|
419
790
|
kind: 'tools',
|
|
420
791
|
origin: 'external',
|
|
421
792
|
upstreamIdentity: tool.name,
|
|
422
|
-
publicIdentity: tool.route?.publicIdentity ??
|
|
793
|
+
publicIdentity: tool.route?.publicIdentity ?? buildPublicToolName(tool.server, tool.name),
|
|
423
794
|
server: tool.server,
|
|
424
795
|
toolName: tool.name,
|
|
425
796
|
connectionKey: result.key,
|