百度

百度地图API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。百度地图提供的MCP Server包含10个符合MCP协议标准的API接口,涵盖逆地理编码、地点检索、路线规划等服务。依赖MCP Python SDK和MCP Typescript SDK开发,任意支持MCP协议的智能体助手都可以快速接入。

location-services

1.0k 查看 · 2026-07-07 更新

简介

百度地图API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。百度地图提供的MCP Server包含10个符合MCP协议标准的API接口,涵盖逆地理编码、地点检索、路线规划等服务。依赖MCP Python SDK和MCP Typescript SDK开发,任意支持MCP协议的智能体助手都可以快速接入。

简介

百度地图API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。百度地图提供的MCP Server包含10个符合MCP协议标准的API接口,涵盖逆地理编码、地点检索、路线规划等服务。依赖MCP Python SDK和MCP Typescript SDK开发,任意支持MCP协议的智能体助手都可以快速接入。

Baidu Map MCP Server

Overview

The Baidu Map API is now fully compatible with the MCP protocol, making it the first map service provider in China to support the MCP protocol.

Baidu Map's MCP Server includes 10 APIs that comply with MCP protocol standards, covering reverse geocoding, place search, route planning, and more. Developed using the MCP Python SDK and MCP Typescript SDK, any intelligent agent assistant that supports the MCP protocol (such as Claude, Cursor, and Qianfan AppBuilder, etc.) can quickly integrate.

It is strongly recommended to access the Baidu Map MCP Server via SSE for lower latency and higher stability. Don't forget to enable the MCP(SSE) service for your AK in the console.

Tools

  1. Geocoding map_geocode

    • Description: Converts an address into corresponding location coordinates. The more complete and accurate the address structure, the higher the precision of the parsed coordinates.
    • Parameters: address Address information
    • Output: location Latitude and longitude coordinates
  2. Reverse Geocoding map_reverse_geocode

    • Description: Retrieves the address description, administrative division, road, and related POI information based on latitude and longitude coordinates.
    • Parameters:
      • latitude Latitude coordinate
      • longitude Longitude coordinate
    • Output: Semantic address information such as formatted_address, uid, addressComponent
  3. Place Search map_search_places

    • Description: Supports searching for place information within a city (down to the city level) or searching for nearby places within a circular area.
    • Parameters:
      • query Search keywords, which can be names or types. Multiple keywords should be separated by English commas, e.g., query=Tiananmen,food
      • tag Type preference for the search, formatted as tag=food or tag=food,hotel
      • region Administrative division for the search, formatted as region=cityname or region=citycode
      • location Latitude and longitude coordinates of the center point for a circular search, formatted as location=lat,lng
      • radius Radius of the circular search
    • Output: List of POIs, including name, location, address, etc.
  4. Place Details Search map_place_details

    • Description: Retrieves detailed information about a POI based on its UID, such as ratings, business hours, etc. (Different types of POIs correspond to different categories of detail data)
    • Parameters: uid Unique identifier of the POI
    • Output: POI details, including name, location, address, brand, price, etc.
  5. Batch Route Calculation map_directions_matrix

    • Description: Calculates the distance and travel time for route planning based on start and end coordinates. Supports driving, cycling, and walking. For walking, the distance between any start and end points must not exceed 200KM. For driving, batch route calculation can compute up to 100 routes at once, with the product of the number of start and end points not exceeding 100.
    • Parameters:
      • origins List of starting latitude and longitude coordinates, formatted as origins=lat,lng. Multiple origins are separated by |
      • destinations List of destination latitude and longitude coordinates, formatted as destinations=lat,lng. Multiple destinations are separated by |
      • model Route calculation type, selectable values include driving, walking, riding, default uses driving
    • Output: Travel time and distance for each route, including distance, duration, etc.
  6. Route Planning map_directions

    • Description: Plans travel routes and duration based on the start and end position names or latitude and longitude coordinates. Can specify travel modes such as driving, walking, cycling, or public transit.
    • Parameters:
      • origin Start position name or latitude and longitude, formatted as origin=lat,lng
      • destination End position name or latitude and longitude, formatted as destination=lat,lng
      • model Travel mode, selectable values include driving, walking, riding, transit, default uses driving
    • Output: Route details, including steps, distance, duration, etc.
  7. Weather Query map_weather

    • Description: Queries real-time weather information and a 5-day weather forecast through administrative divisions or latitude and longitude coordinates.
    • Parameters:
      • district_id Administrative division code
      • location Latitude and longitude coordinates, formatted as location=lng, lat
    • Output: Weather information, including temperature, weather, wind, etc.
  8. IP Location map_ip_location- Description: Obtain specific location information and city name through the given IP, which can be used for IP or user's current location positioning. Optional parameter ip, if empty, it will get the local machine's IP address (supports both IPv4 and IPv6).

  • Parameters:
    • ip (optional) The IP address to be located
  • Output: The current city and the midpoint location of the city
  1. Real-time Traffic Condition Query map_road_traffic

    • Description: Query real-time traffic congestion conditions, which can be done by specifying road names and area shapes (rectangle, polygon, circle).
    • Parameters:
      • model Type of traffic condition query (optional values include road, bound, polygon, around, default is road)
      • road_name Road name and direction, required when model=road (e.g., Chaoyang Road South to North)
      • city City name or city adcode, required when model=road (e.g., Beijing City)
      • bounds Latitude and longitude coordinates of the lower left and upper right corners of the area, required when model=bound (e.g., 39.9,116.4;39.9,116.4)
      • vertexes Latitude and longitude coordinates of the vertices of the polygonal area, required when model=polygon (e.g., 39.9,116.4;39.9,116.4;39.9,116.4;39.9,116.4)
      • center Latitude and longitude coordinates of the center point of the circular area, required when model=around (e.g., 39.912078,116.464303)
      • radius Radius (in meters) of the circular area, value range [1,1000], required when model=around (e.g., 200)
    • Output: Traffic condition information, including road_name, traffic_condition, etc.
  2. Smart POI Extraction map_poi_extract

    • Description: Can only be used if the provided API_KEY has advanced permissions. Extracts relevant POI information based on the given text content.
    • Parameters: text_content Text description used for extracting POIs (complete travel routes, itinerary planning, scenic spot recommendations, etc., e.g., "The Duku Highway and Tarim Lake in Xinjiang are so beautiful, and the experience from Dushanzi Grand Canyon to the Mysterious Tianshan Grand Canyon is also great.")
    • Output: Relevant POI information, including name, location, etc.

