import type { MCPServerConfig, MCPTool, MCPToolResult } from "./mcp-types.js"; /** * MCP Client class * Manages connections to MCP servers and tool calls */ export declare class MCPClient { private servers; private serverRuntimes; private serverTools; private httpSessions; private sseSessions; private authStorage; private agentDir?; private mcpConfigPath?; /** * @param authStoragePath Optional path to auth.json. If omitted, uses getAgentDir()/auth.json. * @param agentDir Optional agent directory for config path resolution. If omitted, uses getAgentDir(). * @param mcpConfigPath Optional explicit MCP config file path. Overrides default resolution. */ constructor(authStoragePath?: string, agentDir?: string, mcpConfigPath?: string); /** * Load MCP server configurations from config file */ private loadServersFromConfig; /** * Get all configured servers */ getServers(): MCPServerConfig[]; /** * Get a specific server by ID */ getServer(id: string): MCPServerConfig | undefined; /** * Add or update a server configuration */ addServer(server: MCPServerConfig): void; /** * Remove a server */ removeServer(id: string): void; private getRuntime; private convertNpxArgsToNpmExecArgs; private getSpawnAttempts; private spawnProcess; private attachStdoutParser; private processStdoutBuffer; private handleJsonRpcMessage; private writeFramedMessage; private sendNotification; private sendRequest; private getHttpSession; private buildHttpHeaders; private ensureHttpInitialized; private sendHttpRequest; private parseEventStreamResponse; private initSSEConnection; private buildSSEHeaders; private runSSEStream; private processSSELine; private handleSSEMessage; private sendSSERequest; private initializeServer; private normalizeToolRecord; private loadToolsForServer; /** * Start an MCP server (for stdio transport) */ startServer(serverId: string): Promise; /** * Stop an MCP server */ stopServer(serverId: string): void; /** * Stop all running servers */ stopAllServers(): void; /** * List available tools from all servers */ listTools(serverId?: string): Promise; /** * Call an MCP tool */ callTool(toolName: string, args: Record, timeoutMs?: number): Promise; private callHttpTool; /** * Call tool via stdio (JSON-RPC) */ private callStdioTool; /** * Call tool via SSE (HTTP) */ private callSSETool; /** * Check if a tool exists */ hasTool(toolName: string): boolean; }