import { McpBridge } from '@svantic/sdk';
// 1. Create the bridge with a label (used in logs and errors).
const bridge = new McpBridge('filesystem');
// 2. Spawn the MCP server and handshake.
await bridge.connect({
command: 'npx',
args: ['@modelcontextprotocol/server-filesystem', '/data'],
});
// 3. Introspect what's available.
const tools = await bridge.list_tools();
console.log(tools.map((t) => t.name));
// 4. Call a tool directly. Arguments match the MCP server's JSON Schema.
const result = await bridge.call_tool('read_file', {
path: '/data/notes/today.md',
});
// 5. Always close — otherwise the child process leaks until GC.
await bridge.close();