Baidu Map MCP Server for Geospatial APIs
Integrate Baidu Map MCP server to access open-source geospatial APIs, bridging LLMs and AI agents with real-world location data and services.
npx -y @baidu-maps/mcpOverview
Baidu Map MCP Server is an open-source, MCP-compliant Location-Based Service (LBS) server that exposes Baidu Maps geospatial capabilities through the Model Context Protocol (MCP). It is designed to bridge large language models (LLMs), AI agents and application backends with real-world location data — enabling geocoding, POI search, routing, traffic, weather and other map services via a standardized protocol.
By running the MCP server locally or in your environment, any MCP-aware agent or LLM can call the same set of geospatial tools as native functions. This makes it easy to add location understanding and action to conversational agents, logistics systems, travel assistants, and smart city applications while keeping integration consistent across platforms.
Features
- Full MCP protocol support for seamless integration with MCP-compliant LLMs and agents
- Wide range of LBS APIs: geocoding, reverse geocoding, POI search, place details, routing, traffic, weather, IP-to-location, etc.
- Batch route planning (matrix routing) for many-to-many route computations
- SSE (Server-Sent Events) optimized endpoint for low-latency, stable streaming results
- Official Python and TypeScript/Node.js packages and CLI entrypoints
- MIT-licensed, open-source codebase — extendable and self-hostable
- Enterprise-grade data and coverage powered by Baidu Maps
Installation / Configuration
Prerequisites:
- Python 3.10–3.12 (for Python server) or Node 16+ (for TypeScript/Node package)
- A server-side API Key (AK) from Baidu Maps Open Platform (enable MCP/SSE feature)
Get an API key at: https://lbsyun.baidu.com/apiconsole/key
Python installation:
Run the Python MCP server as a module:
Node / TypeScript installation:
# or using npx (no install):
Set environment variable and run via npx:
Configure an MCP client (example JSON) to run the server process:
Python example:
Node example:
Recommendation: enable MCP (SSE) support for best performance and reduced latency when streaming responses to agents.
Available Tools / Resources
The server exposes the following MCP tools (APIs):
| Tool name | Purpose |
|---|---|
| map_geocode | Convert address to geographic coordinates |
| map_reverse_geocode | Get address, region and POI info from coordinates |
| map_search_places | Search POIs globally by keyword, type, region or radius |
| map_place_details | Fetch detailed info for a POI by place_id |
| map_directions_matrix | Batch routing for many origins/destinations |
| map_directions | Plan route between two points (driving/walking/biking/transit) |
| map_weather | Real-time and forecast weather by region or coordinates |
| map_ip_location | Resolve city/coords from an IP address |
| map_road_traffic | Query real-time traffic on roads or regions |
| map_poi_extract* | Extract POI information from free text (requires permission) |
*Some advanced tools require additional permissions or whitelist from Baidu Maps.
Resources:
- GitHub: https://github.com/baidu-maps/mcp
- PyPI: mcp-server-baidu-maps
- NPM: @baidumap/mcp-server-baidu-map
- Baidu Maps Console: enable services and MCP/SSE feature via the Open Platform
Use Cases
- LLM-powered travel assistant: convert user queries like “Find vegetarian restaurants near Tiananmen” into POI searches, present results with structured location data, and plan walking routes.
- Logistics and dispatching: compute route matrices for fleets to estimate ETA and optimal assignments between multiple origins and destinations.
- Conversational customer support: agents can resolve addresses, show nearby service centers, and provide turn-by-turn suggestions based on user location.
- Smart city dashboards: combine traffic and weather endpoints to surface risk alerts and routing alternatives for city operations.
- Data enrichment pipelines: reverse-geocode coordinates in datasets or extract POI details for records before analysis.
Example flows:
- Agent asks for nearby coffee shops → call map_search_places → fetch map_place_details → present top results and provide a route via map_directions.
- Bulk delivery optimization → call map_directions_matrix for a set of depots and drop-offs → use matrix to compute assignment heuristics.
Authorization & Best Practices
- Use server-side API keys (AK). Keep keys secret; do not embed keys in public clients.
- Enable “MCP (SSE)” in the Baidu Maps console for the best streaming experience.
- Some endpoints (e.g., map_poi_extract) require advanced permissions or enterprise-level access — request via your Baidu Maps account if needed.
- Prefer SSE when connecting LLMs/agents to reduce latency and support streaming responses.
Additional Notes
- The project is MIT-licensed and intended for customization and self-hosting.
- For deployment at scale, deploy the MCP server behind secure processes and monitor usage quotas on your Baidu Maps account.
- See the GitHub repository for code examples, contribution guidelines and SDK details.