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

Function mcpCall

e2e/scripts/cli.ts:428–453  ·  view source on GitHub ↗
(
  targetName: string,
  sub: string | undefined,
  rest: ReadonlyArray<string>,
)

Source from the content-addressed store, hash-verified

426};
427
428const mcpCall = async (
429 targetName: string,
430 sub: string | undefined,
431 rest: ReadonlyArray<string>,
432) => {
433 const { target } = await loadTarget(targetName);
434 const { Effect } = await import("effect");
435 const { FetchHttpClient } = await import("effect/unstable/http");
436 const { makeMcpSurface } = await import("../src/surfaces/mcp");
437 const surface = makeMcpSurface(target);
438
439 const result = await Effect.runPromise(
440 Effect.gen(function* () {
441 const who = yield* target.newIdentity();
442 const session = surface.session(who);
443 if (sub === "tools") return yield* session.listTools();
444 if (sub === "call") {
445 const [tool, json] = rest;
446 if (!tool) throw new Error("usage: mcp <target> call <tool> [json]");
447 return yield* session.call(tool, json ? (JSON.parse(json) as Record<string, unknown>) : {});
448 }
449 throw new Error("usage: mcp <target> tools | call <tool> [json]");
450 }).pipe(Effect.provide(FetchHttpClient.layer)),
451 );
452 console.log(JSON.stringify(result, null, 2));
453};
454
455const ledger = async (targetName: string, service = "workos") => {
456 const state = readState(targetName);

Callers 1

mainFunction · 0.85

Calls 4

loadTargetFunction · 0.85
makeMcpSurfaceFunction · 0.85
callMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected