BA

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.

Quick Install
npx -y @baidu-maps/mcp

Overview

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:

pip install mcp-server-baidu-maps

Run the Python MCP server as a module:

export BAIDU_MAPS_API_KEY="<YOUR_API_KEY>"
python -m mcp_server_baidu_maps

Node / TypeScript installation:

npm install @baidumap/mcp-server-baidu-map
# or using npx (no install):
npx @baidumap/mcp-server-baidu-map

Set environment variable and run via npx:

export BAIDU_MAP_API_KEY="<YOUR_API_KEY>"
npx @baidumap/mcp-server-baidu-map

Configure an MCP client (example JSON) to run the server process:

Python example:

{
  "mcpServers": {
    "baidu-maps": {
      "command": "python",
      "args": ["-m", "mcp_server_baidu_maps"],
      "env": {
        "BAIDU_MAPS_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}

Node example:

{
  "mcpServers": {
    "baidu-map": {
      "command": "npx",
      "args": ["-y", "@baidumap/mcp-server-baidu-map"],
      "env": {
        "BAIDU_MAP_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}

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 namePurpose
map_geocodeConvert address to geographic coordinates
map_reverse_geocodeGet address, region and POI info from coordinates
map_search_placesSearch POIs globally by keyword, type, region or radius
map_place_detailsFetch detailed info for a POI by place_id
map_directions_matrixBatch routing for many origins/destinations
map_directionsPlan route between two points (driving/walking/biking/transit)
map_weatherReal-time and forecast weather by region or coordinates
map_ip_locationResolve city/coords from an IP address
map_road_trafficQuery 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:

  1. Agent asks for nearby coffee shops → call map_search_places → fetch map_place_details → present top results and provide a route via map_directions.
  2. 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.