/** * MCP Stdio Transport Implementation * * Implements the Model Context Protocol transport layer using stdin/stdout * for communication with Claude Code. Uses newline-delimited JSON messages. * * @see https://spec.modelcontextprotocol.io/specification/basic/transports/ */ import { EventEmitter } from 'events'; import type { MCPTransport, StdioTransportOptions, JsonRpcMessage, JsonRpcRequest, JsonRpcNotification } from '../types'; /** * Stdio Transport for MCP Protocol * * Handles bidirectional communication using stdin for incoming messages * and stdout for outgoing messages. Messages are newline-delimited JSON. */ export declare class StdioTransport extends EventEmitter implements MCPTransport { private readonly inputStream; private readonly outputStream; private readonly debug; private buffer; private isRunning; private isClosed; onMessage: ((message: JsonRpcRequest | JsonRpcNotification) => void) | null; onError: ((error: Error) => void) | null; onClose: (() => void) | null; constructor(options?: StdioTransportOptions); /** * Start the transport - begin listening for incoming messages */ start(): Promise; /** * Stop the transport - clean up resources */ stop(): Promise; /** * Send a JSON-RPC message through stdout */ send(message: JsonRpcMessage): Promise; /** * Set up input stream event handlers */ private setupInputHandlers; /** * Handle incoming data from stdin */ private handleInputData; /** * Process the input buffer for complete messages */ private processBuffer; /** * Parse and dispatch a single message */ private parseAndDispatchMessage; /** * Dispatch a validated message to the handler */ private dispatchMessage; /** * Write data to the output stream */ private writeToOutput; /** * Handle transport errors */ private handleError; /** * Debug logging (to stderr to avoid polluting stdout) */ private debugLog; } /** * Transport-specific error class */ export declare class TransportError extends Error { readonly code: string; constructor(message: string, code: string); } /** * Create a new stdio transport instance */ export declare function createStdioTransport(options?: StdioTransportOptions): StdioTransport; /** * Response builder utilities for transport layer */ export declare const ResponseBuilder: { /** * Build a success response */ success(id: string | number | null, result: unknown): JsonRpcMessage; /** * Build an error response */ error(id: string | number | null, code: number, message: string, data?: unknown): JsonRpcMessage; /** * Build a notification message */ notification(method: string, params?: Record): JsonRpcMessage; }; //# sourceMappingURL=transport.d.ts.map