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

Method callTool

src/mcp/manager.ts:229–244  ·  view source on GitHub ↗

Route an `mcp__ __ ` call to the right connection.

(toolName: string, args: Record<string, unknown>)

Source from the content-addressed store, hash-verified

227
228 /** Route an `mcp__<server>__<tool>` call to the right connection. */
229 async callTool(toolName: string, args: Record<string, unknown>): Promise<{ text: string; isError?: boolean }> {
230 const match = /^mcp__([^_]+)__(.+)$/.exec(toolName)
231 if (!match) {
232 return { text: `Invalid MCP tool name: ${toolName}`, isError: true }
233 }
234 const [, server, originalName] = match
235 const connection = this.connections.get(server)
236 if (!connection) {
237 return { text: `MCP server "${server}" is not connected.`, isError: true }
238 }
239 try {
240 return await callMcpTool(connection, originalName, args)
241 } catch (error) {
242 return { text: `MCP tool ${toolName} failed: ${(error as Error).message}`, isError: true }
243 }
244 }
245
246 /** True if `toolName` is an MCP tool managed by this manager. */
247 hasTool(toolName: string): boolean {

Callers 2

executeToolFunction · 0.80
callMcpToolFunction · 0.80

Calls 1

callMcpToolFunction · 0.85

Tested by

no test coverage detected