/** * MCP Client * Local MCP server management for CLI * Spawns and manages MCP servers using stdio transport */ import type { McpToolInfo, McpToolResult } from '../agent/types.js'; /** * MCP server configuration */ export interface McpServerConfig { command: string; args: string[]; env?: Record; cwd?: string; } /** * MCP configuration file format */ export interface McpConfig { mcpServers: Record; } /** * MCP Client class */ export declare class McpClient { private servers; private configPath; private debug; constructor(options?: { debug?: boolean; }); /** * Log debug message */ private log; /** * Format MCP error with user-friendly messages * Detects "occupied" errors and provides clear guidance */ static formatError(error: string | Error, serverName?: string): string; /** * Check if error indicates server is occupied */ static isOccupiedError(error: string | Error): boolean; /** * Get config path */ getConfigPath(): string; /** * Load MCP configuration */ loadConfig(): McpConfig | null; /** * List configured server names */ listServers(): string[]; /** * Connect to an MCP server with improved error handling */ connect(serverName: string): Promise; /** * Resolve command to full path, preferring bunx over npx */ private resolveCommand; /** * Handle a line from stdout */ private handleLine; /** * Send a JSON-RPC request with timeout */ private sendRequest; /** * Initialize the MCP server with timeout */ private initializeWithTimeout; /** * List tools with timeout */ private listToolsWithTimeout; /** * Call a tool on a connected server (with auto-reconnect) */ callTool(serverName: string, toolName: string, args?: Record): Promise; /** * Check if a server is actually connected and responsive */ isServerConnected(serverName: string): boolean; /** * Get last error for a server */ getServerError(serverName: string): string | undefined; /** * Disconnect from a server with proper cleanup */ disconnect(serverName: string): Promise; /** * Disconnect from all servers */ disconnectAll(): Promise; /** * Get connected server names (only truly connected) */ getConnectedServers(): string[]; /** * Get all tools from all connected servers */ getAllTools(): Map; /** * Get configured tools for a server from config (before connection). * Returns empty array if server config doesn't specify tools. */ getServerConfigTools(_serverName: string): McpToolInfo[]; /** * Get total tool count across all connected servers */ getTotalToolCount(): number; } export declare const mcpClient: McpClient; //# sourceMappingURL=client.d.ts.map