Getting Started

Using Baidu Map MCP Server primarily involves two forms: Python and Typescript. Below, we introduce each method.

Obtaining AK

Before choosing either of the two methods, you need to create a server-side AK in the Baidu Map Open Platform console. Only with the AK can you call the Baidu Map API capabilities.

Python Integration

If you wish to customize the Baidu Map MCP Server capabilities, you can integrate via the source code. For details, see the Python Integration Documentation.

In the v1.1 update, we released the Baidu Map MCP Server: mcp-server-baidu-maps on pypi, allowing you to easily obtain and quickly configure it using any Python package management tool.

Installation

Using uv (Recommended)

When using uv, no special installation is required. We will use uvx to directly run mcp-server-baidu-maps.

Using pip

Alternatively, you can install mcp-server-baidu-maps using pip: bash pip install mcp-server-baidu-maps

After installation, you can run it as a script using the following command: bash python -m mcp_server_baidu_maps

Configuration

Add the following configuration in any MCP client (such as Claude.app). Some clients may require formatting adjustments.

Replace the value of BAIDU_MAPS_API_KEY with your own AK.

Using uvx

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

Using pip installation

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

After saving the configuration, restart your MCP client to start using the Baidu Map MCP Server.

Typescript Integration

Node.js Installation

To integrate via Typescript, you only need to install node.js.When you can run the following in your terminal:

bash node -v

it indicates that node.js has been successfully installed.

Configuration

Open the Setting of Claude for Desktop, switch to Developer, and click on Edit Config. Open the configuration file with any IDE.

