UNPKG

@copilotkit/runtime

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

57 lines (56 loc) 2.18 kB
import "reflect-metadata"; import { Action, Parameter } from "@copilotkit/shared"; //#region src/lib/runtime/mcp-tools-utils.d.ts /** * Represents a tool provided by an MCP server. */ interface MCPTool { description?: string; /** Schema defining parameters, mirroring the MCP structure. */ schema?: { parameters?: { properties?: Record<string, any>; required?: string[]; jsonSchema?: Record<string, any>; }; }; /** The function to call to execute the tool on the MCP server. */ execute(params: any): Promise<any>; } /** * Defines the contract for *any* MCP client implementation the user might provide. */ interface MCPClient { /** A method that returns a map of tool names to MCPTool objects available from the connected MCP server. */ tools(): Promise<Record<string, MCPTool>>; /** An optional method for cleanup if the underlying client requires explicit disconnection. */ close?(): Promise<void>; } /** * Configuration for connecting to an MCP endpoint. */ interface MCPEndpointConfig { endpoint: string; apiKey?: string; } /** * Extracts CopilotKit-compatible parameters from an MCP tool schema. * @param toolOrSchema The schema object from an MCPTool or the full MCPTool object. * @returns An array of Parameter objects. */ declare function extractParametersFromSchema(toolOrSchema?: MCPTool | MCPTool["schema"]): Parameter[]; /** * Converts a map of MCPTools into an array of CopilotKit Actions. * @param mcpTools A record mapping tool names to MCPTool objects. * @param mcpEndpoint The endpoint URL from which these tools were fetched. * @returns An array of Action<any> objects. */ declare function convertMCPToolsToActions(mcpTools: Record<string, MCPTool>, mcpEndpoint: string): Action<any>[]; /** * Generate better instructions for using MCP tools * This is used to enhance the system prompt with tool documentation */ declare function generateMcpToolInstructions(toolsMap: Record<string, MCPTool>): string; //#endregion export { MCPClient, MCPEndpointConfig, MCPTool, convertMCPToolsToActions, extractParametersFromSchema, generateMcpToolInstructions }; //# sourceMappingURL=mcp-tools-utils.d.mts.map