Overview
Baidu Maps API now fully supports the MCP protocol, making it the first map service provider in China to be compatible with the MCP protocol.
The MCP Server provided by Baidu Maps includes 10 API interfaces 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) can quickly integrate with it.
Tools
- Geocoding
map_geocode
- Converts addresses into corresponding location coordinates
- Input:
addressaddress information - Output:
location
- Reverse Geocoding
map_reverse_geocode
- Converts coordinate points into corresponding semantic addresses
- Input:
locationlatitude and longitude coordinates - Output:
formatted_address,uid,addressComponent
- Place Search
map_search_places
- Multiple scenario place and POI searches, including city search and circular area search
- Input:
querysearch keywordslocationcenter point of circular searchradiusradius of circular searchregionspecified city for city search
- Output: POI list, including
name,location,address, etc.
- Place Details Search
map_place_details
- Search for POI details based on POI uid
- Input:
uid - Output: POI details, including
name,location,address,brand,price, etc.
- Batch Routing
map_distance_matrix
- Calculate route distances and travel times between all origin-destination combinations
- Input:
originslist of origin latitude and longitude coordinatesdestinationslist of destination latitude and longitude coordinatesmodetravel type, optional values includedriving,walking,riding, default isdriving
- Output: Duration and distance for each route, including
distance,duration, etc.
- Route Planning
map_directions
- Plan travel routes and durations based on origin and destination coordinates, can specify driving, walking, cycling, public transit, and other travel modes
- Input:
originorigin latitude and longitudedestinationdestination latitude and longitudemodeltravel type, optional values includedriving,walking,riding,transit, default isdriving
- Output: Route details, including
steps,distance,duration, etc.
- Weather Query
map_weather
- Query weather based on administrative division code or latitude and longitude coordinates (querying weather through
locationlatitude and longitude coordinates requires users to have advanced permissions) - Input:
district_idadministrative division codelocationlatitude and longitude coordinates
- Output: Weather information, including
temperature,weather,wind, etc.
- IP Location
map_ip_location
- Get the current location of the request based on the request IP (locates to city level), if the request parameter IP is IPv6, advanced permissions are required
- Input:
iprequest IP address - Output: Current city and city center
location
- Real-time Traffic Query
map_road_traffic
- Query real-time traffic congestion, can query real-time road conditions by specifying road name and area shape (rectangle, polygon, circle).
- Input:
modeltraffic query type (optional values includeroad,bound,polygon,around, default isroad)road_nameroad name and direction, required whenmodel=road(e.g.:Chaoyang Road southbound to northbound)citycity name or city adcode, required whenmodel=road(e.g.:Beijing)boundslatitude and longitude coordinates of the bottom-left and top-right corners of the area, required whenmodel=bound(e.g.:39.912078,116.464303;39.918276,116.475442)vertexeslatitude and longitude coordinates of the vertices of the polygon area, required whenmodel=polygon(e.g.:39.910528,116.472926;39.918276,116.475442;39.916671,116.459056;39.912078,116.464303)centerlatitude and longitude coordinates of the center point of the circular area, required whenmodel=around(e.g.:39.912078,116.464303)radiusradius of the circular area (meters), value range[1,1000], required whenmodel=around(e.g.:200)
- Output: Traffic information, including
road_name,traffic_condition, etc.
- POI Intelligent Extraction
map_poi_extract
- Requires advanced permissions to use, extracts POI-related information from text content.
- Input:
text_contenttext description information for extracting POI (complete tourism routes, itinerary planning, scenic spot recommendation descriptions, etc., for example: "Xinjiang Duku Highway and Tarim Lake are so beautiful, the experience from Dushanzi Grand Canyon to Tianshan Mysterious Grand Canyon is also very nice") - Output: Related POI information, including
name,location, etc.
Getting Started
Using the Baidu Maps MCP Server is primarily through two forms, namely Python and Typescript, which are described below.
Get AK
Before choosing between the two methods, you need to create a server-side AK in the Baidu Maps Open Platform console. You can only call Baidu Maps API capabilities through the AK.
Typescript Integration
Node.js Installation
To integrate through Typescript, you only need to install node.js.
When you can run the following in terminal:
node -vIt indicates that your node.js has been successfully installed.
Configuration
Open Claude for Desktop's Setting, switch to Developer, click Edit Config, and open the configuration file with any IDE.
Add the following configuration to the configuration file. BAIDU_MAP_API_KEY is the AK for accessing the Baidu Maps Open Platform API, which can be obtained from this page:
{
"mcpServers": {
"baidu-map": {
"command": "npx",
"args": [
"-y",
"@baidumap/mcp-server-baidu-map"
],
"env": {
"BAIDU_MAP_API_KEY": "xxx"
}
}
}
}Restart Claude, and the Baidu Maps MCP Server will be successfully loaded in the settings panel. In the main interface dialog box, you can see 8 available MCP tools, and click to view details.
Effect
Now you can ask questions to verify the capabilities of the travel planning assistant.
Integration through Qianfan AppBuilder Platform
Qianfan platform integration currently supports SDK or API integration. Build an application through AppBuilder, each application has a unique app_id, call the corresponding app_id in the python file, and then call the Baidu Maps Python MCP Tool.
You can jump down to the template code, which uses SDK Agent && Map MCP Server to obtain navigation routes and route information, and provides travel suggestions.
Agent Configuration
Go to the Qianfan Platform, create a new application, and publish it.
Set the Agent's thinking rounds to 6. Publish the application.
Calling
This code can be used as a template to call an App that has already been built and published on the Qianfan platform in the form of an SDK, and then download the MCP Server locally and write the relative path of the file into the code.
(Note: Use the actual app_id, token, query, mcp file)
import os
import asyncio
import appbuilder
from appbuilder.core.console.appbuilder_client.async_event_handler import (
AsyncAppBuilderEventHandler,
)
from appbuilder.modelcontextprotocol.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="Celsius"):
return "{} temperature is {} {}".format(location, 20, unit)
async def interrupt(self, run_context, run_response):
thought = run_context.current_thought
# Print in green
print("\033[1;31m", "-> Agent thinking: ", 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 answer: ", 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 that the path here is the relative path of the MCP Server file locally
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
Through the Agent's own thinking, by calling multiple tools such as MCP Server place search, geocoding service, route planning service, etc., it obtains navigation routes and route information, and provides travel suggestions.
Actual user request: "Please plan a one-day flower viewing tour in Beijing for me. Try to provide a more comfortable travel arrangement, of course, also pay attention to the weather conditions."
Notes
In the Baidu Maps MCP Server:
The administrative division codes used are based on the Baidu adcode mapping table.
The latitude and longitude coordinates used are based on the National Bureau of Surveying and Mapping latitude and longitude coordinates gcj02ll, see Baidu Coordinate System for details.


