import { type OAuthClientProvider } from '@ai-sdk/mcp'; import type { Tool } from 'ai'; /** * Supported transport types for MCP clients. */ export type McpTransportType = 'stdio' | 'sse' | 'http'; /** * Shared configuration for all MCP server transports. */ interface McpClientBaseConfig { /** Display name for the MCP server */ name: string; /** Optional prefix applied to every imported tool name */ toolPrefix?: string; /** Optional MCP client name override */ clientName?: string; /** Optional MCP client version override */ clientVersion?: string; /** Auth method for the MCP connection. */ authMethod?: 'api-key' | 'oauth2' | 'bearer'; /** Custom auth headers. */ authHeaders?: Record; /** API version for the MCP server. */ apiVersion?: string; } /** * Configuration for stdio MCP servers. */ export interface McpStdioClientConfig extends McpClientBaseConfig { /** Transport type (defaults to "stdio" when omitted) */ transport?: 'stdio'; /** Command to spawn the MCP server process */ command: string; /** Arguments to pass to the command */ args?: string[]; /** Environment variables for the process */ env?: Record; /** Working directory for spawned process */ cwd?: string; } /** * Configuration for remote MCP servers (SSE / Streamable HTTP). */ export interface McpRemoteClientConfig extends McpClientBaseConfig { /** Transport type */ transport: 'sse' | 'http'; /** MCP endpoint URL */ url: string; /** Optional static headers */ headers?: Record; /** Optional OAuth provider for MCP auth flow */ authProvider?: OAuthClientProvider; /** Optional bearer token injected into Authorization header */ accessToken?: string; /** Optional env var name containing bearer token */ accessTokenEnvVar?: string; } /** * Configuration for connecting to an MCP server. */ export type McpClientConfig = McpStdioClientConfig | McpRemoteClientConfig; /** * Result of creating an MCP client with tools. */ export interface McpClientResult { /** AI SDK tools from the MCP server */ tools: Record>; /** Cleanup function to close the connection */ cleanup: () => Promise; /** Tool names grouped by source server name */ serverToolNames: Record; } /** * Options for combining multiple MCP toolsets. */ export interface CreateMcpToolsetsOptions { /** Strategy used when two MCP servers expose the same tool name */ onNameCollision?: 'overwrite' | 'error'; } /** * Create AI SDK tools from an MCP server. * * This adapter allows ContractSpec agents to consume tools * from external MCP servers (e.g., filesystem, database, etc.). * * @param config - MCP server configuration * @returns Tools and cleanup function * * @example * ```typescript * const { tools, cleanup } = await mcpServerToTools({ * name: 'filesystem', * command: 'npx', * args: ['-y', '@modelcontextprotocol/server-filesystem', '/path'], * }); * * // Use tools in agent... * * await cleanup(); * ``` */ export declare function mcpServerToTools(config: McpClientConfig): Promise; /** * Create multiple MCP tool sets from configurations. * * @param configs - Array of MCP server configurations * @param options - Merge options for conflicts * @returns Combined tools and cleanup function */ export declare function createMcpToolsets(configs: McpClientConfig[], options?: CreateMcpToolsetsOptions): Promise; export {};