import { CancellationToken } from "../../../../base/common/cancellation.js"; import { Disposable, IDisposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { URI } from "../../../../base/common/uri.js"; import { ICommandService } from "../../../../platform/commands/common/commands.service.js"; import { IDialogService } from "../../../../platform/dialogs/common/dialogs.service.js"; import { IInstantiationService } from "../../../../platform/instantiation/common/instantiation.js"; import { ILogger } from "../../../../platform/log/common/log.js"; import { ILoggerService } from "../../../../platform/log/common/log.service.js"; import { INotificationService } from "../../../../platform/notification/common/notification.service.js"; import { IOpenerService } from "../../../../platform/opener/common/opener.service.js"; import { StorageScope } from "../../../../platform/storage/common/storage.js"; import { IStorageService } from "../../../../platform/storage/common/storage.service.js"; import { ITelemetryService } from "../../../../platform/telemetry/common/telemetry.service.js"; import { IWorkspaceContextService } from "../../../../platform/workspace/common/workspace.service.js"; import { IWorkbenchEnvironmentService } from "../../../services/environment/common/environmentService.service.js"; import { IExtensionService } from "../../../services/extensions/common/extensions.service.js"; import { IOutputService } from "../../../services/output/common/output.service.js"; import { ToolProgress } from "../../chat/common/tools/languageModelToolsService.js"; import { StoredMcpIcons } from "./mcpIcons.js"; import { IMcpRegistry } from "./mcpRegistryTypes.service.js"; import { IMcpSandboxService } from "./mcpSandboxService.service.js"; import { McpServerRequestHandler } from "@codingame/monaco-vscode-mcp-service-override/vscode/vs/workbench/contrib/mcp/common/mcpServerRequestHandler"; import { IMcpIcons, IMcpPotentialSandboxBlock, IMcpPrompt, IMcpResource, IMcpResourceTemplate, IMcpServer, IMcpServerConnection, IMcpServerStartOpts, IMcpTool, IMcpToolCallContext, McpCapability, McpCollectionDefinition, McpCollectionReference, McpConnectionState, McpDefinitionReference, McpServerCacheState, McpServerDefinition, McpToolVisibility } from "./mcpTypes.js"; import { IMcpElicitationService } from "./mcpTypes.service.js"; import { IMcpSamplingService } from "./mcpTypes.service.js"; import { MCP } from "./modelContextProtocol.js"; export type McpServerInstallData = { serverName: string; source: "gallery" | "local"; scope: string; success: boolean; error?: string; hasInputs: boolean; }; export type McpServerInstallClassification = { owner: "connor4312"; comment: "MCP server installation event tracking"; serverName: { classification: "SystemMetaData"; purpose: "FeatureInsight"; comment: "The name of the MCP server being installed"; }; source: { classification: "SystemMetaData"; purpose: "FeatureInsight"; comment: "Installation source (gallery or local)"; }; scope: { classification: "SystemMetaData"; purpose: "FeatureInsight"; comment: "Installation scope (user, workspace, etc.)"; }; success: { classification: "SystemMetaData"; purpose: "FeatureInsight"; isMeasurement: true; comment: "Whether installation succeeded"; }; error?: { classification: "CallstackOrException"; purpose: "FeatureInsight"; comment: "Error message if installation failed"; }; hasInputs: { classification: "SystemMetaData"; purpose: "FeatureInsight"; isMeasurement: true; comment: "Whether the server requires input configuration"; }; }; type StoredMcpPrompt = MCP.Prompt & { _icons: StoredMcpIcons; }; interface IToolCacheEntry { readonly serverName: string | undefined; readonly serverInstructions: string | undefined; readonly serverIcons: StoredMcpIcons; readonly trustedAtNonce: string | undefined; readonly nonce: string | undefined; /** Cached tools so we can show what's available before it's started */ readonly tools: readonly ValidatedMcpTool[]; /** Cached prompts */ readonly prompts: readonly StoredMcpPrompt[] | undefined; /** Cached capabilities */ readonly capabilities: McpCapability | undefined; } interface IServerCacheEntry { readonly servers: readonly McpServerDefinition.Serialized[]; } export declare class McpServerMetadataCache extends Disposable { private didChange; private readonly cache; private readonly extensionServers; constructor(scope: StorageScope, storageService: IStorageService); /** Resets the cache for primitives and extension servers */ reset(): void; /** Gets cached primitives for a server (used before a server is running) */ get(definitionId: string): IToolCacheEntry | undefined; /** Sets cached primitives for a server */ store(definitionId: string, entry: Partial): void; /** Gets cached servers for a collection (used for extensions, before the extension activates) */ getServers(collectionId: string): IServerCacheEntry | undefined; /** Sets cached servers for a collection */ storeServers(collectionId: string, entry: IServerCacheEntry | undefined): void; } type ValidatedMcpTool = MCP.Tool & { _icons: StoredMcpIcons; /** * Tool name as published by the MCP server. This may * be different than the one in {@link definition} due to name normalization * in {@link McpServer._getValidatedTools}. */ serverToolName: string; /** * Visibility of the tool, parsed from `_meta.ui.visibility`. * Defaults to Model | App if not specified. */ visibility: McpToolVisibility; /** * UI resource URI if this tool has an associated MCP App UI. * Parsed from `_meta.ui.resourceUri`. */ uiResourceUri?: string; }; interface ServerMetadata { readonly serverName: string | undefined; readonly serverInstructions: string | undefined; readonly icons: IMcpIcons; } export declare class McpServer extends Disposable implements IMcpServer { readonly definition: McpDefinitionReference; private readonly _requiresExtensionActivation; private readonly _primitiveCache; private readonly _mcpRegistry; private readonly _extensionService; private readonly _loggerService; private readonly _outputService; private readonly _telemetryService; private readonly _commandService; private readonly _instantiationService; private readonly _dialogService; private readonly _notificationService; private readonly _openerService; private readonly _samplingService; private readonly _elicitationService; private readonly _mcpSandboxService; /** Shared task manager that survives reconnections */ private readonly _taskManager; /** * Helper function to call the function on the handler once it's online. The * connection started if it is not already. */ static callOn(server: IMcpServer, fn: (handler: McpServerRequestHandler, connection: IMcpServerConnection) => Promise, token?: CancellationToken): Promise; readonly collection: McpCollectionReference; private readonly _connectionSequencer; private readonly _connection; readonly connection: import("../../../../base/common/observable.js").ISettableObservable & IDisposable; readonly connectionState: IObservable; private readonly _capabilities; get capabilities(): IObservable; private readonly _tools; get tools(): IObservable; private readonly _prompts; get prompts(): IObservable; private readonly _serverMetadata; get serverMetadata(): IObservable; get trustedAtNonce(): string | undefined; set trustedAtNonce(nonce: string | undefined); private readonly _fullDefinitions; readonly cacheState: import("../../../../base/common/observable.js").IObservableWithChange; get logger(): ILogger; private readonly _loggerId; private readonly _logger; private _lastModeDebugged; private _isQuietStart; private _isSandboxSuggestionDialogVisible; private _potentialSandboxBlocks; private _potentialSandboxBlockListener; /** Count of running tool calls, used to detect if sampling is during an LM call */ runningToolCalls: Set; constructor(initialCollection: McpCollectionDefinition, definition: McpDefinitionReference, explicitRoots: URI[] | undefined, _requiresExtensionActivation: boolean | undefined, _primitiveCache: McpServerMetadataCache, toolPrefix: string, _mcpRegistry: IMcpRegistry, workspacesService: IWorkspaceContextService, _extensionService: IExtensionService, _loggerService: ILoggerService, _outputService: IOutputService, _telemetryService: ITelemetryService, _commandService: ICommandService, _instantiationService: IInstantiationService, _dialogService: IDialogService, _notificationService: INotificationService, _openerService: IOpenerService, _samplingService: IMcpSamplingService, _elicitationService: IMcpElicitationService, _mcpSandboxService: IMcpSandboxService, environmentService: IWorkbenchEnvironmentService); readDefinitions(): IObservable<{ server: McpServerDefinition | undefined; collection: McpCollectionDefinition | undefined; }>; showOutput(preserveFocus?: boolean): Promise; resources(token?: CancellationToken): AsyncIterable; resourceTemplates(token?: CancellationToken): Promise; start({ interaction, autoTrustChanges, promptType, debug, errorOnUserInteraction }?: IMcpServerStartOpts): Promise; private showInteractiveError; showSandboxConfigSuggestionFromPotentialBlocks(cnx: IMcpServerConnection, potentialBlocks: readonly IMcpPotentialSandboxBlock[]): boolean; private _confirmAndApplySandboxConfigSuggestion; recordPotentialSandboxBlock(block: IMcpPotentialSandboxBlock): void; private _removePotentialSandboxBlocks; stop(): Promise; /** Waits for any ongoing tools to be refreshed before resolving. */ awaitToolRefresh(): Promise; private resetLiveData; private _normalizeTool; private _getValidatedTools; /** * Parses incoming MCP icons and returns the resulting 'stored' record. Note * that this requires an active MCP server connection since we validate * against some of that connection's data. The icons may however be stored * and rehydrated later. */ private _parseIcons; private _setServerTools; private _setServerPrompts; private _toStoredMetadata; private _setServerMetadata; private _populateLiveData; } export declare class McpTool implements IMcpTool { private readonly _server; private readonly _definition; private readonly _elicitationService; readonly id: string; readonly referenceName: string; readonly icons: IMcpIcons; readonly visibility: McpToolVisibility; get definition(): MCP.Tool; get uiResourceUri(): string | undefined; constructor(_server: McpServer, idPrefix: string, _definition: ValidatedMcpTool, _elicitationService: IMcpElicitationService); call(params: Record, context?: IMcpToolCallContext, token?: CancellationToken): Promise; callWithProgress(params: Record, progress: ToolProgress, context?: IMcpToolCallContext, token?: CancellationToken): Promise; _callWithProgress(params: Record, progress: ToolProgress | undefined, context?: IMcpToolCallContext, token?: Readonly, allowRetry?: boolean): Promise; private _handleElicitationErr; compare(other: IMcpTool): number; } export {};