/** * MCP to CustomTool bridge. * * Converts MCP tool definitions to CustomTool format for the agent. */ import type { AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { TSchema } from "@oh-my-pi/pi-ai"; import type { SourceMeta } from "../capability/types"; import type { CustomTool, CustomToolContext, CustomToolResult, RenderResultOptions } from "../extensibility/custom-tools/types"; import type { Theme } from "../modes/theme/theme"; import type { MCPContent, MCPServerConnection, MCPToolDefinition } from "./types"; /** Reconnect callback: tears down stale connection, returns new one or null. */ export type MCPReconnect = () => Promise; export declare function isRetriableConnectionError(error: unknown): boolean; /** Details included in MCP tool results for rendering */ export interface MCPToolDetails { /** Server name */ serverName: string; /** Original MCP tool name */ mcpToolName: string; /** Whether the call resulted in an error */ isError?: boolean; /** Raw content from MCP response */ rawContent?: MCPContent[]; /** Provider ID (e.g., "claude", "mcp-json") */ provider?: string; /** Provider display name (e.g., "Claude Code", "MCP Config") */ providerName?: string; } export declare function createMCPToolName(serverName: string, toolName: string): string; /** * Parse an MCP tool name back to server and tool components. * * Note: This returns the normalized tool name (with server prefix stripped). * The original MCP tool name may have had the server name as a prefix. */ export declare function parseMCPToolName(name: string): { serverName: string; toolName: string; } | null; /** * CustomTool wrapping an MCP tool with an active connection. */ export declare class MCPTool implements CustomTool { private connection; private readonly tool; private readonly reconnect?; readonly name: string; readonly label: string; readonly description: string; readonly parameters: TSchema; /** Original MCP tool name (before normalization) */ readonly mcpToolName: string; /** Server name */ readonly mcpServerName: string; /** Create MCPTool instances for all tools from an MCP server connection */ static fromTools(connection: MCPServerConnection, tools: MCPToolDefinition[], reconnect?: MCPReconnect): MCPTool[]; constructor(connection: MCPServerConnection, tool: MCPToolDefinition, reconnect?: MCPReconnect | undefined); renderCall(args: unknown, _options: RenderResultOptions, theme: Theme): import("@oh-my-pi/pi-tui").Component; renderResult(result: CustomToolResult, options: RenderResultOptions, theme: Theme, args?: unknown): import("@oh-my-pi/pi-tui").Component; execute(_toolCallId: string, params: unknown, _onUpdate: AgentToolUpdateCallback | undefined, _ctx: CustomToolContext, signal?: AbortSignal): Promise>; } /** * CustomTool wrapping an MCP tool with deferred connection resolution. */ export declare class DeferredMCPTool implements CustomTool { #private; private readonly serverName; private readonly tool; private readonly getConnection; private readonly reconnect?; readonly name: string; readonly label: string; readonly description: string; readonly parameters: TSchema; /** Original MCP tool name (before normalization) */ readonly mcpToolName: string; /** Server name */ readonly mcpServerName: string; /** Create DeferredMCPTool instances for all tools from an MCP server */ static fromTools(serverName: string, tools: MCPToolDefinition[], getConnection: () => Promise, source?: SourceMeta, reconnect?: MCPReconnect): DeferredMCPTool[]; constructor(serverName: string, tool: MCPToolDefinition, getConnection: () => Promise, source?: SourceMeta, reconnect?: MCPReconnect | undefined); renderCall(args: unknown, _options: RenderResultOptions, theme: Theme): import("@oh-my-pi/pi-tui").Component; renderResult(result: CustomToolResult, options: RenderResultOptions, theme: Theme, args?: unknown): import("@oh-my-pi/pi-tui").Component; execute(_toolCallId: string, params: unknown, _onUpdate: AgentToolUpdateCallback | undefined, _ctx: CustomToolContext, signal?: AbortSignal): Promise>; }