import type http from "node:http"; export declare const MCP_HTTP_METHODS: readonly ["GET", "POST", "DELETE"]; export interface HttpAuthConfiguration { authToken?: string; allowUnauthenticated: boolean; } export interface HttpAdmissionSettings { maxRequestBytes: number; headersTimeoutMs: number; requestTimeoutMs: number; keepAliveTimeoutMs: number; maxRequestsPerSocket: number; maxConcurrentRequests: number; rateLimitPerMinute: number; rateLimitBurst: number; maxRateLimitKeys: number; trustProxy: boolean; } export interface AdmissionMetrics { activeRequests: number; trackedRateLimitKeys: number; } export type AdmissionDecision = { accepted: true; release: () => void; } | { accepted: false; reason: "rate_limited" | "at_capacity"; statusCode: 429 | 503; retryAfterSeconds: number; }; /** * Reads the public-HTTP containment settings. Invalid values fail startup so a * typo cannot silently turn a request or socket bound into an unlimited one. */ export declare function readHttpAdmissionSettings(env: NodeJS.ProcessEnv): HttpAdmissionSettings; /** * A network-reachable editor control plane must never start unauthenticated in * production. The override remains available only for local development and * test harnesses where it does not create a public deployment. */ export declare function readHttpAuthConfiguration(env: NodeJS.ProcessEnv): HttpAuthConfiguration; export declare function getRequestPathname(rawUrl: string | undefined): string | undefined; export declare function isSupportedMcpMethod(method: string | undefined): boolean; export declare function requestContentLength(req: Pick): number | undefined; export declare function exceedsRequestBodyLimit(req: Pick, maxRequestBytes: number): boolean; export declare class RequestBodyTooLargeError extends Error { constructor(); } /** * Reads an MCP request body with a hard byte cap before it reaches the transport. * This avoids attaching a second live data listener beside the transport, which * can otherwise race and consume a fast chunked body before the transport does. */ export declare function readBoundedRequestBody(req: http.IncomingMessage, maxRequestBytes: number): Promise; export declare function isAuthorizedBearer(req: Pick, authToken: string | undefined): boolean; /** * The edge is authoritative by default. Honor X-Forwarded-For only after an * operator explicitly declares the proxy trusted; otherwise it is attacker * input and must not be used as a rate-limit identity. */ export declare function rateLimitIdentity(req: Pick, authorizedCredential: string | undefined, trustProxy: boolean): string; /** * Bounded, process-local protection for a single machine. It deliberately does * not log or export identities. An edge/WAF remains necessary for fleet-wide * protection across restarts and multiple instances. */ export declare class HttpAdmissionController { private readonly settings; private readonly clock; private readonly buckets; private activeRequests; constructor(settings: Pick, clock?: () => number); acquire(identity: string): AdmissionDecision; metrics(): AdmissionMetrics; private getOrCreateBucket; private pruneIdleBuckets; } //# sourceMappingURL=http-admission.d.ts.map