peppa/packages/mcp/scripts/call.ts
Асель 8dc82859c7 PEP-36 stage 1: run Peppa with Node 26 type stripping instead of tsx
- tsconfig: erasableSyntaxOnly + verbatimModuleSyntax; parameter properties
  rewritten (BugsinkError, GiteaError, GiteaClient, OAuthError, TelegramError,
  TelegramApi, MockGitea)
- bin wrappers (peppa, peppa-mcp, peppa-hook, peppa-bot, testkit mocks,
  peppa-dev): `node --import scripts/lib/require-node.mjs` (clear error on
  Node < 26, PEPPA_NODE overrides the binary); package scripts and tests on
  `node` / `node --test`; tsx removed
- install-launchd.sh pins PEPPA_NODE (checked absolute path) in the plists
- fix a race the faster hooks exposed: the prompt hook answered every pending
  question, including a PM question raised after Peppa itself pasted text
  into the terminal; sendToSession now logs `input_sent` and the hook only
  answers questions older than that input
- change pep-36-lightweight-stack: stage 1 done, hook start numbers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:51:22 +05:00

16 lines
842 B
TypeScript

// Calls one peppa MCP tool from the current directory, as an agent would.
// Usage: node packages/mcp/scripts/call.ts <tool> '<json args>'
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { fileURLToPath } from "node:url";
const [tool, json = "{}"] = process.argv.slice(2);
const client = new Client({ name: "peppa-call", version: "0" });
await client.connect(
new StdioClientTransport({ command: fileURLToPath(new URL("../bin/peppa-mcp", import.meta.url)), cwd: process.cwd(), env: process.env as Record<string, string> }),
);
const r = await client.callTool({ name: tool!, arguments: JSON.parse(json) });
console.log((r.content as Array<{ text: string }>)[0]?.text ?? "");
await client.close();
process.exit(r.isError ? 1 : 0);