( targetName: string, sub: string | undefined, rest: ReadonlyArray<string>, )
| 426 | }; |
| 427 | |
| 428 | const 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 | |
| 455 | const ledger = async (targetName: string, service = "workos") => { |
| 456 | const state = readState(targetName); |
no test coverage detected