/** * MCP Client — 消费外部 MCP Server * * 通过 stdio 连接外部 MCP Server,动态发现并注册其工具。 * * 用法: * const client = new McpClient({ command: "npx", args: ["-y", "xiaohongshu-mcp"] }); * await client.connect(); * const tools = client.getTools(); // 自动转为内部 Tool 格式 */ import type { Tool, ToolResult } from "../types.js"; export interface McpClientConfig { /** MCP Server 启动命令 */ command: string; /** 命令参数 */ args?: string[]; /** 环境变量 */ env?: Record; /** 工具名前缀(避免冲突) */ toolPrefix?: string; /** 连接超时(毫秒) */ timeout?: number; } export declare class McpClient { private config; private process; private requestId; private pendingRequests; private buffer; private tools; private connected; constructor(config: McpClientConfig); /** 连接到 MCP Server */ connect(): Promise; /** 断开连接 */ disconnect(): Promise; /** 是否已连接 */ isConnected(): boolean; /** 获取远程工具列表(转换为内部 Tool 格式) */ getTools(): Tool[]; /** 调用远程工具 */ callTool(name: string, args: Record): Promise; private processBuffer; private handleMessage; private sendRequest; private sendNotification; /** 将 MCP Tool 转换为内部 Tool 格式 */ private mcpToolToInternal; } //# sourceMappingURL=client.d.ts.map