import type { CallToolResult, Client, Tool } from '@modelcontextprotocol/client';
import type { MCPConfig } from '../core/mcp/config.ts';
import type { JsonValue } from '../types.ts';
import { Accessor } from './base.ts';
/** Where a failed MCP session end or client close is reported; silent until a host sets `debug`. */
export declare const logger: {
    debug?: (message: string) => void;
};
/**
 * Whether the server read the request and refused it, which says nothing
 * against the connection: a JSON-RPC error outside the codes the SDK spends
 * on transport, timeout and session faults. Mirrors Python's `answered`.
 */
export declare function answered(error: unknown): Promise<boolean>;
/** Whether the SDK gave up waiting for the server's answer. Mirrors Python's `timed_out`. */
export declare function timedOut(error: unknown): Promise<boolean>;
/**
 * A streamable-HTTP MCP server, one client kept per install.
 *
 * The client opens on first use and stays open until the CLI is removed. A
 * call that fails drops it, unless the server answered it with an error: the
 * next call reopens one, and the dropped one closes once the calls running on
 * it end. A cancelled call leaves it open. Unlike Python, every caller shares it: each request's
 * fetch goes through its caller's pool, so its rule and policies judge it.
 * The SDK loads on the first request, so building or restoring an MCP CLI
 * never imports it.
 */
export declare class MCPAccessor extends Accessor {
    readonly config: MCPConfig;
    private opening;
    private readonly calls;
    private readonly dropped;
    private readonly closing;
    constructor(config: MCPConfig);
    /** The one header `auth` asks for; none without auth. */
    headers(): Record<string, string>;
    /** An initialized client, which the caller closes. */
    connect(signal?: AbortSignal): Promise<Client>;
    /**
     * End the server's MCP session, waiting at most the call timeout, then close
     * the client, which aborts a session end still in flight.
     */
    private shut;
    /** Shut `opening` in the background, kept in `closing` so `close` joins it. */
    private shutting;
    /** Run `use` on an initialized client, closed when it settles. */
    session<T>(use: (client: Client) => Promise<T>, signal?: AbortSignal): Promise<T>;
    /** The kept client's opening, started when there is none. */
    private kept;
    /** Stop handing out `opening`; it closes once the calls running on it end. */
    private drop;
    /**
     * Count a call off `opening`, and start closing it if dropped and that was
     * its last; the call does not wait for the close, which may hang.
     */
    private release;
    /** The server's title and every tool it lists; the SDK reads every page. */
    listTools(): Promise<[string, Tool[]]>;
    /** Call one tool on the kept client, abandoned when `signal` aborts. */
    callTool(name: string, args: Record<string, JsonValue>, signal?: AbortSignal): Promise<CallToolResult>;
    /** Close the kept client and any dropped one. */
    close(): Promise<void>;
}
//# sourceMappingURL=mcp.d.ts.map