/** * MCP stdio 传输:子进程 + 标准输入/输出上的 Newline-delimited JSON-RPC。 */ import type { McpServerConfigStdio } from "../types.js"; import type { JsonRpcRequest, JsonRpcResponse } from "../types.js"; export interface StdioTransportOptions { /** 初始化超时(毫秒) */ initTimeoutMs?: number; /** 单次请求超时(毫秒) */ requestTimeoutMs?: number; /** 初始化失败时的重试次数(不含首次,默认 1,即最多 2 次尝试) */ initRetries?: number; /** 初始化重试间隔(毫秒,默认 3000) */ initRetryDelayMs?: number; } export declare class StdioTransport { private process; private config; private initTimeoutMs; private requestTimeoutMs; private initRetries; private initRetryDelayMs; private nextId; private pending; private buffer; private stderrBuffer; private static pendingKey; constructor(config: McpServerConfigStdio, options?: StdioTransportOptions); /** 启动子进程并完成 MCP initialize 握手 */ start(): Promise; /** 从一行中解析 JSON-RPC 响应:整行即 JSON,或从第一个 { 开始提取到匹配的 }(兼容 npx/uvx 等前缀输出) */ private static parseJsonRpcResponse; private flushLines; private flushStderrLines; private flushLinesFromBuffer; private rejectAll; private initialize; private sendNotification; /** 发送 JSON-RPC 请求并等待响应 */ request(req: JsonRpcRequest, timeoutMs?: number): Promise; /** 关闭子进程 */ close(): Promise; get isConnected(): boolean; }