import type { IMCPClient } from '../interfaces.mcp.js'; import type { OtelInfoType } from '../types.js'; export type MCPClientParam = { url: string; toolPriority?: Record; requestInit?: RequestInit; clientConfig?: { name?: string; version?: string; }; }; /** * A Client for the Model Context Protocol (MCP). * * This connector bridges Arvo Agents with the external MCP ecosystem, allowing agents to * interact with filesystem, databases, GitHub, Slack, and other standardized MCP servers. * * @remarks * **Key Features:** * - **Auto-Transport Selection:** Automatically chooses between `SSEClientTransport` and * `StreamableHTTPClientTransport` based on the URL pattern (checks for `/mcp` suffix). * - **Orchestration Control:** Supports mapping priorities to external tools, allowing * MCP tools to participate in Arvo's **Priority Batch Execution** logic. * - **Observability:** Deep integration with Arvo's OpenTelemetry system to trace * connection status and tool execution metrics. * - **Tool Caching:** Discovers and caches tool definitions upon connection to minimize latency * during the Agent's reasoning loop. * * @example * ```ts * const mcp = new MCPClient({ * url: 'http://localhost:8080/mcp', * // Give the 'check_files' tool high priority so it executes before other tools * toolPriority: { * 'check_files': 1 * } * }); * ``` */ export declare class MCPClient implements IMCPClient { private client; private isConnected; private availableTools; private readonly url; private readonly requestInit; private readonly toolPriority; private readonly clientConfig; /** * Creates a new MCP Client. * * @param param - Configuration object or a Lazy Configuration function. * * **Why use a function?** * Using a function is recommended if the URL, Auth Headers, or Tool Priorities * need to be resolved at **Runtime** (e.g., fetched from a Secrets Manager or Env Var) * rather than at **Instantiation time**. */ constructor(param: MCPClientParam | (() => MCPClientParam)); /** * Initializes the connection to the remote MCP Server. * * This lifecycle method: * 1. Resolves the Transport (SSE vs HTTP). * 2. Performs the protocol handshake. * 3. Fetches the list of available tools immediately (to populate the Agent's context). * * @param config - Trace context. * @throws Error if the connection fails or handshake is rejected. */ connect(config: { otelInfo: OtelInfoType; }): Promise; /** * Returns the Tool Definitions discovered during the `connect()` phase. * * This maps the raw MCP Tool format into Arvo's `AgentToolDefinition` structure * so they can be injected into the LLM's context window. */ getTools(config: { otelInfo: OtelInfoType; }): Promise<{ name: string; description: string; inputSchema: Record; }[]>; /** * Executes a tool on the remote MCP Server. * * Wraps the execution in a dedicated OpenTelemetry Child Span (`MCP.invoke`) * to track latency and success/failure rates of the external system. * * @param param - The tool name and argument payload generated by the LLM. * @returns The simplified JSON string result to be fed back to the LLM. */ invokeTool(param: { name: string; arguments?: Record | null; }, config: { otelInfo: OtelInfoType; }): Promise; /** * Terminates the transport session and resets clients state. * Safe to call multiple times (idempotent). */ disconnect(config: { otelInfo: OtelInfoType; }): Promise; /** * Retrieves the priority configuration for MCP Tools. * * This allows external MCP tools to explicitly participate in Arvo's **Priority Batch Execution**. */ getToolPriority(): Promise>; } //# sourceMappingURL=MCPClient.d.ts.map