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

Function mcpCall

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

Source from the content-addressed store, hash-verified

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