/** * Transport-independent MCP server: JSON-RPC dispatch, protocol version * handling and tool execution. The server speaks both families of protocol * revisions at once: * * - modern (`2026-07-28`): stateless, every request carries * `_meta["io.modelcontextprotocol/protocolVersion"]`, discovery through * `server/discover`; * - legacy (`2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05`): the * `initialize` handshake. The server keeps no per-connection state, so a * request without modern metadata is answered with legacy semantics whether * or not `initialize` came first. * @module mcp/server */ export type ServerOptions = { /** * Overrides of the render limits. */ limits?: Partial; /** * Allow `!include` of files below this directory. Default: none. */ includeDir?: string; /** * Time limit per tool call (default 30000). */ timeoutMs?: number; /** * Largest accepted JSON-RPC message (default: 2 x input limit + 64 KiB). */ maxMessageBytes?: number; /** * Largest result payload (default 8 MiB). */ maxOutputBytes?: number; /** * Largest JSON-RPC batch (default 32). */ maxBatch?: number; /** * Where tools run (default "worker"). */ executor?: "worker" | "inline" | import("./executor.mjs").Executor; /** * Pre-load the layout engine in the background once a * transport starts serving (see `McpServer.warmup`). Default: off, so embedding * and tests start nothing eagerly; `excaliplant-mcp` turns it on (`--no-warmup` off). */ warmup?: boolean; /** * Receives diagnostics for stderr. Default: silent. */ log?: (message: string) => void; }; export type HandleOptions = { /** * Abort when the client went away. */ signal?: AbortSignal; /** * Lower-case HTTP headers (HTTP transport only). */ headers?: Record; }; export type HandleResult = { /** * Serialized response, or null when nothing is to be sent. */ text: string | null; /** * HTTP status the HTTP transport should use. */ status: number; }; export type McpServer = { info: Readonly<{ name: string; version: string; }>; maxMessageBytes: number; /** * Handle one raw JSON-RPC message or batch. */ handleText: (text: string, options?: HandleOptions) => Promise; handleMessage: (message: unknown, options?: HandleOptions) => Promise<{ response: object | null; status: number; }>; /** * Start loading the layout engine where tools run (the * worker thread) without blocking anything: requests are answered meanwhile and a tool call * never waits for it. Transports call this once they serve. Resolves with whether the engine * is loaded (false when disabled, closed or failed); never rejects. */ warmup: () => Promise; /** * Stop the executor and cancel everything in flight. */ close: () => Promise; }; /** * Create a server. It does no I/O itself; feed it messages with * `handleText` (the stdio and HTTP transports do this). * @param {ServerOptions} [options] * @returns {McpServer} */ export declare function createServer(options?: ServerOptions): McpServer;