A Single Natural-Language Command Drives Map Search, File I/O, and Browser Automation via Three MCP Servers
Mixing cloud and local MCP servers in one agent run is still under-documented. This walkthrough gives a concrete, copy-pasteable pattern for combining hosted APIs with local browser and filesystem tools, plus the exact error fixes that trip up first-timers — especially return-format mismatches and Chrome debug-port setup.
The setup uses DeepSeek-V4-Pro as the reasoning model and LangChain’s MultiServerMCPClient to bridge two transport modes: SSE for Amap’s hosted map service and stdio for local filesystem and Chrome debugging tools. A single natural-language query triggers a multi-turn loop where the model decides which tool to call, feeds results back into context, and stops when no further tool calls are needed. The full run — POI search, image retrieval, tab creation, and page-title rewriting — completes without hand-coded orchestration.
All code is provided as a single runnable TypeScript file. The author includes fixes for five common failure modes: misconfiguring the cloud MCP as a local process, using the wrong client variable name, mismatched tool-return formats, missing Chrome debug-port startup, and top-level await errors in Node.js. A finally block guarantees MCP connections close even on exceptions, addressing a frequent resource-leak pain point in agent scripts.
Most MCP tutorials show a single server; the real integration challenge — and where bugs surface — is mixing cloud SSE and local stdio servers in one agent. This code surfaces exactly those pain points.
The return-format normalization block is small but critical. Without it, different MCP servers’ JSON shapes cause silent undefined errors that are hard to trace in a multi-turn loop.
Using a finally block for resource cleanup is standard practice, yet many agent demos omit it. The explicit close() call here prevents port exhaustion and zombie Chrome processes that accumulate during development.