import { type IncomingMessage } from 'node:http'; import type { Server } from '@modelcontextprotocol/sdk/server/index.js'; /** Builds a wired MCP `Server` for one account; see `createServer()` in lib/server.ts. */ export type ServiceFactory = (account: string) => Promise; export type HostOptions = { /** Services to serve, keyed by the path segment that names them (`gmail`, `drive`, ...). */ services: Record; /** Account labels to serve; each becomes the first path segment. */ accounts: string[]; /** Interface to bind; defaults to the loopback address. */ hostname?: string; /** TCP port; 0 picks a free one (tests). Defaults to 8765. */ port?: number; /** * Shared secret every request must present as `Authorization: Bearer `. * Optional on loopback, where the OS already limits callers to this machine; * required when binding anything else. */ token?: string; /** Idle time after which a session is closed; defaults to 12 hours. */ idleMs?: number; /** Largest request body accepted, in bytes; defaults to 16 MiB. */ maxBodyBytes?: number; /** Clock, injectable for tests. */ now?: () => number; /** Line logger; defaults to stderr. */ log?: (line: string) => void; }; export type Host = { /** Base URL the host is reachable at; sessions live under `//`. */ url: string; port: number; /** Live session count. */ sessions: () => number; /** Close every session idle longer than `idleMs`; returns how many. Runs on a timer. */ reap: () => number; /** Close every session and the listener. */ close: () => Promise; }; /** * The `Host` header values the SDK's DNS-rebinding guard accepts. On a loopback * bind, the three spellings of this machine; anywhere else the guard is off * (the bound hostname is not enumerable from here), so the token is the guard. */ export declare function allowedHosts(hostname: string, port: number): string[] | undefined; /** Parse `//` from a request URL; null for any other shape. */ export declare function route(url: string | undefined): { account: string; service: string; } | null; /** Read a bounded body; null means overflow or an interrupted stream. */ export declare function readBody(req: IncomingMessage, limit: number): Promise; /** * One process, every service, every account: a Streamable HTTP MCP host. Each * client connection is its own MCP session with its own `Server` (the SDK * binds one transport per `Server`), built by the service factory for the * account in the path, so the wire surface is exactly the stdio bin's. The * point is the process count: a machine running several agents forks one * stdio server per service per account per client session, and clients that * spawn per thread and never close leave hundreds of idle Node processes * behind; here they are sessions in one process, and idle ones are reaped. */ export declare function host(options: HostOptions): Promise; //# sourceMappingURL=host.d.ts.map