UNPKG

@agenite/mcp

Version:
110 lines (106 loc) 2.43 kB
import { Tool } from '@agenite/tool'; /** * Configuration for MCP server */ type MCPServerConfig = MCPSSEConfig | MCPStdioConfig; interface MCPSSEConfig { /** * URL for SSE transport */ url: string; } interface MCPStdioConfig { /** * Command to execute the MCP server */ command: string; /** * Arguments for the command */ args?: string[]; /** * Environment variables for the command */ env?: Record<string, string>; /** * Working directory for the command */ cwd?: string; } /** * Definition of a tool provided by MCP server */ interface MCPToolDefinition { /** * Name of the tool */ name: string; /** * Description of the tool */ description?: string; /** * JSON schema for the tool input */ inputSchema: Record<string, unknown>; } /** * Result of a tool call from MCP server */ interface MCPToolCallResult { /** * Whether the call resulted in an error */ isError: boolean; /** * Data returned from the tool call */ data: string; } declare class MCPClient { private config; private clients; private clientConfig; constructor(config: { mcpServers: { [name: string]: MCPServerConfig; }; name?: string; version?: string; }); /** * Connect to a specific MCP server * @private */ private connect; /** * Connect to all configured MCP servers * @private */ private connectAll; /** * Get available tools from a specific MCP server */ getTools(serverName: string): Promise<Tool[]>; /** * Get available tools from all connected MCP servers as a flat array * This is the preferred method for integration with Agent */ getAllTools(): Promise<Tool[]>; /** * Get available tools from all connected MCP servers organized by server */ getAllToolsByServer(): Promise<{ [serverName: string]: Tool[]; }>; /** * Call a tool on a specific MCP server * @private This is internally used by the Tool execute functions */ private callTool; /** * Get configured server names */ getServerNames(): string[]; } export { MCPClient, type MCPSSEConfig, type MCPServerConfig, type MCPStdioConfig, type MCPToolCallResult, type MCPToolDefinition };