
百度地图API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
百度地图提供的MCP Server,包含10个符合MCP协议标准的API接口,涵盖逆地理编码、地点检索、路线规划等。
依赖MCP Python SDK和MCP Typescript SDK开发,任意支持MCP协议的智能体助手(如Claude、Cursor以及千帆AppBuilder等)都可以快速接入。
强烈推荐通过SSE接入百度地图MCP Server, 以获得更低的延迟和更高的稳定性。请不要忘记在控制台为你的AK勾选上MCP(SSE)服务。
地理编码 map_geocode
address 地址信息is_china 地址是否在中国大陆以外地区,默认为is_china=truelocation 纬经度坐标逆地理编码 map_reverse_geocode
latitude 纬度坐标longitude经度坐标formatted_address, uid, addressComponent 等语义化地址信息地点检索 map_search_places
city级别), 也可支持圆形区域内的周边地点信息检索query 检索关键词, 可用名称或类型, 多关键字使用英文逗号隔开, 如: query=天安门,美食tag 检索的类型偏好, 格式为tag=美食或者tag=美食,酒店region 检索的行政区划, 格式为region=cityname或region=citycodelocation 圆形检索中心点纬经度坐标, 格式为location=lat,lngradius 圆形检索的半径is_china 检索地是否在中国大陆以外地区,默认为is_china=truename, location, address等地点详情检索 map_place_details
uid POI的唯一标识is_china 检索目标是否在中国大陆以外地区,默认为is_china=truename, location, address, brand, price等批量算路 map_directions_matrix
origins 起点纬经度列表, 格式为origins=lat,lng,多个起点用|分隔destinations 终点纬经度列表, 格式为destinations=lat,lng,多个终点用|分隔model 算路类型,可选取值包括 driving, walking, riding,默认使用drivingdistance, duration等路线规划 map_directions
origin 起点位置名称或纬经度, 格式为origin=lat,lngdestination 终点位置名称或纬经度, 格式为destination=lat,lngmodel 出行类型, 可选取值包括 driving, walking, riding, transit, 默认使用drivingis_china 是否在中国大陆以外地区,默认为is_china=truesteps, distance, duration等天气查询 map_weather
district_id 行政区划编码location 经纬度坐标, 格式为location=lng, latis_china 是否在中国大陆以外地区,默认为is_china=truetemperature, weather, wind等IP定位 map_ip_location
ip,如果为空则获取本机IP地址(支持IPv4和IPv6)。ip(可选)需要定位的IP地址location实时路况查询 map_road_traffic
model 路况查询类型 (可选值包括road, bound, polygon, around, 默认使用road)road_name 道路名称和道路方向, model=road时必传 (如:朝阳路南向北)city 城市名称或城市adcode, model=road时必传 (如:北京市)bounds 区域左下角和右上角的纬经度坐标, model=bound时必传 (如:39.9,116.4;39.9,116.4)vertexes 多边形区域的顶点纬经度坐标, model=polygon时必传 (如:39.9,116.4;39.9,116.4;39.9,116.4;39.9,116.4)center 圆形区域的中心点纬经度坐标, model=around时必传 (如:39.912078,116.464303)radius 圆形区域的半径(米), 取值[1,1000], model=around时必传 (如:200)road_name, traffic_condition等POI智能提取 map_poi_extract
API_KEY带有高级权限才可使用, 根据所给文本内容提取其中的相关POI信息。text_content 用于提取POI的文本描述信息 (完整的旅游路线,行程规划,景点推荐描述等文本内容, 例如: 新疆独库公路和塔里木湖太美了, 从独山子大峡谷到天山神秘大峡谷也是很不错的体验)name, location等任意支持MCP协议的客户端(如Claude for Desktop、Cursor、Cherry Studio 和 Cline等)都可以简单且快速的接入百度地图MCP Server。
在传输方式上,百度地图MCP Server支持:
HTTP 远程传输
stdio 本地传输
下面提供通用的接入配置,客户端接入的配置示例则在最后采用Cursor作为接入演示。请根据您客户端的兼容性选择合适的传输方式进行接入。
P.S. Streamable HTTP是Anthropic当前在MCP协议中主推用于替代传统SSE的传输方式,相比于SSE它支持无状态通信,甚至支持按需升级到 SSE,更稳定、更高效的通信也使得它更加适配企业级应用。因此,如果您选择了HTTP远程接入,在条件允许的情况下我们极力推荐以Streamable HTTP作为接入首选。
在百度地图开放平台注册并创建服务器端API密钥(AK)。
https://mcp.map.baidu.com/mcp?ak=您的AK
https://mcp.map.baidu.com/sse?ak=您的AK
可以通过pip来安装mcp-server-baidu-maps
pip install mcp-server-baidu-maps
安装后,我们可以使用以下命令将其作为脚本运行:
python -m mcp_server_baidu_maps
也可以在你的客户端中配置(如Claude for Desktop、Cursor),部分客户端下可能需要做一些格式化调整。
其中BAIDU_MAPS_API_KEY对应的值需要替换为你自己的AK。
{ "mcpServers": { "baidu-maps": { "command": "uvx", "args": ["mcp-server-baidu-maps"], "env": { "BAIDU_MAPS_API_KEY": "<YOUR_API_KEY>" } } }}
{ "mcpServers": { "baidu-maps": { "command": "python", "args": ["-m", "mcp_server_baidu_maps"], "env": { "BAIDU_MAPS_API_KEY": "<YOUR_API_KEY>" } } }}
保存配置后,重启你的MCP客户端,即可使用百度地图MCP Server。
通过Typescript接入,你只需要安装node.js。
当你在终端可以运行
node -v
则说明你的node.js已经安装成功。
安装:
npm install @baidumap/mcp-server-baidu-map
在你的客户端中配置(如Claude for Desktop、Cursor):
将以下配置添加到配置文件中,BAIDU_MAP_API_KEY 是访问百度地图开放平台API的AK,在此页面中申请获取:
{ "mcpServers": { "baidu-map": { "command": "npx", "args": [ "-y", "@baidumap/mcp-server-baidu-map" ], "env": { "BAIDU_MAP_API_KEY": "<BAIDU_MAP_API_KEY>" } } }}
如果是window 系统, json 需要添加单独的配置:
"mcpServers": { "baidu-map": { "command": "cmd", "args": [ "/c", "npx", "-y", "@baidumap/mcp-server-baidu-map" ], "env": { "BAIDU_MAP_API_KEY": "<BAIDU_MAP_API_KEY>" }, }}
对于StreamableHTTP接入,需在配置文件中添加
{ "mcpServers": { "baidu-maps-StreamableHTTP": { "url": "https://mcp.map.baidu.com/sse?ak=您的ak" } }}
如果选择的传输方式为SSE,则配置为
{ "mcpServers": { "baidu-maps-SSE": { "url": "https://mcp.map.baidu.com/sse?ak=您的ak" } }}
如果在使用过程中遇到工具调用效果较差的情况,可以更换基础模型。当前评估适配MCP效果较好的为claude-sonnet系列模型,可在图中位置选择更换。
千帆平台接入,目前支持SDK接入或是API接入,通过AppBuilder构建一个应用,每个应用拥有一个独立的app_id,在python文件中调用对应的app_id,再调用百度地图 Python MCP Tool即可。
模板代码可向下跳转,通过SDK Agent &&地图MCP Server,拿到导航路线及路线信息,并给出出行建议。
前往千帆平台,新建一个应用,并发布。

