One Agent, Four Servers: Wiring Maps, Browsers, and Files into a Single AI Loop
Multi-server MCP setups collapse what used to be separate integrations — maps, browsers, file I/O — into a single agent loop with no custom middleware. The `MultiServerMCPClient` pattern means adding a new capability is a config entry, not a new code path.
MCP acts as a universal tool bus for AI models, and this walkthrough demonstrates the multi-server architecture that makes it practical. A `MultiServerMCPClient` aggregates tools from four distinct servers — a remote HTTP-based Amap service for location data, a local stdio-based Chrome DevTools server for browser control, a custom arithmetic server, and a filesystem server — into one flat tool list. The agent loop then lets DeepSeek reason across them: it searches for hotels, fetches details, and writes results to disk without per-tool glue code.
The configuration shows two transport patterns side by side. Remote servers connect over HTTP with a single URL, while local servers launch as child processes over stdio, including npm packages invoked through `npx`. The agent itself is a straightforward while-loop that feeds tool results back into the conversation as `ToolMessage` objects, with a max-iterations guard against runaway calls.
A custom MCP server boils down to three pieces: a name, a Zod parameter schema that the model reads to understand inputs, and an async handler that returns a standard `{ content: [...] }` shape. The Chrome DevTools server exposes 29 browser-control tools — navigation, clicks, screenshots, console inspection — all callable through natural language.
The architecture treats tools as interchangeable resources: the model never knows or cares whether a tool came from a remote HTTP service or a local subprocess.
Stdio transport means MCP servers can be written in any language that reads stdin and writes stdout, not just JavaScript or Python.
The agent loop is deliberately simple — no planning module, no reflection step — yet chains multi-step tasks across unrelated services reliably because each tool result is just another message in the conversation.