Baidu Map MCP Server is a comprehensive Location-Based Service solution that implements the Model Context Protocol (MCP), allowing seamless integration between large language models, AI agents, and geospatial services. It provides a rich set of mapping capabilities including geocoding, POI search, route planning, weather information, and more.
Install the Python SDK using pip:
pip install mcp-server-baidu-maps
Run the server directly:
python -m mcp_server_baidu_maps
Install the package using npm:
npm install @baidumap/mcp-server-baidu-map
Before using the server, you'll need to register and create a server-side API Key:
When using with an MCP client (such as Claude or Cursor), configure as follows:
{
"mcpServers": {
"baidu-maps": {
"command": "python",
"args": ["-m", "mcp_server_baidu_maps"],
"env": {
"BAIDU_MAPS_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
Configure in your MCP client:
{
"mcpServers": {
"baidu-map": {
"command": "npx",
"args": [
"-y",
"@baidumap/mcp-server-baidu-map"
],
"env": {
"BAIDU_MAP_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
For low-latency and stable access, it's recommended to use Server-Sent Events (SSE). Refer to the SSE Quickstart for detailed setup instructions.
Baidu Map MCP Server provides the following MCP-compliant APIs:
Tool Name | Description |
---|---|
map_geocode |
Convert addresses to geographic coordinates |
map_reverse_geocode |
Get address information from coordinates |
map_search_places |
Search for POIs by keyword, type, region, or radius |
map_place_details |
Get detailed information for a POI by its ID |
map_directions_matrix |
Calculate routes for multiple origins/destinations |
map_directions |
Plan routes between two points with various transit modes |
map_weather |
Query weather data by region or coordinates |
map_ip_location |
Determine location from IP address |
map_road_traffic |
Get real-time traffic conditions |
map_poi_extract * |
Extract POI information from text (requires special permission) |
*Note: Some advanced features require additional permissions.
Combine multiple tools to create a comprehensive travel assistant:
# Search for tourist attractions
places = map_search_places(query="tourist attractions", region="Beijing", page_size=5)
# Get directions between locations
route = map_directions(
origin="39.9042,116.4074", # Beijing city center
destination=places[0]["location"],
mode="transit"
)
# Check weather at the destination
weather = map_weather(location=places[0]["location"])
Calculate multiple routes simultaneously for delivery planning:
routes_matrix = map_directions_matrix(
origins=["39.9042,116.4074", "39.9975,116.3038"], # Multiple starting points
destinations=["40.0096,116.3168", "39.9837,116.3229"], # Multiple destinations
mode="driving"
)
Create context-aware navigation by combining traffic and weather data:
# Get current traffic conditions
traffic = map_road_traffic(road_name="Chang'an Avenue", city="Beijing")
# Check weather along route
weather = map_weather(location="Beijing")
# Calculate optimal route considering traffic
route = map_directions(
origin="39.9042,116.4074",
destination="40.0096,116.3168",
mode="driving"
)
For more detailed information and advanced usage, refer to these resources:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "baidu-map" '{"command":"npx","args":["-y","@baidumap/mcp-server-baidu-map"],"env":{"BAIDU_MAP_API_KEY":"<YOUR_API_KEY>"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"baidu-map": {
"command": "npx",
"args": [
"-y",
"@baidumap/mcp-server-baidu-map"
],
"env": {
"BAIDU_MAP_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"baidu-map": {
"command": "npx",
"args": [
"-y",
"@baidumap/mcp-server-baidu-map"
],
"env": {
"BAIDU_MAP_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect