/** * MCP sampling wrapper. * * Lets tool implementations ask the host (Claude Code) to run an LLM * completion on their behalf — using the user's existing Claude Pro/Max * subscription. No API key, no billing, no external HTTP call. * * The Server instance is set once from index.ts and held at module level * so handlers don't need to change their signatures. */ import type { Server } from "@modelcontextprotocol/sdk/server/index.js"; export declare function setServer(server: Server): void; export declare function getServer(): Server; /** * Probe whether the connected MCP host supports sampling. * * Some hosts (notably Claude Code CLI as of early 2026) do not implement * the `sampling/createMessage` method and respond with JSON-RPC -32601 * "Method not found". Other hosts (Claude Desktop, Cursor) support it. * * Result is cached per-session — we only ask once. * * Returns true if sampling works, false if the host doesn't support it. * Any other error (timeout, network, user rejection) also returns false * since the practical effect is the same: we can't use sampling. */ export declare function probeSampling(): Promise; export declare function isSamplingAvailable(): boolean | null; /** Reset probe cache — exposed for tests. */ export declare function resetSamplingProbe(): void; export interface SamplingMessage { role: "user" | "assistant"; content: { type: "text"; text: string; } | { type: "image"; data: string; mimeType: string; }; } export interface SamplingOptions { systemPrompt?: string; maxTokens?: number; temperature?: number; timeoutMs?: number; retries?: number; /** Model hints forwarded to the client. */ modelHints?: string[]; } export interface SamplingResult { text: string; model: string; stopReason?: string; } /** * Request a completion from the host LLM via MCP sampling. * * Throws if the client does not support sampling or the user rejects it. * Callers should catch and degrade gracefully. */ export declare function requestCompletion(messages: SamplingMessage[], opts?: SamplingOptions): Promise; /** * Request a completion and parse the response as JSON. * * Looks for a ```json fenced block first, then falls back to parsing the * entire text. Useful for structured outputs like screen selection or * metadata copy. */ export declare function requestJson(messages: SamplingMessage[], opts?: SamplingOptions): Promise; /** * Request a completion and extract HTML from the response. * * Looks for a ```html fenced block first, then falls back to treating the * entire response as HTML if it starts with `; //# sourceMappingURL=sampling.d.ts.map