import { type ScopeChecker } from "./registry.js"; /** * Transport-agnostic Streamable HTTP (JSON-RPC 2.0) handler for MisarMail MCP. * * Auth, rate limiting, and plan gating are injected rather than implemented * here: those depend on the MisarMail database and belong in the product repo. * What lives here is exactly the protocol behaviour that must stay identical to * the stdio server — the catalogue, the prompts, and the dispatch semantics. * * Deliberately built on Web `Request`/`Response` (not Next types) so the package * carries no framework dependency. */ export interface AuthenticatedCaller { userId: string; /** * The host's own scope predicate for the presented key. * * Passing a predicate rather than a scope list keeps MCP authorisation * byte-identical to the REST API's, wildcards and privileged-scope exclusions * included. Omit to skip per-tool scope checks entirely. */ hasAnyScope?: ScopeChecker; } export interface HttpHandlerOptions { /** Resolve an Authorization header to a caller, or null when invalid. */ authenticate: (authHeader: string | null) => Promise; /** Optional plan gate. Return a message to reject, or null to allow. */ checkPlan?: (caller: AuthenticatedCaller) => Promise; /** API base the tools call, e.g. `https://mail.misar.io/api/v1` for in-process calls. */ baseUrl: string; serverName?: string; serverVersion?: string; /** Called with unexpected errors so the host can log them. */ onError?: (toolName: string, error: unknown) => void; } export declare function createHttpHandler(options: HttpHandlerOptions): (request: Request) => Promise; /** CORS preflight response for browser-based MCP clients. */ export declare function corsPreflight(): Response; //# sourceMappingURL=http.d.ts.map