Google 航班 MCP 服务器
该 MCP 服务器提供了使用捆绑的fast_flights
库与 Google Flights 数据交互的工具。
特征
提供以下 MCP 工具:
get_flights_on_date
:获取两个机场之间特定日期的可用单程航班。- 参数:
origin
(str)、 destination
(str)、 date
(str,YYYY-MM-DD)、 adults
(int,可选)、 seat_type
(str,可选)、 return_cheapest_only
(bool,可选,默认False
)。
get_round_trip_flights
:获取特定出发和返回日期的可用往返航班。- 参数:
origin
(str)、 destination
(str)、 departure_date
(str,YYYY-MM-DD)、 return_date
(str,YYYY-MM-DD)、 adults
(int,可选)、 seat_type
(str,可选)、 return_cheapest_only
(bool,可选,默认False
)。
find_all_flights_in_range
:查找指定日期范围内的往返航班。可以选择仅返回每个日期范围内找到的最便宜航班。- 参数:
origin
(str)、 destination
(str)、 start_date_str
(str,YYYY-MM-DD)、 end_date_str
(str,YYYY-MM-DD)、 min_stay_days
(int,可选)、 max_stay_days
(int,可选)、 adults
(int,可选)、 seat_type
(str,可选)、 return_cheapest_only
(bool,可选,默认False
)。
设置
- 克隆存储库:
git clone https://github.com/opspawn/Google-Flights-MCP-Server.git
cd Google-Flights-MCP-Server
- 创建虚拟环境(推荐):
python -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
- 安装依赖项:
pip install -r requirements.txt
- 安装 Playwright 浏览器(
fast_flights
需要):
运行服务器
您可以直接使用 Python 运行服务器:
服务器默认使用 STDIO 传输。
与 MCP 客户端集成(例如 Cline、Claude Desktop)
将服务器添加到 MCP 客户端的配置文件中。例如, cline_mcp_settings.json
或claude_desktop_config.json
:
{
"mcpServers": {
"google-flights": {
"command": "/path/to/your/.venv/bin/python", // Use absolute path to venv python
"args": [
"/absolute/path/to/flight_mcp_server/server.py" // Use absolute path to server script
],
"env": {},
"disabled": false,
"autoApprove": []
}
// ... other servers
}
}
**重要提示:**将command
和args
中的路径替换为虚拟环境的 Python 可执行文件和系统上的server.py
脚本的绝对路径。
笔记
- 此服务器捆绑了
fast_flights
库(最初来自https://github.com/AWeirdDev/flights ),用于其核心航班数据抓取功能。请参阅随附的LICENSE
文件了解其条款。 - 根据 Google 航班信息的变化和网络状况,航班数据抓取有时会不可靠或缓慢。这些工具包含基本的错误处理功能。
find_all_flights_in_range
工具可能会占用大量资源,因为它会检查许多日期组合。