将Agent的思考轮数调到6。发布应用。
此代码可以当作模板,以SDK的形式调用千帆平台上已经构建好且已发布的App,再将MCP Server下载至本地,将文件相对路径写入代码即可。
(注意:使用实际的app_id、token、query、mcp文件)
import osimport asyncioimport appbuilderfrom appbuilder.core.console.appbuilder_client.async_event_handler import ( AsyncAppBuilderEventHandler,)from appbuilder.mcp_server.client import MCPClientclass 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 # 绿色打印 print("\033[1;31m", "-> Agent 中间思考: ", 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工具名称: {}, MCP参数:{}\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结果: {}\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 非流式回答: ", 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()### 用户Tokenos.environ["APPBUILDER_TOKEN"] = ( "")async def main(): appbuilder.logger.setLoglevel("DEBUG") ### 发布的应用ID app_id = "" appbuilder_client = appbuilder.AsyncAppBuilderClient(app_id) mcp_client = MCPClient() ### 注意这里的路径为MCP Server文件在本地的相对路径 await mcp_client.connect_to_server("./<YOUR_FILE_PATH>/map.py") print(mcp_client.tools) await agent_run( appbuilder_client, mcp_client, '开车导航从北京到上海', ) await appbuilder_client.http_client.session.close()if __name__ == "__main__": loop = asyncio.get_event_loop() loop.run_until_complete(main())
经过Agent自己的思考,通过调用MCPServer 地点检索、地理编码服务、路线规划服务等多个tool,拿到导航路线及路线信息,并给出出行建议。
实际用户请求:“请为我计划一次北京赏花一日游。尽量给出更舒适的出行安排,当然,也要注意天气状况。”


在百度地图MCP Server中传入的部分参数规格:
行政区划编码均采用百度adcode映射表。
经纬度坐标均采用国测局经纬度坐标bd09ll,详见百度坐标系。
类型等中文字符串参数应符合百度POI类型标准。
MIT © baidu-maps
百度地图MCP Server中的部分高级能力需要申请高级权限才可使用。如有需要的话,请联系我们。
在使用百度地图MCP Server时遇到的任何问题,欢迎通过issue或是百度地图开放平台反馈给我们,我们也欢迎每一个积极的PR,非常感谢各位的支持与贡献❤️
团队目前主要关注Remote形式的服务供应,对于开源部分的更新会相对较少,请谅解。
| 版本 | 功能说明 | 更新日期 |
|---|---|---|
| V1.0 | 百度地图MCP Server正式上线 | 2025-03-21 |
| V1.1 | 补充uvx、pip形式的快速接入 | 2025-03-28 |
| V1.2 | 补充千帆AppBuilder接入方式 | 2025-04-05 |
| V2.0 | 支持MCP1.9.0版协议 | 2025-05-16 |