Baidu Maps MCP server

Integrates with Baidu Maps API for location-based operations including geocoding, route planning, and location search within the Baidu Maps ecosystem.
Back to servers
Provider
Baidu Maps
Release date
Mar 20, 2025
Language
TypeScript
Package
Stats
3.8K downloads
266 stars

Baidu Maps MCP Server is a comprehensive mapping service that implements the Model Context Protocol (MCP), making it the first map service provider in China compatible with this protocol. It offers 10 standard API interfaces for location-based services including reverse geocoding, place search, and route planning.

Installation

Before getting started, you need to obtain an API key (AK) from the Baidu Maps Open Platform console. This server key allows you to access the Baidu Maps API capabilities.

Python Installation

Option 1: Using uv (Recommended)

If you have uv installed, you can use uvx to run the MCP server directly:

uvx mcp-server-baidu-maps

Option 2: Using pip

Install the package using pip:

pip install mcp-server-baidu-maps

After installation, run the server with:

python -m mcp_server_baidu_maps

TypeScript Installation

Prerequisites

Make sure you have Node.js installed. Verify your installation by running:

node -v

Configuration

Python Configuration

Add the following configuration to your MCP client (e.g., Claude.app), replacing <YOUR_API_KEY> with your actual Baidu Maps API key:

When using uvx:

{
  "mcpServers": {
    "baidu-maps": {
      "command": "uvx",
      "args": ["mcp-server-baidu-maps"],
      "env": {
        "BAIDU_MAPS_API_KEY": "<YOUR_API_KEY>"
      }
    }
  }
}

When using pip installation:

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

TypeScript Configuration

Open Claude for Desktop's settings, switch to the Developer tab, and click "Edit Config". Add the following configuration, replacing "xxx" with your actual API key:

For most systems:

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

For Windows systems:

"mcpServers": {
 "baidu-map": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@baidumap/mcp-server-baidu-map"
      ],
      "env": {
        "BAIDU_MAP_API_KEY": "xxx"
      },
    }
}

Restart your MCP client after saving the configuration to use the Baidu Maps MCP Server.

Available Services

The server provides the following 10 MCP-compatible API services:

1. Geographic Encoding (map_geocode)

Converts addresses into geographic coordinates.

  • Parameter: address (address information)
  • Output: location (latitude and longitude coordinates)

2. Reverse Geocoding (map_reverse_geocode)

Gets address details from coordinates.

  • Parameters: latitude, longitude
  • Output: formatted_address, uid, addressComponent, etc.

3. Place Search (map_search_places)

Searches for places within cities or circular areas.

  • Parameters:
    • query: Keywords (comma-separated)
    • tag: Type preferences (e.g., "food,hotel")
    • region: Administrative region
    • location: Center point coordinates (lat,lng)
    • radius: Search radius
  • Output: POI list with details

4. Place Details (map_place_details)

Retrieves detailed information about a specific place.

  • Parameter: uid (POI unique identifier)
  • Output: Detailed POI information

5. Route Matrix (map_directions_matrix)

Calculates distances and travel times for multiple routes.

  • Parameters:
    • origins: List of starting coordinates
    • destinations: List of ending coordinates
    • model: Route type (driving, walking, riding)
  • Output: Duration and distance for each route

6. Route Planning (map_directions)

Plans travel routes between locations.

  • Parameters:
    • origin: Starting location
    • destination: Ending location
    • model: Travel type (driving, walking, riding, transit)
  • Output: Detailed route information

7. Weather Query (map_weather)

Retrieves weather information for locations.

  • Parameters:
    • district_id: Administrative region code
    • location: Coordinates (lng,lat)
  • Output: Weather information

8. IP Location (map_ip_location)

Locates users based on IP address.

  • Optional parameter: ip (defaults to user's IP)
  • Output: Current city and city center coordinates

9. Real-time Traffic (map_road_traffic)

Queries real-time traffic congestion.

  • Parameters depend on model type (road, bound, polygon, around)
  • Output: Traffic information

10. POI Extraction (map_poi_extract)

Extracts POI information from text (requires advanced permissions).

  • Parameter: text_content (text containing location information)
  • Output: Related POI information

Qianfan AppBuilder Integration

You can also integrate the Baidu Maps MCP Server with Baidu's Qianfan AppBuilder platform:

  1. Create a new application on the Qianfan Platform
  2. Set the agent's thinking rounds to 6 and publish the application
  3. Use the sample Python code provided to call your published app and the MCP Server
import os
import asyncio
import appbuilder
from appbuilder.core.console.appbuilder_client.async_event_handler import (
    AsyncAppBuilderEventHandler,
)
from appbuilder.mcp_server.client import MCPClient

class MyEventHandler(AsyncAppBuilderEventHandler):
    # Event handler implementation
    # ...

async def main():
    appbuilder.logger.setLoglevel("DEBUG")
    app_id = ""  # Your published app ID
    appbuilder_client = appbuilder.AsyncAppBuilderClient(app_id)
    mcp_client = MCPClient()
    
    # Path to your local MCP Server file
    await mcp_client.connect_to_server("./<YOUR_FILE_PATH>/map.py")
    print(mcp_client.tools)
    await agent_run(
        appbuilder_client,
        mcp_client,
        'Drive from Beijing to Shanghai',  # Your query
    )
    await appbuilder_client.http_client.session.close()

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Technical Notes

  • Administrative region codes use the Baidu adcode mapping table
  • Coordinates use the GCJ-02 coordinate system
  • Chinese string parameters should conform to Baidu POI type standards
  • It's recommended to use SSE for lower latency and higher stability

Advanced Features

Some advanced capabilities require special permissions. If needed, please contact Baidu Maps for access.

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later