Files
vscode-workbench/mcp-demo/mcp-smoke.mjs
T

22 lines
963 B
JavaScript

// Stdio handshake smoke test for arbitrary MCP stdio servers.
// Usage: node mcp-smoke.mjs <command> [args...]
// Lists tools and prints the first few names.
import { Client } from "file:///C:/Users/12914/.dsh/profiles/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js";
import { StdioClientTransport } from "file:///C:/Users/12914/.dsh/profiles/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js";
const [command, ...args] = process.argv.slice(2);
if (!command) {
console.error("usage: node mcp-smoke.mjs <command> [args...]");
process.exit(1);
}
const transport = new StdioClientTransport({ command, args, env: { ...process.env } });
const client = new Client({ name: "smoke", version: "0.0.1" });
await client.connect(transport);
const tools = await client.listTools();
console.log(JSON.stringify({ toolCount: tools.tools.length, sample: tools.tools.slice(0, 10).map((t) => t.name) }));
await client.close();
process.exit(0);