Add the following configuration to the file. BAIDU_MAP_API_KEY is the AK for accessing the Baidu Map Open Platform API, which you can apply for here:

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

For Windows systems, the JSON needs a specific configuration: json "mcpServers": { "baidu-map": { "command": "cmd", "args": [ "/c", "npx", "-y", "@baidumap/mcp-server-baidu-map" ], "env": { "BAIDU_MAP_API_KEY": "xxx" }, } }

Restart Claude. At this point, the settings panel should have successfully loaded the Baidu Map MCP Server. In the main interface's dialog box, you will see 8 available MCP tools; clicking on them will show more details.

Effect

You can now start asking questions to verify the capabilities of the travel planning assistant.

Integration via Qianfan AppBuilder Platform

The Qianfan platform supports integration through SDK or API. By building an application using AppBuilder, each application gets its own unique app_id. In the Python script, call the corresponding app_id and then invoke the Baidu Map Python MCP Tool.

The template code below demonstrates how to use the SDK Agent and the Map MCP Server to fetch navigation routes and route information, and provide travel suggestions.

Agent Configuration

Go to the Qianfan platform, create a new application, and publish it.

Set the number of thinking rounds for the Agent to 6. Publish the application.

Invocation

This code can be used as a template to call the already built and published App on the Qianfan platform via SDK. Download the MCP Server locally and write the relative file path into the code.

Note: Use the actual app_id, token, query, and mcp file.

python 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): def init(self, mcp_client): super().init() self.mcp_client = mcp_client

def get_current_weather(self, location=None, unit="摄氏度"): return "{} 的温度是 {} {}".format(location, 20, unit) async def interrupt(self, run_context, run_response): thought = run_context.current_thought # Green print print("\033[1;31m", "-> Agent intermediate thought: ", thought, "\033[0m") tool_output = [] for tool_call in run_context.current_tool_calls: tool_res = "" if tool_call.function.name == "get_current_weather": tool_res = self.get_current_weather(**tool_call.function.arguments) else: print( "\033[1;32m", "MCP tool name: {}, MCP parameters: {}\n".format(tool_call.function.name, tool_call.function.arguments), "\033[0m", ) mcp_server_result = await self.mcp_client.call_tool( tool_call.function.name, tool_call.function.arguments ) print("\033[1;33m", "MCP result: {}\n\033[0m".format(mcp_server_result)) for i, content in enumerate(mcp_server_result.content): if content.type == "text": tool_res += mcp_server_result.content[i].text tool_output.append( { "tool_call_id": tool_call.id, "output": tool_res, } ) return tool_output async def success(self, run_context, run_response): print("\n\033[1;34m", "-> Agent non-streaming response: ", run_response.answer, "\033[0m")

async def agent_run(client, mcp_client, query): tools = mcp_client.tools conversation_id = await client.create_conversation() with await client.run_with_handler( conversation_id=conversation_id, query=query, tools=tools, event_handler=MyEventHandler(mcp_client), ) as run: await run.until_done()

User Token

os.environ["APPBUILDER_TOKEN"] = ""

async def main(): appbuilder.logger.setLoglevel("DEBUG") ### Published Application ID app_id = "" appbuilder_client = appbuilder.AsyncAppBuilderClient(app_id) mcp_client = MCPClient()

### Note: The path here is the relative local path to the 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, 'Driving navigation from Beijing to Shanghai', ) await appbuilder_client.http_client.session.close()

if name == "main": loop = asyncio.get_event_loop() loop.run_until_complete(main())#### Effect

After the Agent's own deliberation, by calling multiple tools such as MCPServer location retrieval, geocoding service, and route planning service, it acquires navigation routes and route information, and provides travel suggestions.

Actual user request: "Please plan a one-day flower viewing trip in Beijing for me. Try to make the travel arrangements as comfortable as possible, of course, also taking into account the weather conditions."

Thought Process

Agent Result

Explanation

Some parameter specifications when using Baidu Map MCP Server:

License

MIT © baidu-maps

Authorization

Some advanced features in Baidu Map MCP Server require applying for advanced permissions to be used. If needed, please contact us.

