MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / buildInvokeToolCode

Function buildInvokeToolCode

apps/cli/src/tooling.ts:424–435  ·  view source on GitHub ↗
(toolPath: string, args: Record<string, unknown>)

Source from the content-addressed store, hash-verified

422 `return await tools.describe.tool({ path: ${JSON.stringify(toolPath)} });`;
423
424export const buildInvokeToolCode = (toolPath: string, args: Record<string, unknown>): string => {
425 const access = buildToolAccessExpression(toolPath);
426 return [
427 `const __toolPath = ${JSON.stringify(toolPath)};`,
428 `const __args = ${JSON.stringify(args, null, 2)};`,
429 `const __target = tools${access};`,
430 `if (typeof __target !== "function") {`,
431 " throw new Error(`Tool not found: ${__toolPath}`);",
432 "}",
433 "return await __target(__args);",
434 ].join("\n");
435};

Callers 2

main.tsFile · 0.90
tools-cli.test.tsFile · 0.90

Calls 1

Tested by

no test coverage detected