import type { Readable, Writable } from 'node:stream'; import type { MCPJsonRpcMessage, MCPTransport } from '../../../types/connector/mcp.js'; import { type Logger } from '../../../utils/logger.js'; /** * The server half of stdio, so `MCPServer` has something to run on. * * `MCPServer` is a complete implementation — `initialize`, `tools/list`, * `tools/call`, resource and prompt providers — and nothing anywhere * constructed one, because every transport in this directory is the * CLIENT side. `StdioTransport` spawns a child and talks to its streams; * this reads the streams THIS process was given. Same interface, opposite * end of the pipe. * * Stdio is the first transport rather than an afterthought: a client * spawns the server as a child process, so there is no port, no bind * address and no inbound authentication question to get wrong. The * boundary is the process, and the process was started by the client. * * **stdout belongs to the protocol.** A single stray `console.log` * anywhere in the process corrupts the message stream, and the symptom is * a client that reports malformed JSON rather than anything naming the * culprit. This repository's logger already writes to stderr, which is * what makes this transport safe to add; keep it that way. */ export declare class ServerStdioTransport implements MCPTransport { private readonly input; private readonly output; private buffer; private connected; private readonly log; private messageHandler?; private closeHandler?; private errorHandler?; private readonly onData; private readonly onEnd; private readonly onStreamError; /** * Streams are injected rather than read from `process` directly so a * test can drive this without owning the process's own stdio — a test * that replaced `process.stdin` would break every other test sharing * the runner. */ constructor(streams?: { input?: Readable; output?: Writable; }, log?: Logger); connect(): Promise; close(): Promise; send(message: MCPJsonRpcMessage): Promise; onMessage(handler: (message: MCPJsonRpcMessage) => void): void; onClose(handler: () => void): void; onError(handler: (error: Error) => void): void; isConnected(): boolean; /** * A chunk is not a message. Reads arrive at whatever size the pipe * hands over, so one read can carry half a message, several messages, * or the tail of one and the head of the next. Buffering until a * newline is the whole protocol framing. */ private consume; private deliver; } //# sourceMappingURL=server-stdio.d.ts.map