/** * CLI shim: call a relay MCP tool from bash. * Usage: * npx tsx call.ts read_messages '{"for":"pm"}' * npx tsx call.ts post_message '{"from":"pm","to":"dev-a","kind":"directive","body":"..."}' * npx tsx call.ts list_pending '{"for":"pm"}' */ import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"; const [, , toolName, argsJson] = process.argv; if (!toolName) { console.error("Usage: call.ts "); process.exit(1); } const args = argsJson ? JSON.parse(argsJson) : {}; const url = new URL("http://localhost:7331/sse"); const transport = new SSEClientTransport(url); const client = new Client({ name: "relay-cli", version: "0.1.0" }, { capabilities: {} }); await client.connect(transport); const result = await client.callTool({ name: toolName, arguments: args }); console.log(JSON.stringify(result)); await client.close();