/** * Shared utilities for MCP sampling * * Common functions used by both the provider and custom handler implementations. */ import type { CreateMessageRequest } from "@modelcontextprotocol/sdk/types.js"; import type { ModelMessage } from "ai"; /** * AI SDK compatible message format */ export type AISDKMessage = ModelMessage; /** * Convert AI SDK finish reason to MCP stop reason * * @param finishReason - AI SDK finish reason * @returns MCP stop reason */ export declare function convertAISDKFinishReasonToMCP(finishReason?: string): "endTurn" | "stopSequence" | "maxTokens"; /** * Convert MCP tools to AI SDK tools format * * This is used in client sampling to convert tools from the MCP server's * createMessage request into AI SDK tool format that can be passed to generateText. * * Note: This function does NOT provide execute implementations because in client sampling, * tool execution happens on the MCP server side, not the client side. The client just * returns tool-call content blocks which the server will then execute. * * @param mcpTools - Array of MCP Tool definitions from server's createMessage request * @param helpers - AI SDK helper functions (tool and jsonSchema from "ai" package) * @returns AI SDK tools object or undefined if no tools * * @example * ```typescript * import { tool, jsonSchema, generateText } from "ai"; * import { convertMCPToolsToAISDK } from "@mcpc/mcp-sampling-ai-provider"; * * const aiTools = convertMCPToolsToAISDK(params.tools, { tool, jsonSchema }); * const result = await generateText({ * model: modelId, * messages: params.messages, * tools: aiTools, // Tools without execute - they're just for the LLM to know about * }); * ``` */ export declare function convertMCPToolsToAISDK(mcpTools?: CreateMessageRequest["params"]["tools"], helpers?: { tool: (...args: any[]) => any; jsonSchema: (...args: any[]) => any; }): Record | undefined; //# sourceMappingURL=utils.d.ts.map