/** * MCP client wrapper using JSON-RPC 2.0 over HTTP/SSE. * * Pi-search talks to three MCP-compatible servers: * - Exa (https://mcp.exa.ai/mcp) * - DeepWiki (https://mcp.deepwiki.com/mcp) * - Context7 (https://context7.com/api/v2 — REST, not JSON-RPC; handled in tools/context7.ts) * * The original monolithic index.ts used raw `fetch()` with hand-rolled * JSON-RPC envelopes and SSE parsing. This module centralizes that * logic behind a thin interface so it can be: * - unit tested with a fake transport * - swapped for a different transport later (e.g. stdio) * - time-bounded and abortable * - mapped onto coded errors (McpError) */ export type McpServerName = "exa" | "deepwiki"; export type McpCallResult = { content: Array<{ type: "text"; text: string; }>; isError?: boolean; }; export type McpInvokeOptions = { signal?: AbortSignal; timeoutMs?: number; }; export interface McpClient { /** List tool names available on a given server. */ listToolNames(server: McpServerName): Promise; invoke(args: { server: McpServerName; toolName: string; arguments: Record; options?: McpInvokeOptions; }): Promise; close(): Promise; } /** Parse MCP-over-HTTP responses: either `application/json` or SSE (`text/event-stream`). */ export declare function parseMcpMessages(text: string, contentType: string): Record[]; export declare function textFromMcpContent(content: unknown): string; /** Default MCP client backed by Node's global fetch + JSON-RPC 2.0. */ export declare class JsonRpcHttpMcpClient implements McpClient { listToolNames(server: McpServerName): Promise; invoke({ server, toolName, arguments: args, options, }: { server: McpServerName; toolName: string; arguments: Record; options?: McpInvokeOptions; }): Promise; close(): Promise; } export declare function createDefaultMcpClient(): McpClient; //# sourceMappingURL=client.d.ts.map