import { Client, type ClientOptions } from '@modelcontextprotocol/sdk/client/index.js'; import { SSEClientTransport, type SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js'; import { StreamableHTTPClientTransport, type StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; import type { CallToolRequest, GetPromptRequest, Implementation, ListPromptsRequest, ListResourceTemplatesRequest, ListResourcesRequest, ListToolsRequest, ReadResourceRequest } from '@modelcontextprotocol/sdk/types.js'; import type { Application } from 'egg'; export type MCPTransportProtocol = 'streamable' | 'stateless' | 'sse'; export type MCPRequestMockApplication = Application; export interface MCPRequestUnitTestOptions { app: MCPRequestMockApplication; serverName?: string; } export interface MCPConnectOptions { clientInfo?: Implementation; clientOptions?: ClientOptions; streamableTransportOptions?: StreamableHTTPClientTransportOptions; sseTransportOptions?: SSEClientTransportOptions; } type RequestOptions = Parameters[2]; export declare class MCPTestClient { readonly client: Client; readonly transport: StreamableHTTPClientTransport | SSEClientTransport; readonly protocol: MCPTransportProtocol; constructor(client: Client, transport: StreamableHTTPClientTransport | SSEClientTransport, protocol: MCPTransportProtocol); listTools(params?: ListToolsRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; tools: { inputSchema: { [x: string]: unknown; type: "object"; properties?: Record | undefined; required?: string[] | undefined; }; name: string; description?: string | undefined; outputSchema?: { [x: string]: unknown; type: "object"; properties?: Record | undefined; required?: string[] | undefined; } | undefined; annotations?: { title?: string | undefined; readOnlyHint?: boolean | undefined; destructiveHint?: boolean | undefined; idempotentHint?: boolean | undefined; openWorldHint?: boolean | undefined; } | undefined; execution?: { taskSupport?: "optional" | "required" | "forbidden" | undefined; } | undefined; _meta?: Record | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; listResources(params?: ListResourcesRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; resources: { uri: string; name: string; description?: string | undefined; mimeType?: string | undefined; annotations?: { audience?: ("user" | "assistant")[] | undefined; priority?: number | undefined; lastModified?: string | undefined; } | undefined; _meta?: { [x: string]: unknown; } | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; listResourceTemplates(params?: ListResourceTemplatesRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; resourceTemplates: { uriTemplate: string; name: string; description?: string | undefined; mimeType?: string | undefined; annotations?: { audience?: ("user" | "assistant")[] | undefined; priority?: number | undefined; lastModified?: string | undefined; } | undefined; _meta?: { [x: string]: unknown; } | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; listPrompts(params?: ListPromptsRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; prompts: { name: string; description?: string | undefined; arguments?: { name: string; description?: string | undefined; required?: boolean | undefined; }[] | undefined; _meta?: { [x: string]: unknown; } | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; callTool(name: string, args?: Record, options?: RequestOptions): ReturnType; callTool(params: CallToolRequest['params'], options?: RequestOptions): ReturnType; readResource(uri: string, options?: RequestOptions): ReturnType; readResource(params: ReadResourceRequest['params'], options?: RequestOptions): ReturnType; getPrompt(name: string, args?: Record, options?: RequestOptions): ReturnType; getPrompt(params: GetPromptRequest['params'], options?: RequestOptions): ReturnType; request(...args: Parameters): Promise; setNotificationHandler(...args: Parameters): this; close(): Promise; } export default class MCPRequestUnitTest { #private; constructor(options: MCPRequestUnitTestOptions); streamable(options?: StreamableHTTPClientTransportOptions): this; stateless(options?: StreamableHTTPClientTransportOptions): this; sse(options?: SSEClientTransportOptions): this; authToken(token: string): this; clientInfo(info: Partial): this; clientOptions(options: ClientOptions): this; set(name: string, value: string | number | boolean): this; headers(headers?: Record | null): this; connect(options?: MCPConnectOptions): Promise; listTools(params?: ListToolsRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; tools: { inputSchema: { [x: string]: unknown; type: "object"; properties?: Record | undefined; required?: string[] | undefined; }; name: string; description?: string | undefined; outputSchema?: { [x: string]: unknown; type: "object"; properties?: Record | undefined; required?: string[] | undefined; } | undefined; annotations?: { title?: string | undefined; readOnlyHint?: boolean | undefined; destructiveHint?: boolean | undefined; idempotentHint?: boolean | undefined; openWorldHint?: boolean | undefined; } | undefined; execution?: { taskSupport?: "optional" | "required" | "forbidden" | undefined; } | undefined; _meta?: Record | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; listResources(params?: ListResourcesRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; resources: { uri: string; name: string; description?: string | undefined; mimeType?: string | undefined; annotations?: { audience?: ("user" | "assistant")[] | undefined; priority?: number | undefined; lastModified?: string | undefined; } | undefined; _meta?: { [x: string]: unknown; } | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; listResourceTemplates(params?: ListResourceTemplatesRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; resourceTemplates: { uriTemplate: string; name: string; description?: string | undefined; mimeType?: string | undefined; annotations?: { audience?: ("user" | "assistant")[] | undefined; priority?: number | undefined; lastModified?: string | undefined; } | undefined; _meta?: { [x: string]: unknown; } | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; listPrompts(params?: ListPromptsRequest['params'], options?: RequestOptions): Promise<{ [x: string]: unknown; prompts: { name: string; description?: string | undefined; arguments?: { name: string; description?: string | undefined; required?: boolean | undefined; }[] | undefined; _meta?: { [x: string]: unknown; } | undefined; icons?: { src: string; mimeType?: string | undefined; sizes?: string[] | undefined; }[] | undefined; title?: string | undefined; }[]; _meta?: { [x: string]: unknown; "io.modelcontextprotocol/related-task"?: { [x: string]: unknown; taskId: string; } | undefined; } | undefined; nextCursor?: string | undefined; }>; callTool(name: string, args?: Record, options?: RequestOptions): ReturnType; callTool(params: CallToolRequest['params'], options?: RequestOptions): ReturnType; readResource(uri: string, options?: RequestOptions): ReturnType; readResource(params: ReadResourceRequest['params'], options?: RequestOptions): ReturnType; getPrompt(name: string, args?: Record, options?: RequestOptions): ReturnType; getPrompt(params: GetPromptRequest['params'], options?: RequestOptions): ReturnType; } export {};