/** * MCP (Model Context Protocol) Integration * * Provides client and server implementations for MCP, * enabling tool discovery and invocation across processes. * * @example Using MCP Client * ```typescript * import { MCPClient } from 'praisonai'; * * const client = new MCPClient({ serverUrl: 'http://localhost:3000' }); * await client.connect(); * * const tools = await client.listTools(); * const result = await client.callTool('search', { query: 'AI' }); * ``` * * @example Using MCP with Agent * ```typescript * import { Agent, MCPClient } from 'praisonai'; * * const mcp = new MCPClient({ serverUrl: 'http://localhost:3000' }); * await mcp.connect(); * * const agent = new Agent({ * instructions: 'Use available tools', * tools: await mcp.getToolsAsAISDK() * }); * ``` */ /** * MCP Transport types */ export type MCPTransportType = 'stdio' | 'http' | 'websocket' | 'sse'; /** * MCP Tool definition */ export interface MCPTool { name: string; description?: string; inputSchema?: Record; annotations?: Record; } /** * MCP Resource definition */ export interface MCPResource { uri: string; name: string; description?: string; mimeType?: string; } /** * MCP Prompt definition */ export interface MCPPrompt { name: string; description?: string; arguments?: Array<{ name: string; description?: string; required?: boolean; }>; } /** * MCP Client configuration */ export interface MCPClientConfig { /** Server URL or command for stdio */ serverUrl?: string; /** Transport type (default: 'http') */ transport?: MCPTransportType; /** Command for stdio transport */ command?: string; /** Arguments for stdio transport */ args?: string[]; /** Environment variables */ env?: Record; /** Connection timeout in ms */ timeout?: number; /** Enable verbose logging */ verbose?: boolean; /** API key for authentication */ apiKey?: string; } /** * MCP Tool call result */ export interface MCPToolResult { content: Array<{ type: 'text' | 'image' | 'resource'; text?: string; mimeType?: string; data?: string; uri?: string; }>; isError?: boolean; } /** * MCP Session state */ export interface MCPSession { id: string; connected: boolean; serverInfo?: { name: string; version: string; capabilities?: Record; }; tools: MCPTool[]; resources: MCPResource[]; prompts: MCPPrompt[]; } /** * MCP Client - Connect to MCP servers */ export declare class MCPClient { readonly id: string; private config; private session; private transport; constructor(config?: MCPClientConfig); /** * Connect to the MCP server */ connect(): Promise; /** * Connect via stdio (spawn process) */ private connectStdio; /** * Connect via HTTP */ private connectHttp; /** * Connect via WebSocket */ private connectWebSocket; /** * Initialize MCP session */ private initialize; /** * Send RPC request */ private rpc; /** * Refresh tools list from server */ refreshTools(): Promise; /** * List available tools */ listTools(): Promise; /** * Call a tool */ callTool(name: string, args?: Record): Promise; /** * Get tools formatted for AI SDK */ getToolsAsAISDK(): Promise; /** * Disconnect from server */ disconnect(): Promise; /** * Get session info */ getSession(): MCPSession; /** * Check if connected */ isConnected(): boolean; } /** * Factory function to create MCPClient */ export declare function createMCPClient(config?: MCPClientConfig): MCPClient; /** * Connect to an MCP server and return tools */ export declare function getMCPTools(config: MCPClientConfig): Promise<{ client: MCPClient; tools: any[]; }>; export default MCPClient; export { MCPServer, createMCPServer, type MCPServerTool, type MCPResource as MCPServerResource, type MCPPrompt as MCPServerPrompt, type MCPServerConfig } from './server'; export { MCPSession as MCPSessionManager, createMCPSession, SessionManager as MCPClientSessionManager, createSessionManager, type MCPSessionConfig, type SessionState, type SessionContext, type SessionEvent } from './session'; export { MCPSecurity, createMCPSecurity, createApiKeyPolicy, createRateLimitPolicy, type SecurityPolicy, type SecurityResult, type SecurityContext, type RateLimitConfig, type AuthMethod, type SecurityPolicyType } from './security';