/** * McpClient - Model Context Protocol Client for Ag-Bash */ import type { ExecutionLimits } from "../limits.js"; import type { CommandContext } from "../types.js"; /** * Minimal structural interface describing what McpClient needs from a Bash * instance. Using a narrow interface avoids a circular import on the full * Bash class and decouples McpClient from private internals. */ interface McpBashLike { readonly limits: Required; } export interface McpTool { name: string; description?: string; inputSchema: Record; } export interface McpServerConnection { id: string; name: string; type: "stdio" | "http"; status: "connected" | "disconnected" | "error"; tools: McpTool[]; transport: McpTransport; } export interface McpTransport { init(): Promise; send(message: unknown): Promise; /** * Send a JSON-RPC notification (no `id`, no response expected). Separate * from {@link send} because notifications must never be registered in a * pending-request map: a server that legitimately never replies to * `notifications/initialized` would otherwise hang that call until its * request-timeout fires. */ notify(message: unknown): void; close(): void; } /** Security configuration for HttpTransport. */ export interface HttpTransportSecurityConfig { /** Allow requests to private/internal network addresses. Default: false. */ allowPrivateNetworks?: boolean; } /** * Error thrown when an SSRF-blocked URL is detected. * @public */ export declare class McpTransportSecurityError extends Error { constructor(message: string); } /** Configuration options for StdioTransport. */ export interface StdioTransportOptions { /** Timeout in milliseconds for pending requests. Default: 30000 (30s). */ requestTimeoutMs?: number; } export declare class McpClient { private connections; /** MCP protocol revision this client requests during `initialize`. */ private static readonly PROTOCOL_VERSION; /** * Perform the MCP `initialize` request followed by the * `notifications/initialized` notice. The spec requires this exchange * before any `tools/list` or `tools/call` request is legal; a real * server (unlike the untested mock transports this client was * previously only exercised against) rejects those requests otherwise. */ private handshake; connectStdio(id: string, command: string, args: string[], cmdCtx: CommandContext, options?: StdioTransportOptions): Promise; connectHttp(id: string, url: string, bash?: McpBashLike, securityConfig?: HttpTransportSecurityConfig): Promise; private discoverTools; callTool(connectionId: string, toolName: string, args: Record, bash?: McpBashLike): Promise; listConnections(): McpServerConnection[]; disconnect(id: string): void; /** Release all resources and disconnect all servers. */ dispose(): Promise; } export {};