// Smoke test: spawns peppa-mcp in the given project dir and calls a few tools. // Usage: node packages/mcp/scripts/smoke.ts import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import { fileURLToPath } from "node:url"; const [dir = process.cwd(), task = "1"] = process.argv.slice(2); const bin = fileURLToPath(new URL("../bin/peppa-mcp", import.meta.url)); const client = new Client({ name: "peppa-smoke", version: "0" }); await client.connect(new StdioClientTransport({ command: bin, cwd: dir, env: process.env as Record })); const { tools } = await client.listTools(); console.log("tools:", tools.map((t) => t.name).join(", ")); for (const [name, args] of [ ["list_goals", {}], ["list_tasks", {}], ["get_task", { task }], ] as const) { const r = await client.callTool({ name, arguments: args }); console.log(`\n── ${name}${r.isError ? " (error)" : ""}\n${(r.content as Array<{ text: string }>)[0]!.text}`); } await client.close();