UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

65 lines 2.18 kB
import type { Tool } from "@mcp-use/modelcontextprotocol-sdk/types.js"; import type { MCPClient } from "../../client.js"; export interface ExecutionResult { result: unknown; logs: string[]; error: string | null; execution_time: number; } export interface ToolSearchResult { name: string; server: string; description?: string; input_schema?: Tool["inputSchema"]; } export interface ToolSearchMeta { total_tools: number; namespaces: string[]; result_count: number; } export interface ToolSearchResponse { meta: ToolSearchMeta; results: ToolSearchResult[]; } export type SearchToolsFunction = (query?: string, detailLevel?: "names" | "descriptions" | "full") => Promise<ToolSearchResponse>; export interface ToolNamespaceInfo { serverName: string; tools: Tool[]; session: any; } /** * Abstract base class for code executors. * Provides shared functionality for connecting to MCP servers and building tool contexts. */ export declare abstract class BaseCodeExecutor { protected client: MCPClient; protected _connecting: boolean; constructor(client: MCPClient); /** * Execute code with access to MCP tools. * @param code - The code to execute * @param timeout - Execution timeout in milliseconds */ abstract execute(code: string, timeout?: number): Promise<ExecutionResult>; /** * Clean up resources used by the executor. * Should be called when the executor is no longer needed. */ abstract cleanup(): Promise<void>; /** * Ensure all configured MCP servers are connected before execution. * Prevents race conditions with a connection lock. */ protected ensureServersConnected(): Promise<void>; /** * Get tool namespace information from all active MCP sessions. * Filters out the internal code_mode server. */ protected getToolNamespaces(): ToolNamespaceInfo[]; /** * Create a search function for discovering available MCP tools. * Used by code execution environments to find tools at runtime. */ createSearchToolsFunction(): SearchToolsFunction; } //# sourceMappingURL=base.d.ts.map