import { McpClient } from "@modelcontextprotocol/sdk/client/client.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const serverCmd = "node";
const serverArgs = ["mcp-server/dist/index.js"]; // adjust if needed
const toolName = process.argv[2]; // e.g., "calculate"
const argsJson = process.argv[3] || "{}"; // e.g., '{"expression":"2+2*5"}'
if (!toolName) {
console.error("Usage: node scripts/mcp-smoketest.mjs <toolName> '<jsonArgs>'");
process.exit(2);
}
const transport = new StdioClientTransport({ command: serverCmd, args: serverArgs });
const client = new McpClient({ name: "smoke", version: "0.0.1" }, transport);
await client.connect();
const args = JSON.parse(argsJson);
const result = await client.callTool({ name: toolName, arguments: args });
console.log(JSON.stringify(result, null, 2));
await client.close();