import type { JSONRPCMessage, JSONRPCResponse } from './types.js'; import { BaseTransport, type BaseTransportConfig } from './base-transport.js'; /** * Configuration for HTTP Transport. */ export interface HTTPTransportConfig extends BaseTransportConfig { /** Base URL of the MCP server (e.g., https://api.example.com/mcp) */ baseUrl: string; /** Optional session ID for authenticated connections */ sessionId?: string; /** Custom headers to include in requests */ headers?: Record; /** Request timeout in milliseconds (default: 30000) */ timeout?: number; } /** * HTTPTransport connects to MCP servers over HTTP using POST requests. * * This transport is used for remote MCP servers that expose a simple * HTTP endpoint. Each request is sent as a POST and the response is * returned directly. * * This is a request-response pattern, unlike SSE which supports * server-initiated messages. * * Expected server endpoint: * - POST {baseUrl} - JSON-RPC endpoint */ export declare class HTTPTransport extends BaseTransport { private connected; private abortController; private readonly baseUrl; private sessionId?; private readonly customHeaders; private readonly timeout; /** Protocol version negotiated with the server (set after initialization) */ private negotiatedVersion?; constructor(config: HTTPTransportConfig); /** * Build request headers, including session ID and protocol version. * Per MCP 2025-11-25 streamable-http spec: * - MCP-Protocol-Version must be included on all requests after initialization * - Mcp-Session-Id must be included if we have one from initialization */ private buildHeaders; /** * Initialize the HTTP transport. * For HTTP, there's no persistent connection, so this just validates the URL. */ connect(): Promise; /** * Set the negotiated protocol version to use in subsequent request headers. * Called by MCPClient after successful initialization. */ setNegotiatedVersion(version: string): void; /** * Send a JSON-RPC message to the server via HTTP POST. * * Unlike SSE transport, this method handles the response synchronously * and emits a 'message' event with the response. */ send(message: JSONRPCMessage, signal?: AbortSignal): void; /** * Send a JSON-RPC message and wait for the response. */ sendAsync(message: JSONRPCMessage, signal?: AbortSignal): Promise; /** * Handle a streaming HTTP response (text/event-stream). * Includes timeout handling to prevent indefinite hangs. */ private handleStreamingResponse; /** * Close the HTTP transport. */ close(): void; /** * Check if the transport is connected. */ isConnected(): boolean; } //# sourceMappingURL=http-transport.d.ts.map