import type { ToolDefinition } from "../../tools/ToolTypes.js"; import { McpClient, type McpServerDefinition } from "./McpClient.js"; /** * Owns the lifetime of every configured MCP server. * * Three properties matter more than features here: * * - **Isolation.** One broken server degrades its own tools to unavailable * and never fails the run or affects another server. * - **Boundedness.** Every call has a timeout, at most one retry, and * competes for a global concurrency budget, so a slow server cannot * monopolise a run. * - **Cleanup.** stdio servers are child processes. They must be shut down * even when a run fails, or the CLI leaves orphans behind. */ /** Concurrent in-flight MCP calls across all servers. */ export declare const DEFAULT_MAX_CONCURRENT_CALLS = 4; export interface McpServerHealth { name: string; status: "connected" | "failed" | "disabled"; toolCount: number; error?: string; discoveryMs?: number; } export interface McpServerRegistryOptions { servers: readonly McpServerDefinition[]; maxConcurrentCalls?: number; /** Injected in tests. */ createClient?: (definition: McpServerDefinition) => McpClient; onEvent?: (event: McpRegistryEvent) => void; } export type McpRegistryEvent = { type: "server_connected"; server: string; toolCount: number; durationMs: number; } | { type: "server_failed"; server: string; error: string; } | { type: "server_skipped"; server: string; reason: string; }; export declare class McpServerRegistry { private readonly options; private readonly clients; private readonly health; private readonly semaphore; private discovered; constructor(options: McpServerRegistryOptions); /** * Connects to every enabled server and returns their tools as Codali tool * definitions. Servers are contacted in parallel; a failure is recorded as * unhealthy rather than thrown, so one bad entry in a tenant's config cannot * take down the run. */ discoverTools(): Promise; /** * Wraps a client so every tool call is bounded by the concurrency budget and * retried once on a transport failure. Retrying is safe here because Phase 2 * connectors are read-only. */ private wrapClient; healthReport(): McpServerHealth[]; get isDiscovered(): boolean; /** * Shuts down every connection. Must run even when a run fails: stdio servers * are child processes and would otherwise be orphaned. */ close(): Promise; } export declare const createMcpServerRegistry: (options: McpServerRegistryOptions) => McpServerRegistry; //# sourceMappingURL=McpServerRegistry.d.ts.map