export interface JsonRpcStdioOptions { /** Executable to spawn (resolved against PATH by child_process). */ command: string; /** Argument vector — never a shell string. */ args: string[]; /** Working directory for the child. */ cwd?: string; /** Extra environment; merged over process.env. */ env?: NodeJS.ProcessEnv; /** Per-request timeout in ms (default 15000). */ requestTimeoutMs?: number; /** Called once if the child exits (for any reason). */ onExit?: (code: number | null, signal: NodeJS.Signals | null) => void; /** Called for each stderr chunk (diagnostics). */ onStderr?: (chunk: string) => void; } /** Payload of an MCP `notifications/progress` message. */ export interface ProgressNotification { progressToken: number | string; progress?: number; total?: number; message?: string; } /** * A live JSON-RPC 2.0 session over a child process's stdio. * * Lifecycle: construct → start() → request()/notify()* → close(). * A crashed or exited child rejects all in-flight requests so callers never * hang. `start()` is idempotent-guarded (throws if called twice). */ export declare class JsonRpcStdioClient { private readonly opts; private child; private nextId; private readonly pending; private stdoutBuf; private exited; private exitError; private readonly timeoutMs; constructor(opts: JsonRpcStdioOptions); /** Spawn the child and begin reading responses. */ start(): void; /** * Send a request and await its result. Rejects on error / timeout / exit. * `onProgress`, if given, fires for each `notifications/progress` the server * emits for this request (and each one also resets the inactivity timer). */ request(method: string, params?: unknown, onProgress?: (p: ProgressNotification) => void): Promise; /** * Return a shallow copy of `params` with `_meta.progressToken` set to `token`, * without mutating the caller's object. MCP reserves `params._meta` for this; * servers that don't emit progress simply ignore it. */ private withProgressToken; /** Fire-and-forget notification (no id, no response expected). */ notify(method: string, params?: unknown): void; /** Close stdin and terminate the child; rejects any stragglers. */ close(): Promise; private onStdout; private dispatch; /** * Handle a server-initiated notification. Only `notifications/progress` is * actioned: it restarts the inactivity timer of the request whose * `progressToken` it carries (the request id we assigned), turning the flat * request deadline into an idle timeout that survives long, live operations. */ private onNotification; private fail; private rejectAll; }