/** * `warden-mcp gateway`: the proxy in front of an MCP server over Streamable HTTP. What `wrap` does for stdio, through * the same checks: * - `tools/list` is answered by the gateway: it reads every page from the server, runs the tool-definition gates and * pinning (`vetAndPin`, the function `wrap` uses) and returns only the tools the verdict allows; * - `tools/call` asks the decision service first (`flowPre`), forwards an allowed call, records the result * (`flowPost`) and screens it (`screenResult`) before the client sees it; * - `resources/read`, `prompts/get` and `completion/complete` are judged, recorded and screened the same way; * - everything else (initialize, notifications, listings, the GET stream, DELETE) passes through, and in its answers * only the response to the client's own request, requests and notifications reach the client. * * A refused call is an MCP tool error (`isError: true`) with the reason and, for `ask`, the approval code, so the model * reads why and the person can approve. Responses come back as JSON or as an SSE stream, like the server's. */ import type { IncomingMessage, ServerResponse } from 'node:http'; import type { ToolDef } from './types.js'; import type { GatewayConfig, GatewayServer } from './gateway-config.js'; import { Decider, type Who } from './gateway-decide.js'; export interface SseEvent { id?: string; event?: string; data: string; } /** Split an SSE body into events (WHATWG rules for `data`, `id`, `event`; comments and `retry` ignored). */ export declare function parseSse(text: string): SseEvent[]; export declare class McpProxy { private server; private config; private decider; private logLine; private readonly ref; private readonly store; private feed?; /** What the last vetted tools/list exposed, per server session: a call to anything else is refused. */ private visible; constructor(server: GatewayServer, config: GatewayConfig, decider: Decider, logLine: (m: string) => void); private warden; private upstreamHeaders; private send; /** One request to the server, waiting for the response with this id (JSON body or SSE stream). */ private request; private key; /** Read every page, vet and pin, remember what may be called. Throws WardenBlock when the verdict blocks. */ private vetList; private json; private toolError; handle(req: IncomingMessage, res: ServerResponse, body: string, who: Who): Promise; /** * resources/read, prompts/get, completion/complete: judged like a tool call before they are sent (a resource URI or a * prompt argument can carry data out), forwarded, and their result recorded as outside text and screened. A refusal * is a JSON-RPC error with the guard's reason; there is no tool call for the model to repeat after an approval. */ private read; private call; private responseHeaders; /** Everything the gateway does not judge: sent on, answered as the server answers (streamed). */ /** A server request or notification (a log line, progress, a sampling request: text for the model), masked. */ private maskMessage; private passThrough; /** For tests and `gateway labels`: the tools the last check exposed for a session key. */ exposed(sessionKey?: string): ToolDef[] | undefined; static hash(tools: ToolDef[]): string; } //# sourceMappingURL=gateway-mcp.d.ts.map