import { CancellationToken } from "../../../../base/common/cancellation.js"; import { Event } from "../../../../base/common/event.js"; import { Disposable, IDisposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import { IInstantiationService } from "../../../../platform/instantiation/common/instantiation.js"; import { IThemeService } from "../../../../platform/theme/common/themeService.service.js"; import { IMcpToolCallUIData } from "../common/mcpTypes.js"; import { MCP } from "../common/modelContextProtocol.js"; import { McpApps } from "../common/modelContextProtocolApps.js"; /** * Result from loading an MCP App UI resource. */ export interface IMcpAppResourceContent extends McpApps.McpUiResourceMeta { /** The HTML content of the UI resource */ readonly html: string; /** MIME type of the content */ readonly mimeType: string; } /** * Transport abstraction for the constrained subset of MCP requests an MCP * App's webview makes back to the host. Two implementations exist: one * routes through {@link IMcpService} (local servers), the other through * the owning {@link IAgentConnection.handleMcpRequest} on an `mcp://` AHP * side channel (agent-host-resident servers). */ export interface IMcpAppCallTransport extends IDisposable { /** Forwarded MCP server notifications (`notifications/*`) for this server. */ readonly onNotification: Event<{ readonly method: string; readonly params?: unknown; }>; loadResource(token: CancellationToken): Promise; callTool(name: string, params: Record, token: CancellationToken): Promise; readResource(uri: string, token: CancellationToken): Promise; sampling(params: MCP.CreateMessageRequest["params"], token: CancellationToken): Promise; log(params: MCP.LoggingMessageNotificationParams): Promise; } /** * Wrapper class that "upgrades" serializable IMcpToolCallUIData into a functional * object that can load UI resources and proxy tool/resource calls back to the MCP server. * * Selects the underlying transport based on whether the renderer was given * an AHP `mcp://` channel — agent-host-resident servers route through the * owning Agent Host connection, everything else uses the local * {@link IMcpService}. */ export declare class McpToolCallUI extends Disposable { private readonly _uiData; /** * Basic host context reflecting the current UI and theme. Notably lacks * the `toolInfo` or `viewport` sizes. */ readonly hostContext: IObservable; private readonly _transport; /** Forwarded MCP server notifications scoped to this App's server. */ readonly onNotification: Event<{ readonly method: string; readonly params?: unknown; }>; constructor(_uiData: IMcpToolCallUIData, instantiationService: IInstantiationService, themeService: IThemeService); /** * Gets the underlying UI data. */ get uiData(): IMcpToolCallUIData; /** * Logs a message to the MCP server's logger. */ log(log: MCP.LoggingMessageNotificationParams): Promise; /** * Loads the UI resource from the MCP server. * @param token Cancellation token * @returns The HTML content and CSP configuration */ loadResource(token: CancellationToken): Promise; /** * Calls a tool on the MCP server. * @param name Tool name * @param params Tool parameters * @param token Cancellation token * @returns The tool call result */ callTool(name: string, params: Record, token: CancellationToken): Promise; /** * Reads a resource from the MCP server. * @param uri Resource URI * @param token Cancellation token * @returns The resource content */ readResource(uri: string, token: CancellationToken): Promise; /** * Issues a `sampling/createMessage` request against the MCP server's * host-side sampling implementation. Only supported when the App * server runs inside an agent host that has opted into sampling. */ sampling(params: MCP.CreateMessageRequest["params"], token: CancellationToken): Promise; }