MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / executeTool

Function executeTool

src/tools/index.ts:93–113  ·  view source on GitHub ↗
(
	toolName: string,
	args: Record<string, unknown>,
	context: ToolContext,
	mcp?: McpManager,
)

Source from the content-addressed store, hash-verified

91}
92
93export async function executeTool(
94 toolName: string,
95 args: Record<string, unknown>,
96 context: ToolContext,
97 mcp?: McpManager,
98): Promise<ToolResult> {
99 // MCP tools are namespaced as mcp__<server>__<tool> and routed to the manager.
100 if (mcp && mcp.hasTool(toolName)) {
101 const result = await mcp.callTool(toolName, args)
102 return { text: result.text, isError: result.isError }
103 }
104 const executor = executors[toolName]
105 if (!executor) {
106 return { text: `Tool "${toolName}" is not available in OrbCode CLI.`, isError: true }
107 }
108 try {
109 return await executor(args, context)
110 } catch (error) {
111 return { text: `Tool ${toolName} failed: ${(error as Error).message}`, isError: true }
112 }
113}
114
115/** Native tools plus any MCP tools from connected servers. */
116export function getActiveTools(mcp?: McpManager): OpenAI.Chat.ChatCompletionTool[] {

Callers 1

handleToolCallMethod · 0.85

Calls 2

hasToolMethod · 0.80
callToolMethod · 0.80

Tested by

no test coverage detected