Path: blob/main/src/vs/platform/mcp/common/mcpGateway.ts
5243 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { URI } from '../../../base/common/uri.js';6import { createDecorator } from '../../instantiation/common/instantiation.js';78export const IMcpGatewayService = createDecorator<IMcpGatewayService>('IMcpGatewayService');910export const McpGatewayChannelName = 'mcpGateway';1112/**13* Result of creating an MCP gateway.14*/15export interface IMcpGatewayInfo {16/**17* The address of the HTTP endpoint for this gateway.18*/19readonly address: URI;2021/**22* The unique identifier for this gateway, used for disposal.23*/24readonly gatewayId: string;25}2627/**28* Service that manages MCP gateway HTTP endpoints in the main process (or remote server).29*30* The gateway provides an HTTP server that external processes can connect31* to in order to interact with MCP servers known to the editor. The server32* is shared among all gateways and is automatically torn down when the33* last gateway is disposed.34*/35export interface IMcpGatewayService {36readonly _serviceBrand: undefined;3738/**39* Disposes all gateways associated with a given client context (e.g., client ID or connection).40* @param context The client context whose gateways should be disposed.41* @return A disposable that can be used to unregister the client context from future cleanup (e.g., if the context is reused).42*/43disposeGatewaysForClient<TContext>(context: TContext): void;4445/**46* Creates a new MCP gateway endpoint.47*48* The gateway is assigned a secure random route ID to make the endpoint49* URL unguessable without authentication.50*51* @param context Optional context (e.g., client ID) to associate with the gateway for cleanup purposes.52* @returns A promise that resolves to the gateway info if successful.53*/54createGateway<TContext>(context: TContext): Promise<IMcpGatewayInfo>;5556/**57* Disposes a previously created gateway.58*59* When the last gateway is disposed, the underlying HTTP server is shut down.60*61* @param gatewayId The unique identifier of the gateway to dispose.62*/63disposeGateway(gatewayId: string): Promise<void>;64}656667