Feedback

If you encounter any issues while using Baidu Map MCP Server, feel free to report them via issue or through the Baidu Map Open Platform. We also welcome every positive PR. Thank you very much for your support and contributions ❤️

Updates

The team is currently focusing on providing services in Remote form, so updates to the open-source part will be relatively fewer. Please understand.

VersionFeature DescriptionUpdate Date
V1.0Official launch of Baidu Map MCP Server2025-03-21
V1.1Added quick integration methods for uvx and pip2025-03-28
V1.2Added integration method for Qianfan AppBuilder2025-04-05
V2.0Supports MCP 1.9.0 protocol2025-05-16

工具列表

  • map_geocode: 地理编码服务: 将地址解析为对应的位置坐标.地址结构越完整, 地址内容越准确, 解析的坐标精度越高.

  • map_reverse_geocode: 逆地理编码服务: 根据纬经度坐标, 获取对应位置的地址描述, 所在行政区划, 道路以及相关POI等信息

  • map_search_places: 地点检索服务: 支持检索城市内的地点信息(最小到city级别), 也可支持圆形区域内的周边地点信息检索. 城市内检索: 检索某一城市内(目前最细到城市级别)的地点信息. 周边检索: 设置圆心和半径, 检索圆形区域内的地点信息(常用于周边检索场景).

  • map_place_details: 地点详情检索服务: 地点详情检索针对指定POI, 检索其相关的详情信息. 通过地点检索服务获取POI uid.使用地点详情检索功能, 传入uid, 即可检索POI详情信息, 如评分、营业时间等(不同类型POI对应不同类别详情数据).

  • map_directions_matrix: 批量算路服务: 根据起点和终点坐标计算路线规划距离和行驶时间. 批量算路目前支持驾车、骑行、步行. 步行时任意起终点之间的距离不得超过200KM, 超过此限制会返回参数错误. 驾车批量算路一次最多计算100条路线, 起终点个数之积不能超过100.

  • map_directions: 路线规划服务: 根据起终点位置名称纬经度坐标规划出行路线. 驾车路线规划: 根据起终点位置名称纬经度坐标规划驾车出行路线. 骑行路线规划: 根据起终点位置名称纬经度坐标规划骑行出行路线. 步行路线规划: 根据起终点位置名称纬经度坐标规划步行出行路线. 公交路线规划: 根据起终点位置名称纬经度坐标规划公共交通出行路线.

  • map_weather: 天气查询服务: 通过行政区划或是经纬度坐标查询实时天气信息及未来5天天气预报.

  • map_ip_location: IP定位服务: 通过所给IP获取具体位置信息和城市名称, 可用于定位IP或用户当前位置.

  • map_road_traffic: 实时路况查询服务: 查询实时交通拥堵情况, 可通过指定道路名和区域形状(矩形, 多边形, 圆形)进行实时路况查询. 道路实时路况查询: 查询具体道路的实时拥堵评价和拥堵路段、拥堵距离、拥堵趋势等信息. 矩形区域实时路况查询: 查询指定矩形地理范围的实时拥堵情况和各拥堵路段信息. 多边形区域实时路况查询: 查询指定多边形地理范围的实时拥堵情况和各拥堵路段信息. 圆形区域(周边)实时路况查询: 查询某中心点周边半径范围内的实时拥堵情况和各拥堵路段信息.

  • map_poi_extract: POI智能提取

服务配置

[{'mcpServers': {'baidu-maps': {'args': ['mcp-server-baidu-maps'], 'command': 'uvx', 'env': {'BAIDU_MAPS_API_KEY': '<YOUR_API_KEY>'}}}}, {'mcpServers': {'baidu-maps': {'args': ['-m', 'mcp_server_baidu_maps'], 'command': 'python', 'env': {'BAIDU_MAPS_API_KEY': '<YOUR_API_KEY>'}}}}, {'mcpServers': {'baidu-map': {'args': ['-y', '@baidumap/mcp-server-baidu-map'], 'command': 'npx', 'env': {'BAIDU_MAP_API_KEY': 'xxx'}}}}]

来源