/** * MCP Client — connects to an MCP server, discovers tools, and forwards calls. * * Lifecycle: * 1. connect() — spawn server, perform initialize handshake, list tools * 2. listTools() — return discovered tools (cached from connect) * 3. callTool(name, args) — forward tool invocation to server * 4. disconnect() — gracefully shut down * * Swarm-aware: A single MCPClient instance can serve multiple swarm agents. * Tool calls are stateless — concurrent callers are safe. */ import type { MCPServerConfig, MCPToolDefinition, MCPCallToolResult, MCPClientState, MCPClientInfo } from "./types.js"; export declare class MCPClient { private config; private transport; private state; private serverInfo; private tools; private error; private onToolsChanged; private _connectLock; private _refreshLock; constructor(config: MCPServerConfig, options?: { onToolsChanged?: () => void; }); /** * Connect to the MCP server: * 1. Spawn the server process via stdio transport * 2. Perform the initialize handshake * 3. Send initialized notification * 4. Discover available tools */ connect(): Promise; private _runConnect; /** * Disconnect from the MCP server gracefully. */ disconnect(): Promise; /** * Refresh the tool list from the server. */ refreshTools(): Promise; /** * Return the cached list of available tools. */ listTools(): MCPToolDefinition[]; /** * Call a tool on the MCP server. * Returns the tool result with content array. * * Concurrency-safe: multiple callers can invoke simultaneously. */ callTool(name: string, args?: Record): Promise; getState(): MCPClientState; getInfo(): MCPClientInfo; private handleNotification; } //# sourceMappingURL=client.d.ts.map