import type { ToolExecutionContext } from "../tool/index.js"; import type { MCPServerConfig } from "./types.js"; type JSONRPCParams = Record | unknown[]; interface JSONRPCRequest { jsonrpc: "2.0"; id?: string | number; method: string; params?: JSONRPCParams; } interface JSONRPCResponse { jsonrpc: "2.0"; id?: string | number; result?: unknown; error?: { code: number; message: string; data?: unknown; }; } /** Implement mcpserver. */ export declare class MCPServer { private static LOG_LEVELS; private logLevel; private config; private sessionManager; private taskStore; private pendingTasks; private pendingRequestAbortControllers; private clientCapabilities; private sessionCapabilities; /** Callback for server-initiated notifications. Set by transport layer. */ onNotification?: (notification: { jsonrpc: "2.0"; method: string; params?: unknown; }) => void; constructor(config: MCPServerConfig); /** * Fail-closed validation of the auth configuration (VULN-SRV-5). * * Historically, an unset `auth` field — or `{ type: "none" }` — silently * accepted every request with only a warning log. That meant an operator who * forgot to configure auth shipped an unauthenticated JSON-RPC surface. * * The new contract: `auth` is required, and the only way to accept * unauthenticated traffic is to explicitly set * `{ type: "none", allowUnauthenticated: true }`. Any other shape is * rejected at construction time. */ private static validateAuthConfig; notifyToolsChanged(): void; notifyResourcesChanged(): void; notifyPromptsChanged(): void; clientSupportsElicitation(mode: "form" | "url", sessionId?: string): boolean; handleRequest(request: JSONRPCRequest, context?: ToolExecutionContext, sessionId?: string): Promise; private dispatch; private initialize; private listTools; private callTool; private listResourceTemplates; private listResources; private readResource; private listPrompts; private getPrompt; private complete; /** * Emit a `notifications/message` log entry to the connected MCP client, * but only if `level` meets the minimum threshold set via `logging/setLevel`. * This is what makes `this.logLevel` functional rather than a no-op field. */ private emitLogNotification; private setLogLevel; private cancelRequest; private getTask; private getTaskResult; private cancelTask; private listTasks; /** Wait for all background task executions to settle. Useful in tests. */ waitForPendingTasks(): Promise; createHTTPHandler(): (request: Request) => Promise; private extractRequestContext; /** * Origin allowlist for the HTTP transport, enforced independently of the CORS * response configuration to defend against DNS-rebinding attacks. Non-browser * clients (no Origin header) are permitted. When explicit origins are * configured they are the allowlist; otherwise only loopback origins are * accepted so a default `auth: "none"` local server is not reachable from an * attacker-controlled page. */ private isOriginAllowed; private validateAuth; private getCORSHeaders; } /** Create mcpserver. */ export declare function createMCPServer(config: MCPServerConfig): MCPServer; export {}; //# sourceMappingURL=server.d.ts.map