import { ToolDefinition } from "./_chunks/index.mjs"; import { McpHost } from "./_chunks/mcp-answers.mjs"; /** What SDK v1 keeps of the HTTP request. */ export interface ToolkitRequestInfo { readonly headers: Readonly>; readonly url?: { readonly href: string; }; } /** The part of the SDK v1 request `extra` a handler reads: abort signal, progress and questions. */ export interface ToolkitExtra { readonly signal?: AbortSignal; /** Present on an HTTP transport. */ readonly requestInfo?: ToolkitRequestInfo; readonly _meta?: { readonly [key: string]: unknown; readonly progressToken?: string | number; }; readonly sendNotification?: (notification: { readonly method: "notifications/progress"; readonly params: { readonly progressToken: string | number; readonly progress: number; readonly total?: number; readonly message: string; }; }) => Promise; /** Both schemas are `never`, so SDK v1's method fits whatever Zod and schema types it carries. */ readonly sendRequest?: (request: { readonly method: "elicitation/create"; readonly params: { readonly mode: "form"; readonly message: string; readonly requestedSchema: never; }; }, resultSchema: never, options?: { readonly signal?: AbortSignal; }) => Promise; } /** The toolkit's `useMcpElicitation`, or anything that knows if the client fills forms. */ export type ToolkitElicitation = () => { readonly supports: (mode?: "form") => boolean; }; /** How `toToolkitTools` reaches the person behind the client. */ export interface ToolkitOptions { /** Pass `useMcpElicitation` to give `execute` an `ask`. It runs in every handler. */ readonly elicitation?: ToolkitElicitation; } /** What a handler answers. The toolkit runs SDK v1, so these types never name the v2 package. */ export interface ToolkitResult { [key: string]: unknown; content: Array<{ [key: string]: unknown; type: string; }>; isError?: boolean; } /** One toolkit tool. Schemas stay `unknown`, since pnpm gives the toolkit its own `zod` copy. */ export interface ToolkitTool { readonly name: string; readonly title?: string; readonly description?: string; readonly annotations?: { readonly title?: string; readonly readOnlyHint?: boolean; readonly destructiveHint?: boolean; readonly idempotentHint?: boolean; readonly openWorldHint?: boolean; }; readonly inputSchema: unknown; readonly outputSchema?: unknown; readonly _meta?: Record; readonly handler: (args: unknown, extra?: ToolkitExtra) => Promise; } /** * Turns tools into toolkit entries that list what `listTools` lists and answer via `callTool`. * * `host` is an {@link McpHost} with the call's `_meta` and a `Request` rebuilt from SDK v1's * `requestInfo`: the caller's URL and headers, but no body and always `GET`. * * Progress and questions need the toolkit's sessions: its stateless default answers in plain JSON. * `useMcpElicitation` also needs Nitro's `asyncContext`, since it finds the server in the request. * * @param info - Server info; `name` is the word in the message for an unknown tool. * @param tools - Tools to serve. * @param options - Where `ask` comes from; without it there is none. * @returns {ToolkitTool[]} Tool definitions in the order given. * @throws {ToolDefinitionError} When two tools share a name. */ export declare function toToolkitTools(info: { readonly name: string; }, tools: readonly ToolDefinition[], options?: ToolkitOptions): ToolkitTool[]; export type { McpHost };