import { CueAuth } from './auth'; import { McpContext } from './models'; /** * Minimal view of an MCP `tools/call` result — only the fields the response * handling reads. Declared locally instead of imported from the SDK on * purpose: the SDK ships its types only behind an `exports` map, which this * project's `moduleResolution: "node"` cannot follow, so the imported result * type collapses to its `unknown` index signature. */ type McpTextBlock = { type: 'text'; text: string; }; interface McpCallResult { content: Array; structuredContent?: Record | null; isError?: boolean; } export interface McpCallOptions { /** Abort signal forwarded to the underlying MCP request. */ signal?: AbortSignal; } /** Flatten any `HeadersInit` (Headers instance, tuples, or record) into a plain record. */ export declare function toHeaderRecord(init: HeadersInit | undefined): Record; /** Join every text content block into one string, mirroring the Python probe's `extract_payload`. */ export declare function extractText(content: McpCallResult['content']): string; /** * A data tool that catches an exception returns `{ error }` (see the backend's * `tool_error`) — a soft failure with no `id`, distinct from a real context. */ export declare function isToolError(payload: unknown): payload is { error: string; }; /** * Resolve a tool result to its payload the same way the Python probe does: * prefer the structured content the tool returned, otherwise fall back to the * text content (parsed as JSON when possible, raw string otherwise). */ export declare function extractPayload(result: McpCallResult): T; /** * Generic caller for the Cue Index MCP *data tools*. * * Speaks the FastMCP streamable-HTTP protocol against the gateway `/mcp` route * (the same protocol the `probe_mcp.py` reference uses via `fastmcp.Client`): * it performs the `initialize` handshake, invokes `tools/call`, and returns the * tool's Context result ({@link McpContext} — `{ id, text }`) proxied through * unchanged, with no endpoint-specific logic or re-templating. * * Type the call per endpoint via the generic parameters, e.g. * `callTool<{ input: string; space_id: string }>('search', { input, space_id })`. * New endpoints need no change to this class. */ export declare class CueMcp { private readonly _auth; private readonly _gatewayUrl; constructor(_auth: CueAuth, _gatewayUrl: string); callTool = Record, TResult = McpContext>(tool: string, params: TParams, options?: McpCallOptions): Promise; } export {};