const agent = new Agent({
name: "dev",
model: openai("gpt-5.4"),
tools: { ...fsTools, bash },
mcpServers: {
github: {
type: "stdio",
command: "npx",
args: ["-y", "@modelcontextprotocol/server-github"],
env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN },
},
weather: {
type: "http",
url: "https://weather-mcp.example.com/mcp",
headers: { Authorization: "Bearer ..." },
},
},
});
// MCP connections are established lazily on first run()
for await (const event of agent.run([], "What PRs are open?")) {
// ...
}
// Clean up MCP connections when done
await agent.close();