/** * MCP (Model Context Protocol) - AI SDK Wrapper * * Provides MCP client utilities for connecting to MCP servers and using their tools. */ export interface MCPConfig { /** Transport configuration */ transport: MCPTransportConfig; /** Client name */ name?: string; /** Client version */ version?: string; /** Callback for uncaught errors */ onUncaughtError?: (error: unknown) => void; } export type MCPTransportConfig = { type: 'stdio'; command: string; args?: string[]; env?: Record; } | { type: 'sse'; url: string; headers?: Record; authProvider?: OAuthClientProvider; } | { type: 'http'; url: string; headers?: Record; authProvider?: OAuthClientProvider; } | { type: 'websocket'; url: string; headers?: Record; }; /** * OAuth client provider for MCP authentication. */ export interface OAuthClientProvider { /** Get the current access token */ getAccessToken(): Promise; /** Refresh the access token */ refreshToken?(): Promise; /** Handle OAuth redirect */ handleRedirect?(url: string): Promise; } export interface MCPClient { /** Get tools from the MCP server */ tools(): Promise>; /** List available resources */ listResources(): Promise; /** Read a resource */ readResource(uri: string): Promise; /** List available prompts */ listPrompts(): Promise; /** Get a prompt */ getPrompt(name: string, args?: Record): Promise; /** Close the connection */ close(): Promise; } export interface MCPTool { /** Tool name */ name: string; /** Tool description */ description?: string; /** Input schema */ inputSchema: any; /** Execute the tool */ execute: (args: any) => Promise; } export interface MCPResource { /** Resource URI */ uri: string; /** Resource name */ name: string; /** Resource description */ description?: string; /** MIME type */ mimeType?: string; } export interface MCPResourceContent { /** Content URI */ uri: string; /** Content MIME type */ mimeType?: string; /** Text content */ text?: string; /** Binary content (base64) */ blob?: string; } export interface MCPPrompt { /** Prompt name */ name: string; /** Prompt description */ description?: string; /** Arguments */ arguments?: Array<{ name: string; description?: string; required?: boolean; }>; } export interface MCPPromptResult { /** Prompt description */ description?: string; /** Messages */ messages: Array<{ role: 'user' | 'assistant'; content: { type: 'text'; text: string; } | { type: 'image'; data: string; mimeType: string; }; }>; } /** * Create an MCP client. * * @example Stdio transport (local server) * ```typescript * const client = await createMCP({ * transport: { * type: 'stdio', * command: 'npx', * args: ['-y', '@modelcontextprotocol/server-filesystem', '/path/to/dir'] * } * }); * * const tools = await client.tools(); * ``` * * @example SSE transport (remote server) * ```typescript * const client = await createMCP({ * transport: { * type: 'sse', * url: 'https://mcp-server.example.com/sse' * } * }); * ``` */ export declare function createMCP(config: MCPConfig): Promise; /** * Get or create a pooled MCP client. * * @example * ```typescript * const client = await getMCPClient('filesystem', { * transport: { type: 'stdio', command: 'npx', args: ['-y', '@mcp/server-fs'] } * }); * ``` */ export declare function getMCPClient(key: string, config: MCPConfig): Promise; /** * Close and remove a pooled MCP client. */ export declare function closeMCPClient(key: string): Promise; /** * Close all pooled MCP clients. */ export declare function closeAllMCPClients(): Promise; /** * Convert MCP tools to AI SDK tool format. * * @example * ```typescript * const client = await createMCP({ ... }); * const mcpTools = await client.tools(); * const aiTools = mcpToolsToAITools(mcpTools); * * const result = await generateText({ * model: 'gpt-4o', * prompt: 'List files in the current directory', * tools: aiTools * }); * ``` */ export declare function mcpToolsToAITools(mcpTools: Record): Record;