/** * Minimal MCP client. * * Deliberately covers only `tools/list` and `tools/call`. Resources and prompts * are deferred because no requirement in `codali_workflow.txt` needs them, and * an unused surface is still a surface to maintain and secure. * * The transports come from the official SDK rather than being hand-rolled, so * protocol lifecycle, framing, and session handling stay the SDK's problem. * Only the two transports the spec currently defines are offered — stdio and * Streamable HTTP. There is no separate legacy HTTP+SSE transport: current MCP * carries SSE *within* Streamable HTTP where it is needed. */ /** * Protocol version this build was written and tested against. Asserted in * tests so an SDK bump that changes the wire protocol fails loudly here rather * than silently against a live server. */ export declare const CODALI_MCP_PROTOCOL_VERSION = "2025-11-25"; export declare const CODALI_MCP_CLIENT_INFO: { readonly name: "codali"; readonly version: "1.0.0"; }; export type McpTransportKind = "stdio" | "http"; export interface McpStdioTransportConfig { transport: "stdio"; command: string; args?: string[]; env?: Record; cwd?: string; } export interface McpHttpTransportConfig { transport: "http"; url: string; headers?: Record; } export type McpTransportConfig = McpStdioTransportConfig | McpHttpTransportConfig; export interface McpServerConfig { name: string; enabled?: boolean; timeoutMs?: number; /** * Operator's declaration that this server's exposed tools are read-only. * * Defaults to `false`, and that default is deliberate. A server's own * `readOnlyHint` cannot be trusted — it is the party being constrained * vouching for itself — and Codali has no other way to know whether * `edit_file` edits a file. So an unvetted server's tools are treated as * capable of mutation, which keeps them out of the default tool set until an * operator either declares the server read-only or names the specific tools * to expose via `allowTools`. */ readOnly?: boolean; /** * Tools to expose from this server. Absent means all discovered tools. * Deny always wins over allow. */ allowTools?: string[]; denyTools?: string[]; } export type McpServerDefinition = McpServerConfig & McpTransportConfig; export interface McpToolDefinition { name: string; description?: string; inputSchema?: Record; outputSchema?: Record; /** * Server-supplied hints (`readOnlyHint`, `destructiveHint`, …). * * Retained for display and diagnostics only. These are **not** trusted for * security decisions: a server declaring itself read-only is an assertion by * the very party being constrained. Codali policy decides what may run. */ annotations?: Record; } export interface McpCallResult { ok: boolean; text: string; structured?: unknown; raw: unknown; } export declare class McpClientError extends Error { readonly code: string; readonly server: string; readonly retryable: boolean; constructor(code: string, server: string, message: string, options?: { retryable?: boolean; cause?: unknown; }); } /** * Flattens MCP content blocks into text the model can read. Non-text blocks are * described rather than dropped, so a run never silently loses a result it * cannot render. */ export declare const flattenMcpContent: (content: unknown) => string; export interface McpClientOptions { definition: McpServerDefinition; /** Injected in tests to avoid spawning processes or opening sockets. */ createClient?: () => Promise; } /** The slice of the SDK client this wrapper depends on. */ export interface McpTransportClient { listTools(params?: Record, options?: { timeout?: number; }): Promise<{ tools: unknown[]; }>; callTool(params: { name: string; arguments?: Record; }, resultSchema?: unknown, options?: { timeout?: number; }): Promise; close(): Promise; } export declare class McpClient { private readonly options; private client?; private connecting?; constructor(options: McpClientOptions); get name(): string; private get timeoutMs(); /** Connects lazily; concurrent callers share one in-flight connection. */ private ensureClient; private connect; listTools(): Promise; callTool(name: string, args: unknown): Promise; close(): Promise; } export declare const createMcpClient: (options: McpClientOptions) => McpClient; //# sourceMappingURL=McpClient.d.ts.map