/** * Server runtime — single entry point for stdio and Streamable HTTP transports. * * Consumers replace the boilerplate at the bottom of their `index.ts` * (`new StdioServerTransport`, `server.connect`, error handling) with one call: * * ```ts * await startMcpServer(server); * ``` * * Transport is selected by `MCP_TRANSPORT` env (`stdio` | `http`), defaulting to `stdio`. * In `http` mode, requires `MCP_HTTP_TOKEN` for Bearer auth (or `MCP_HTTP_SKIP_AUTH=true`). */ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; export type TransportKind = "stdio" | "http"; export interface StartMcpServerOptions { /** Force a transport kind. Default: read `MCP_TRANSPORT`, fall back to `stdio`. */ transport?: TransportKind; /** HTTP port. Default: `MCP_HTTP_PORT` or `3000`. Pass `0` to let the OS pick. */ port?: number; /** HTTP bind host. Default: `MCP_HTTP_HOST` or `127.0.0.1`. */ host?: string; /** Bearer token. Default: `MCP_HTTP_TOKEN`. Required in HTTP mode unless `skipAuth`. */ token?: string; /** Skip auth even when no token is set. Default: `MCP_HTTP_SKIP_AUTH`. */ skipAuth?: boolean; /** * Allowed `Host` header values for DNS rebinding protection. Default: when bound * to a localhost address, the protection is auto-enabled with sensible defaults. * Pass an explicit list to override. */ allowedHosts?: string[]; } export interface HttpHandle { /** The actual port the server is listening on (useful when port is `0`). */ port: number; /** Stops accepting new connections and closes the underlying transport. */ close: () => Promise; } /** * Connect the MCP server to the configured transport. * * - `stdio` (default): starts a `StdioServerTransport` and returns once connected. * The promise resolves to `void`; the process stays alive via the open stdio. * - `http`: starts a Node http server hosting `/mcp` (POST/GET/DELETE) for Streamable * HTTP transport plus a public `/health` endpoint, and returns a handle for inspecting * the bound port and shutting down. Bearer auth via `MCP_HTTP_TOKEN`. * * Concurrent requests share a single stateless `StreamableHTTPServerTransport` instance, * which is the documented pattern for `sessionIdGenerator: undefined` mode. */ export declare function startMcpServer(server: McpServer, opts?: StartMcpServerOptions): Promise; //# sourceMappingURL=runtime.d.ts.map