Route & Gas Station MCP Server
Enables users to query driving distances and find gas stations along routes using Google Maps APIs through natural language, powered by FastMCP and Google ADK.
README
Route & Gas Station Chatbot with MCP, Google ADK, and Google Maps
A local AI travel chatbot that calculates driving distance between two locations and finds gas stations near a route.
This project is built to understand the complete Model Context Protocol (MCP) flow:
User -> Google ADK Chatbot -> MCP Client -> MCP Server -> Google Maps APIs
Features
- Calculate driving distance and estimated travel duration
- Find gas stations near sampled points on a driving route
- Use Google ADK as the AI chatbot framework
- Use FastMCP to expose Python functions as MCP tools
- Use Google Routes API for driving routes
- Use Google Places API (New) for gas-station searches
- Run locally using Streamable HTTP MCP transport
Architecture
+------------------+
| User / ADK Web |
| http://localhost |
+--------+---------+
|
| Natural-language request
v
+------------------+
| Google ADK Agent |
| MCP Client |
+--------+---------+
|
| http://127.0.0.1:8002/mcp
v
+-------------------------------+
| FastMCP Server |
| route_mcp_server.py |
+---------------+---------------+
|
+----------------------------+
| |
v v
+--------------------------+ +--------------------------+
| Google Routes API | | Google Places API (New) |
| Distance and duration | | Gas stations |
+--------------------------+ +--------------------------+
Project Structure
mcp-route-chatbot/
│
├── .env
├── .gitignore
├── README.md
├── requirements.txt
├── route_mcp_server.py
│
└── route_chatbot/
├── __init__.py
└── agent.py
Prerequisites
- Python 3.10 or later
- Google Gemini API key for Google ADK
- Google Maps Platform API key
- Google Cloud billing account connected to the Google Maps project
- Enabled Google Maps APIs:
- Routes API
- Places API (New)
Setup
1. Clone the repository
git clone https://github.com/YOUR_GITHUB_USERNAME/mcp-route-chatbot.git
cd mcp-route-chatbot
2. Create and activate a virtual environment
Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
macOS/Linux:
python3 -m venv .venv
source .venv/bin/activate
3. Install dependencies
python -m pip install -r requirements.txt
4. Configure environment variables
Create a .env file in the project root:
GOOGLE_API_KEY=your_gemini_api_key
GOOGLE_MAPS_API_KEY=your_google_maps_platform_api_key
Never commit your
.envfile or API keys to GitHub.
Google Maps Setup
- Open Google Cloud Console
- Create a new Google Cloud project
- Link a billing account
- Enable the following APIs:
- Routes API
- Places API (New)
- Go to APIs & Services -> Credentials
- Create an API key
- Restrict the key to only:
- Routes API
- Places API (New)
- Add the key to
.envasGOOGLE_MAPS_API_KEY
Run the Application
The project has two independently running services.
Terminal 1: Start the MCP server
python route_mcp_server.py
Expected MCP endpoint:
http://127.0.0.1:8002/mcp
Terminal 2: Start ADK Web UI
adk web --port 8001
Open this URL in your browser:
http://127.0.0.1:8001
Select the route_chatbot agent in the ADK Web UI.
Example Prompts
Ask these questions in ADK Web UI:
What is the driving distance from Phoenix, Arizona to Sedona, Arizona?
How long does it take to drive from Phoenix, Arizona to Flagstaff, Arizona?
Find 5 gas stations from Phoenix, Arizona to Flagstaff, Arizona.
Show gas stations on the route from Los Angeles, California to Las Vegas, Nevada.
MCP Tools
The FastMCP server exposes these tools to the ADK agent.
| Tool | Purpose |
|---|---|
route_distance |
Returns driving distance in miles/kilometers and estimated driving time |
gas_stations_on_route |
Finds gas stations around sampled coordinates along the route |
route_distance
Example tool input:
{
"origin": "Phoenix, Arizona",
"destination": "Sedona, Arizona"
}
Example response:
{
"origin": "Phoenix, Arizona",
"destination": "Sedona, Arizona",
"distance_km": 186.4,
"distance_miles": 115.8,
"estimated_drive_minutes": 125.0
}
gas_stations_on_route
Example tool input:
{
"origin": "Phoenix, Arizona",
"destination": "Flagstaff, Arizona",
"max_results": 5
}
Important Ports
| Service | Port | URL |
|---|---|---|
| ADK Web UI | 8001 | http://127.0.0.1:8001 |
| MCP Server | 8002 | http://127.0.0.1:8002/mcp |
Do not open the MCP URL directly in a browser. It is a Streamable HTTP endpoint for MCP clients and may return an error such as Client must accept text/event-stream. The ADK agent is the MCP client that should connect to this endpoint.
API Cost Notes
Google Maps Platform APIs use pay-as-you-go pricing. This project can make:
- One Routes API call for a distance question
- One Routes API call plus several Places Nearby Search calls for a gas-station question
For learning and low-volume local usage, create a dedicated Google Cloud project and configure a small billing budget alert before testing.
Troubleshooting
| Issue | Possible cause | Solution |
|---|---|---|
GOOGLE_MAPS_API_KEY is missing |
.env is missing or not loaded |
Put .env beside route_mcp_server.py, then restart the server |
403 PERMISSION_DENIED |
API not enabled, billing not linked, or restricted key | Enable Routes API and Places API (New), verify billing and key restrictions |
404 on http://127.0.0.1:8002/ |
Normal behavior | Use the MCP endpoint /mcp only from the ADK client |
Client must accept text/event-stream |
MCP URL opened in a browser | This is expected; start ADK Web and let ADK connect |
| ADK cannot find MCP tools | Incorrect MCP URL or MCP server is stopped | Confirm http://127.0.0.1:8002/mcp and keep the MCP terminal running |
429 RESOURCE_EXHAUSTED |
API quota or rate limit | Reduce calls and review Google Cloud quotas and billing |
Security
- Keep API keys only in
.env - Add
.envto.gitignore - Restrict the Google Maps API key to Routes API and Places API (New)
- Use IP restrictions when deploying the MCP server
- Do not expose server-side API keys in a frontend application
Future Improvements
- Add real-time fuel price data from a fuel-price provider
- Add route preferences such as avoiding tolls or highways
- Recommend the best fuel stop based on rating, route position, and opening hours
- Add route map visualization
- Add unit tests with
pytestand mocked Google API responses - Dockerize the MCP server and ADK application
- Deploy the MCP server to Cloud Run or AWS ECS
- Add an approval step before sharing a travel plan
Learning Outcomes
This project demonstrates:
- MCP server development with FastMCP
- MCP client integration with Google ADK
- Agent tool calling
- Streamable HTTP transport
- API-key management with
.env - Google Maps Routes API integration
- Google Places API integration
- Local multi-service application development
License
This project is licensed under the MIT License. See the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。