import type { McpServerConfig } from './config.js'; import type { McpClientOptions, McpToolInfo, McpToolSchema } from './client-types.js'; import { type McpNegotiatedProtocol } from './protocol.js'; export type { JsonRpcId } from './jsonrpc.js'; export type { McpClientNotification, McpClientOptions, McpClientServerRequest, McpClientUnhandledResponse, McpElicitationResolver, McpProcessSpec, McpToolInfo, McpToolSchema, } from './client-types.js'; export declare class McpClient { private config; private options?; private proc; private nextId; private pendingRequests; private buffer; private readLoopRunning; private restartCount; private initialized; /** Set true by disconnect() to suppress the read-loop's auto-restart. Reset on each successful _startProcess(). */ private intentionalClose; /** Streamable HTTP connection when the server is configured with a `url`. */ private http; /** Outcome of protocol version negotiation, for diagnostics. */ private negotiated; /** Cache: tool name → full schema (populated lazily on first callTool) */ private schemaCache; /** Minimal tool info loaded at connect time (name + description only) */ private toolInfoCache; constructor(config: McpServerConfig, options?: McpClientOptions | undefined); get name(): string; get isConnected(): boolean; /** The negotiated protocol (era, version, transport), or null before connect. */ get protocolInfo(): McpNegotiatedProtocol | null; /** * connect, Start the transport and negotiate a protocol version. * After connect, listTools() is available. No tool data is fetched here. */ connect(): Promise; /** * listTools, Return tool names and descriptions (progressive loading). * Full schemas are NOT fetched here; call getToolSchema() to get them. */ listTools(): Promise; /** * getToolSchema, Fetch full JSON schema for a tool (lazy, cached). * MCP protocol provides full schemas in tools/list; we cache them on first access. */ getToolSchema(toolName: string): Promise; /** * callTool, Execute a tool on the MCP server. * Fetches full schema on first use (if not already cached). * Modern-era servers may answer with an input_required interim result * (Multi Round-Trip Requests); elicitation input requests are resolved * through the wired resolver and the call is retried with inputResponses. */ callTool(toolName: string, args: Record): Promise; /** Mcp-Param-* headers for a tools/call on the modern HTTP transport. */ private _toolCallHeaders; /** Resolve MRTR input requests; only elicitation is answerable client-side. */ private _resolveInputRequests; /** * disconnect, Stop the server process and clean up. */ disconnect(): Promise; private _startProcess; /** Capabilities advertised to the server (both eras). */ private _clientCapabilities; /** * Detect the server's era and negotiate a protocol version (stdio). * * Probe with `server/discover` first, as the specification directs for * dual-era stdio clients. A recognized modern error negotiates from the * server's advertised versions; any other error (or probe silence) falls * back to the `initialize` handshake. */ private _negotiate; /** * Send a JSON-RPC request; returns the result. In the modern era the * request params carry the per-request `_meta` the revision requires. */ private _request; /** Send a JSON-RPC request over stdio without protocol decoration. */ private _rawRequest; /** Send a JSON-RPC notification (no response expected). */ private _notify; private _startReadLoop; private _processBuffer; private _dispatchLine; private _handleResponse; private _handleNotification; private _handleServerRequest; private _handleUnhandledResponse; private _sendJsonRpcError; private _sendJsonRpcResult; private _callObserver; private _scheduleRestart; /** * ping, Check whether the server is healthy. * The 2026-07-28 revision removed `ping`; modern-era servers are probed * with `server/discover` instead. Legacy servers keep the classic ping. */ ping(): Promise; /** * Answer a server-to-client JSON-RPC request arriving on a legacy HTTP SSE * stream. Elicitation routes to the wired resolver; everything else is * unsupported (the connection answers method-not-found for undefined). */ private _answerServerRequestOverHttp; } //# sourceMappingURL=client.d.ts.map