// Multi Server Agent
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

async function connectToServer(command: string, args: string[]) {
  const client = new Client({ name: "agent", version: "1.0.0" });
  const transport = new StdioClientTransport({ command, args });
  await client.connect(transport);
  return client;
}

async function main() {
  const mathClient = await connectToServer("node", ["./math-server.js"]);
  const weatherClient = await connectToServer("node", ["./weather-server.js"]);

  const tools = [
    ...(await mathClient.listTools()).tools,
    ...(await weatherClient.listTools()).tools,
  ];

  console.log("Beschikbare tools:", tools.map((t) => t.name));
}

main().catch(console.error);
