peppa/packages/mcp/scripts/call.ts
Асель f53b3447cf PEP: manage Peppa through Peppa; OpenSpec change for PEP-1
- Peppa registered as project PEP (.peppa/project.json, .mcp.json)
- goals #2/#3 and tasks PEP-1..PEP-5 created in Peppa
- openspec/changes/pep-1-web-platform: proposal, specs (web-auth,
  project-provisioning, web-workspace), design, tasks — awaiting PM approval
- packages/mcp/scripts/call.ts: call a peppa MCP tool from the shell

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:40:09 +05:00

16 lines
841 B
TypeScript

// Calls one peppa MCP tool from the current directory, as an agent would.
// Usage: tsx 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);