- Home
- MCP servers
- Geolocation Search and Route Planning
Geolocation Search and Route Planning
- python
0
GitHub Stars
python
Language
5 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"leng-2024-agent-with-mcp": {
"command": "python",
"args": [
"baidu_map_search_mcp.py"
],
"env": {
"BAIDU_MAPS_API_KEY": "<YOUR_BAIDU_MAPS_API_KEY>"
}
}
}
}You can expose geographic search and route planning capabilities as an MCP server that any compatible large model can call. This MCP server lets you run an agent locally or offer its tools to external models, enabling location-based queries and multi-mode routing with a simple, consistent interface.
How to use
You can connect to the MCP server from an external model or client by using the stdio-based MCP transport shown in the example configuration. The server exposes a set of tools for location search and route planning, including geocoding, reverse geocoding, nearby places, and driving, walking, biking, and transit routing. When you send a request, the MCP client will route the call to the appropriate tool (for example, get_location_text, get_places, or get_place_driving_distance) and return a structured result in Markdown-style output for easy presentation.
To start using the server, first run the MCP service locally as described in the installation section. Then you can configure your MCP client to point to the local stdio server using the command and environment shown in the example. The client will invoke tools automatically based on your input, and you will receive a structured, readable response that highlights route suggestions and place results.
How to install
Prerequisites you need before installation:
- Python installed on your system
- Access to an internet connection to fetch dependencies
- A valid Baidu Maps API Key for map operations
- A valid DeepSeek API Key if you plan to run the local agent with DeepSeek inference Follow these steps to install and prepare the MCP server and its tooling.
# Optional: create a virtual environment
python -m venv venv
# Activate the environment (example for Windows PowerShell)
venv\Scripts\activate
# Install required dependencies
pip install -r requirements.txt
# If requirements.txt is not available, you can install core dependencies directly
pip install openai httpx fastmcp
Additional setup and configuration
The MCP server relies on two main API keys when running locally as an agent, or a single API key when only exposing MCP tools. You will need to provide these keys as environment variables during startup.
Environment variables used by the server:
- BAIDU_MAP_API_KEY: Baidu Maps Web API AK used for map lookups and routing.
- DEEPSEEK_API_KEY: DeepSeek API Key used for running the local agent with the DeepSeek model (required for local agent mode).
- BAIDU_MAPS_API_KEY: Alternative or additional Baidu Maps API key used by the MCP transport.
- Any other keys shown in specific runtime examples should be provided as needed by your deployment.
MCP configuration and environment for the server
You can run the MCP service locally to expose the map tools to external models. The following stdio-based configuration demonstrates how to start the MCP server with a Python command and an environment variable for the Baidu Maps API key.
{
"mcpServers": {
"search_mcp": {
"command": "python",
"args": ["<YOUR_BAIDU_MAP_SEARCH_MCP_PATH>"],
"env": {
"BAIDU_MAPS_API_KEY": "<YOUR_API_KEY>"
}
}
}
}
Security and best practices
Keep API keys secure. Do not embed keys directly in code that is committed to version control. Use environment variables or a secret manager in your deployment. Limit API usage to required capabilities and apply rate limiting on your MCP endpoints if you expose them to external models.
Troubleshooting notes
If you encounter startup issues, verify that the required API keys are set in the environment where the MCP server runs. Check that the Python environment has the necessary packages installed and that the Baidu Maps API is accessible from your deployment region. If a tool call fails, inspect the MCP transport logs to determine which function was invoked and what parameters were passed.
Examples of supported tools and endpoints
The MCP server provides the following tool capabilities:
- get_ip(): Get the public IP address of the user
- get_location_ip(ip): Get geographic location from an IP address
- get_location_text(address): Convert a textual address to coordinates
- get_places(query, location, radius): Find places near a location
- get_place_driving_distance(origin, destination): Compute driving route details
- get_place_walking_distance(origin, destination): Compute walking route details
- get_place_riding_distance(origin, destination): Compute biking route details
- get_place_transit_distance(origin, destination): Compute transit route details
Notes about MCP server naming and identification
The MCP server name used in the configuration is search_mcp. This name is used as the key in the mcpServers map and should be kept concise and lowercase.
Available tools
get_ip
Retrieve the user's public IP address.
get_location_ip
Resolve geographic location from an IP address.
get_location_text
Convert a textual address to geographic coordinates.
get_places
Search nearby places given a query, location, and radius.
get_place_driving_distance
Plan a driving route between two points.
get_place_walking_distance
Plan a walking route between two points.
get_place_riding_distance
Plan a cycling route between two points.
get_place_transit_distance
Plan a transit (bus/train) route between two points.