/** * MCP Bridge * * The MCP bridge manages HTTP listeners for `acp:` URLs and coordinates * the transformation of MCP server configurations during session creation. * * Key responsibilities: * 1. Transform `acp:$UUID` URLs to `http://localhost:$PORT` during session/new * 2. Spawn HTTP listeners for each `acp:` URL * 3. Route MCP messages between agents and proxies via `_mcp/*` messages * 4. Manage connection lifecycle */ import type { Responder } from "@thinkwell/protocol"; import type { McpServerSpec } from "./types.js"; import type { MessageQueue } from "../message-queue.js"; /** * Options for creating an MCP bridge */ export interface McpBridgeOptions { messageQueue: MessageQueue; } /** * Active connection through the MCP bridge */ interface ActiveMcpConnection { connectionId: string; acpUrl: string; sessionId: string; responder: Responder | null; } /** * MCP Bridge manager * * Manages HTTP listeners and connection lifecycle for MCP-over-ACP bridging. */ export declare class McpBridge { private readonly messageQueue; private listeners; private connections; private pendingSessions; constructor(options: McpBridgeOptions); /** * Transform MCP servers in a session/new request * * For each `acp:` URL: * 1. Spawn an HTTP listener on an ephemeral port * 2. Replace the URL with `http://localhost:$PORT` * * Returns the transformed server list and a session key for later correlation. */ transformMcpServers(servers: McpServerSpec[] | undefined, sessionKey: string): Promise<{ transformedServers: McpServerSpec[] | undefined; hasAcpServers: boolean; }>; /** * Complete session creation after receiving the session ID from the agent * * This delivers the session ID to all pending listeners so they can * correlate connections with the session. */ completeSession(sessionKey: string, sessionId: string): void; /** * Cancel a pending session (e.g., on error) */ cancelSession(sessionKey: string): Promise; /** * Handle a message from an HTTP listener */ private handleBridgeMessage; /** * Get connection info by connection ID */ getConnection(connectionId: string): ActiveMcpConnection | undefined; /** * Close all listeners and connections */ close(): Promise; } export {}; //# sourceMappingURL=mcp-bridge.d.ts.map