import type { ToolDef } from './provider-base.js'; /** v1.2.108 — TTL for the per-server tools-list cache. See * `McpClient.cachedTools` for the policy. */ export declare const TOOLS_TTL_MS: number; /** * Tool naming policy: `mcp_{server}_{tool}`. Avoids name collisions when * two servers advertise the same tool name (common: every server has * `read_file`). The original tool name is preserved on `originalName` * so error messages stay legible and `enabledTools` filtering can match * either form. */ export declare function _namespacedNameForTest(serverName: string, toolName: string): string; /** Stage-2 config shape for one MCP server. Mirrors the zod schema in * config-schema.ts but kept here as a plain TS interface so this file * doesn't import the whole schema module just for the type. */ export interface McpServerConfig { name: string; command?: string; args?: string[]; env?: Record; cwd?: string; url?: string; headers?: Record; toolTimeoutMs?: number; enabledTools?: string[]; enabled?: boolean; } /** Result of a single tool call. Stage-2 agent loop treats this as * free-form text appended to the conversation as a tool message. */ export interface ToolCallResult { text: string; isError: boolean; } /** * Wraps one MCP server connection. The caller (`mcp-registry.ts`) * holds a Map and is responsible for lifecycle * (connectAll at boot, closeAll on shutdown). */ export declare class McpClient { readonly name: string; private readonly cfg; private readonly toolTimeoutMs; private client; private cachedTools; constructor(cfg: McpServerConfig); /** True once connect() has completed without error. */ isConnected(): boolean; /** * Pick the right transport for the config and run the MCP handshake. * Errors propagate; registry surfaces them as `unhealthy` rows. */ connect(): Promise; /** * Discover the server's tool roster and project into agim ToolDef[]. * Applies `enabledTools` filter and the namespaced-name policy. * Cache TTL: TOOLS_TTL_MS (env AGIM_MCP_TOOLS_TTL_MS, default 5 min, * 0 = no cache). Use `refresh()` to force a re-list immediately. */ listAvailableTools(): Promise; /** Force-drop the tools-list cache so the next `listAvailableTools()` * call hits the server again. Used after the agim operator knows the * upstream server changed (manual refresh in the web admin, or — in * the future — an MCP `tools/list_changed` notification). */ refresh(): void; /** * Invoke a tool by either the namespaced or original name. Returns * the concatenated text content + an isError flag (the MCP spec * lets a tool succeed at the transport level while reporting a * domain-level error; the agent loop should usually pass either * back to the model so it can react). */ callTool(callName: string, args: Record, opts?: { signal?: AbortSignal; }): Promise; /** Best-effort close. Idempotent. */ close(): Promise; private _resolveOriginalName; } /** Make sure the input schema is at least an object — MCP servers * sometimes return undefined or a non-object for parameterless tools. */ export declare function _ensureObjectSchemaForTest(raw: unknown): Record; /** * MCP tool results are `content: [{type, text, ...}, ...]`. Concatenate * every `text` block into one string for the agent loop. Non-text * blocks (image, resource) are stringified as `[image]` etc. so the * model at least sees they were there; first-class image support * lands when we wire vision providers. */ export declare function _aggregateTextContentForTest(content: unknown): string; //# sourceMappingURL=mcp-client.d.ts.map