import type { CallToolResult, GetPromptResult, InputRequiredResult, PromptArgument, ReadResourceResult, ToolAnnotations } from "@modelcontextprotocol/server"; import type { PromptCallback, PromptDefinition } from "./prompts.js"; import type { ResourceCallback, ResourceDefinition } from "./resources.js"; import type { ToolCallback, ToolDefinition } from "./tools.js"; /** HTTP connection settings accepted by {@link MCPServer.proxy}. */ export interface ProxyHttpConfig { /** Upstream MCP endpoint URL. */ url: string; /** Extra headers sent on every upstream request. */ headers?: Record; /** Bearer token sent to the upstream server. */ authToken?: string; /** Connection timeout in milliseconds. */ timeout?: number; /** Fetch implementation used for upstream HTTP requests. */ fetch?: typeof fetch; /** Protocol negotiation mode forwarded to `@mcp-use/client`. */ protocolNegotiation?: "auto" | "legacy" | { pin: string; }; } /** Connection settings for one upstream server. */ export type ProxyServerConfig = ProxyHttpConfig; /** Progress payload received while a proxied tool is running. */ export interface ProxyProgress { /** Completed work units. */ progress: number; /** Total work units, when known. */ total?: number | undefined; /** Human-readable progress detail. */ message?: string | undefined; } /** Request controls used when forwarding calls to an upstream connection. */ export interface ProxyRequestOptions { /** Aborts the upstream request when the downstream request is cancelled. */ signal?: AbortSignal; /** Receives upstream progress notifications. */ onprogress?: (progress: ProxyProgress) => void; } /** Structural connection contract accepted by the low-level proxy overload. */ export interface ProxyConnection { /** Negotiated metadata used to derive the automatic capability namespace. */ readonly info: { server?: { name: string; }; }; /** Whether the upstream advertised a named MCP capability. */ supports?(capability: string): boolean; /** List upstream tools. */ listTools(): Promise; /** Forward a tool call. */ callTool(name: string, args?: Record, options?: ProxyRequestOptions): Promise; /** List upstream resources, including pagination when supported. */ listAllResources?(): Promise<{ resources: ProxyResource[]; }>; /** List one page of upstream resources. */ listResources?(): Promise<{ resources: ProxyResource[]; }>; /** Read an upstream resource. */ readResource(uri: string, options?: ProxyRequestOptions): Promise; /** List upstream prompts. */ listPrompts(): Promise<{ prompts: ProxyPrompt[]; }>; /** Render an upstream prompt. */ getPrompt(name: string, args: Record, options?: ProxyRequestOptions): Promise; } /** Tool metadata consumed while introspecting an upstream connection. */ export interface ProxyTool { /** Upstream tool name. */ name: string; /** Upstream tool icons advertised on `tools/list`. */ icons?: ToolDefinition["icons"]; /** Human-readable tool title. */ title?: string | undefined; /** LLM-facing tool description. */ description?: string | undefined; /** Upstream input JSON Schema. */ inputSchema?: Record | undefined; /** Upstream output JSON Schema. */ outputSchema?: Record | undefined; /** Upstream behavioral hints. */ annotations?: ToolAnnotations | undefined; } /** Resource metadata consumed while introspecting an upstream connection. */ export interface ProxyResource { /** Upstream resource name. */ name: string; /** Original upstream resource URI. */ uri: string; /** Human-readable resource title. */ title?: string | undefined; /** Human-readable resource description. */ description?: string | undefined; /** Resource media type. */ mimeType?: string | undefined; /** Upstream client hints, e.g. audience and priority. */ annotations?: ResourceDefinition["annotations"] | undefined; /** Upstream extension metadata advertised on `resources/list`. */ _meta?: ResourceDefinition["_meta"] | undefined; } /** Prompt metadata consumed while introspecting an upstream connection. */ export interface ProxyPrompt { /** Upstream prompt name. */ name: string; /** Human-readable prompt title. */ title?: string | undefined; /** Human-readable prompt description. */ description?: string | undefined; /** String arguments accepted by the prompt. */ arguments?: PromptArgument[] | undefined; } /** Registration surface used while mounting proxied capabilities. @internal */ export interface ProxyMountHost { /** Whether the parent server has mounted its handler. */ isStarted(): boolean; /** Whether a tool name is already registered. */ hasTool(name: string): boolean; /** Whether a resource name is already registered. */ hasResource(name: string): boolean; /** Whether a prompt name is already registered. */ hasPrompt(name: string): boolean; /** Register a proxied tool. */ registerTool(definition: ToolDefinition, callback: ToolCallback): void; /** Register a proxied resource. */ registerResource(definition: ResourceDefinition, callback: ResourceCallback): void; /** Register a proxied prompt. */ registerPrompt(definition: PromptDefinition, callback: PromptCallback): void; /** Track a proxy client owned by the parent server. */ trackOwner(owner: { close(): Promise; }): void; /** Record one successfully introspected upstream namespace. */ trackNamespace?(counts: { tools: number; resources: number; prompts: number; }): void; } /** Convert a missing optional-client import into the proxy install error. @internal */ export declare function proxyClientInstallError(error: unknown): Error | undefined; /** * Mount one existing upstream connection on a parent server. * * @param host - Parent server registration surface. * @param connection - Ready `@mcp-use/client` v2 connection. * @internal */ export declare function mountProxyConnection(host: ProxyMountHost, connection: ProxyConnection): Promise; /** * Connect and mount namespace-keyed upstream servers through * `@mcp-use/client` v2. * * @param host - Parent server registration surface. * @param servers - Namespace-keyed upstream client configuration. * * @internal */ export declare function mountProxyServers(host: ProxyMountHost, servers: Record): Promise; /** Determine whether a proxy argument is an existing connection. @internal */ export declare function isProxyConnection(value: unknown): value is ProxyConnection;