import type { MethodContext } from '../daemon/methods.js'; import { type McpId } from './protocol.js'; export interface McpServerOpts { /** * In-process method context: handles + audit. The MCP server invokes * sign methods directly against this — no cross-process IPC. */ context: MethodContext; /** * Extra text appended to a tool's description at tools/list time, keyed by * tool name. Tool descriptions are the only channel through which the * model discovers capabilities, and the static definitions can't know * runtime config — this is how sigil-mcp advertises the JSON-RPC signing * proxy endpoint when the [rpc] block is enabled. */ toolNotes?: Readonly>; /** * Optional log sink for protocol-level events. Defaults to a no-op. * The default binary entrypoint writes log events to stderr so they don't * collide with stdio MCP traffic on stdout. */ onLog?: (event: McpLogEvent) => void; } export type McpLogEvent = { kind: 'recv'; method: string; id: McpId | null; } | { kind: 'send_ok'; id: McpId; } | { kind: 'send_error'; id: McpId; code: number; message: string; } | { kind: 'initialized'; }; /** * Handle a single received line by dispatching it through the MCP protocol. * Returns either a response string to send back, or `null` if the line was a * notification (no response expected). * * Async because tools/call can perform an out-of-band confirm round-trip * (sign_transaction → ConfirmGate → human ack) that may take seconds. */ export declare function handleLine(line: string, opts: McpServerOpts): Promise; export interface McpStdioOpts extends McpServerOpts { stdin: NodeJS.ReadableStream; stdout: NodeJS.WritableStream; } /** * Run the MCP server over arbitrary streams (stdin/stdout in production, * mock streams in tests). Resolves when stdin closes AND any in-flight * requests have finished — so a slow confirm round-trip doesn't get * truncated by an early resolve. * * Concurrency: handlers run serially, chained through a processing promise. * That preserves response ordering (matches sync behavior pre-confirm) and * keeps stdout writes ordered without needing a separate write queue. * Trade-off: a long-pending confirm on request A blocks request B until A * resolves. Acceptable for sigil — agents don't pipeline tool calls in * practice, and serial is the simpler correctness story. */ export declare function runMcpStdio(opts: McpStdioOpts): Promise; //# sourceMappingURL=server.d.ts.map