/** * MCP Streamable HTTP transport * * Adds HTTP transport alongside stdio. Unprotected mode only. * Each session gets its own McpServer + transport (CVE-2026-25536 defense). * * Endpoints: * POST /mcp JSON-RPC tool calls (requires Mcp-Session-Id after init) * DELETE /mcp Terminate session * GET /health Health check (no auth) * GET /.well-known/oauth-protected-resource[/] PRM (conditional) * GET /mcp 405 Method Not Allowed */ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; /** * Trust-proxy configuration for X-Forwarded-For interpretation. * * Presets: * - 'off': never trust forwarded headers (default; safe for direct clients) * - 'loopback': trust only from 127.0.0.0/8 and ::1 * - 'linklocal': trust loopback + link-local (169.254.0.0/16, fe80::/10) * - 'private': trust loopback + link-local + RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) * - 'all': trust any remote address (DISCOURAGED; use only when behind a fully trusted proxy chain) * * Explicit addresses: * - comma-separated IPs: trust only from listed addresses (e.g., '10.0.0.1,10.0.0.2') * * WARNING: only enable behind a trusted reverse proxy. An attacker can forge * X-Forwarded-For from an untrusted peer to bypass per-IP rate limiting. */ export type TrustProxyValue = 'off' | 'loopback' | 'linklocal' | 'private' | 'all' | string; export interface HttpTransportOptions { /** Port to listen on. Default: 3000 */ port?: number; /** Bind address. Default: '127.0.0.1' (localhost only) */ host?: string; /** Allowed CORS origins (empty = deny all). */ corsOrigins?: string[]; /** OAuth authorization server URIs (enables PRM with publicUrl). */ authorizationServers?: string[]; /** Canonical public URL of this server (required for PRM). */ publicUrl?: string; /** Trust X-Forwarded-For for rate limiting. Default: 'off' */ trustProxy?: TrustProxyValue; /** Max request body bytes. Default: 1MB */ maxRequestBytes?: number; /** Rate limit: requests per minute per session. Default: 100 */ rateLimitRpm?: number; /** Session TTL in ms. Default: 30 min */ sessionTtlMs?: number; /** Max concurrent sessions. Default: 100 */ maxSessions?: number; /** Max sessions per client IP. Default: 10 */ maxSessionsPerIp?: number; /** Factory to create new McpServer instances (one per session) */ serverFactory: () => McpServer; } /** Upper bound on tracked rate-limit windows; the oldest window is evicted first. */ export declare const MAX_RATE_LIMIT_KEYS = 10000; /** Rate-limit key: a valid id of a live session, otherwise the client address. */ export declare function rateLimitKeyFor(sessionId: string | undefined, clientIp: string, isLiveSession: (id: string) => boolean): string; /** * Create and start an HTTP server for MCP Streamable HTTP transport. * Returns a cleanup function to shut everything down. */ export declare function createHttpTransport(options: HttpTransportOptions): Promise<{ cleanup: () => Promise; /** Number of tracked rate-limit windows (test seam). */ rateLimitKeyCount: () => number; }>; //# sourceMappingURL=http-transport.d.ts.map