import { type McpClientIdentity, type McpNegotiatedProtocol } from './protocol.js'; export interface McpHttpServerMessageHandlers { /** Server-to-client notification observed on a response stream. */ onNotification?: ((method: string, params?: unknown) => void) | undefined; /** * Server-to-client JSON-RPC request observed on a legacy SSE stream. * Return a result to answer it; throw (or return undefined) to have the * connection answer method-not-found. */ onServerRequest?: ((id: number | string, method: string, params?: unknown) => Promise | unknown) | undefined; } export interface McpHttpConnectionOptions { readonly serverName: string; readonly url: string; readonly clientInfo: McpClientIdentity; readonly clientCapabilities: Record; readonly timeoutMs: number; readonly fetchImpl?: typeof fetch | undefined; readonly handlers?: McpHttpServerMessageHandlers | undefined; } export declare class McpRpcError extends Error { readonly code: number; readonly data?: unknown | undefined; constructor(code: number, message: string, data?: unknown | undefined); } export declare class McpHttpConnection { private readonly options; private negotiatedProtocol; private sessionId; private closed; private nextId; constructor(options: McpHttpConnectionOptions); get isOpen(): boolean; get negotiated(): McpNegotiatedProtocol | null; private get fetchImpl(); /** * Detect the server's era and negotiate a protocol version. * Modern attempt first; recognized modern errors negotiate; anything else * falls back to the legacy initialize handshake. */ negotiate(): Promise; private negotiateLegacy; /** Send a request and return its JSON-RPC result. */ request(method: string, params: unknown, extraHeaders?: Record): Promise; /** Send a notification (expects 202, no body). */ notify(method: string, params: unknown): Promise; /** Best-effort session termination (legacy sessions only). */ close(): Promise; private modernMeta; private buildHeaders; private postAndParse; private post; private captureSessionId; private resolveJsonRpcResponse; private readSseResponse; private dispatchStreamMessage; private answerServerRequest; } //# sourceMappingURL=http-connection.d.ts.map