/**
 * 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.js";
import type { CustomTool, CustomToolContext, CustomToolResult, RenderResultOptions } from "../extensibility/custom-tools/types.js";
import type { Theme } from "../modes/theme/theme.js";
import type { OutputMeta } from "../tools/output-meta.js";
import type { MCPContent, MCPServerConnection, MCPToolDefinition } from "./types.js";
/** Reconnect callback: tears down stale connection, returns new one or null. */
export type MCPReconnect = () => Promise<MCPServerConnection | null>;
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;
    /** Structured output metadata (set by the spill wrapper when output is truncated to an artifact). */
    meta?: OutputMeta;
}
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<TSchema, MCPToolDetails> {
    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;
    readonly approval: "write";
    /** Render completed MCP calls with the result header replacing the pending call header. */
    readonly mergeCallAndResult = true;
    /** 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<MCPToolDetails>, options: RenderResultOptions, theme: Theme, args?: unknown): import("@oh-my-pi/pi-tui").Component;
    execute(_toolCallId: string, params: unknown, _onUpdate: AgentToolUpdateCallback<MCPToolDetails> | undefined, _ctx: CustomToolContext, signal?: AbortSignal): Promise<CustomToolResult<MCPToolDetails>>;
}
/**
 * CustomTool wrapping an MCP tool with deferred connection resolution.
 */
export declare class DeferredMCPTool implements CustomTool<TSchema, MCPToolDetails> {
    #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;
    readonly approval: "write";
    /** Render completed MCP calls with the result header replacing the pending call header. */
    readonly mergeCallAndResult = true;
    /** Create DeferredMCPTool instances for all tools from an MCP server */
    static fromTools(serverName: string, tools: MCPToolDefinition[], getConnection: () => Promise<MCPServerConnection>, source?: SourceMeta, reconnect?: MCPReconnect): DeferredMCPTool[];
    constructor(serverName: string, tool: MCPToolDefinition, getConnection: () => Promise<MCPServerConnection>, source?: SourceMeta, reconnect?: MCPReconnect | undefined);
    renderCall(args: unknown, _options: RenderResultOptions, theme: Theme): import("@oh-my-pi/pi-tui").Component;
    renderResult(result: CustomToolResult<MCPToolDetails>, options: RenderResultOptions, theme: Theme, args?: unknown): import("@oh-my-pi/pi-tui").Component;
    execute(_toolCallId: string, params: unknown, _onUpdate: AgentToolUpdateCallback<MCPToolDetails> | undefined, _ctx: CustomToolContext, signal?: AbortSignal): Promise<CustomToolResult<MCPToolDetails>>;
}
