
Google Flights MCP Server

2025.04.13
0
Python航班查询旅行规划位置服务
Google Flights MCP Server 是一个提供与 Google Flights 数据交互的工具的服务,通过集成的 `fast_flights` 库实现。它主要用于查询航班信息,包括单程航班、往返航班以及在指定日期范围内的所有航班。
View on GitHub
Overview
基本能力
产品定位
Google Flights MCP Server 主要用于航班信息的查询和交互,适用于需要获取航班数据的场景。
核心功能
get_flights_on_date
: 查询特定日期两个机场之间的单程航班。- 参数:
origin
(出发地),destination
(目的地),date
(日期, YYYY-MM-DD),adults
(成人数量, 可选),seat_type
(座位类型, 可选),return_cheapest_only
(是否仅返回最便宜的航班, 可选, 默认False
)。 get_round_trip_flights
: 查询特定出发和返回日期的往返航班。- 参数:
origin
,destination
,departure_date
(出发日期),return_date
(返回日期),adults
,seat_type
,return_cheapest_only
。 find_all_flights_in_range
: 查询指定日期范围内的所有往返航班,可选仅返回每个日期对的最便宜航班。- 参数:
origin
,destination
,start_date_str
(开始日期),end_date_str
(结束日期),min_stay_days
(最短停留天数, 可选),max_stay_days
(最长停留天数, 可选),adults
,seat_type
,return_cheapest_only
。
适用场景
- 旅行规划:查询特定日期的航班信息。
- 价格比较:比较不同日期的航班价格。
- 资源密集型查询:在指定日期范围内查找所有可能的航班组合。
工具列表
get_flights_on_date
: 查询单程航班。get_round_trip_flights
: 查询往返航班。find_all_flights_in_range
: 查询日期范围内的所有航班。
常见问题解答
- 航班抓取有时可能不可靠或缓慢,取决于 Google Flights 的变化和网络条件。
find_all_flights_in_range
工具可能会消耗大量资源,因为它检查许多日期组合。
使用教程
使用依赖
- 克隆仓库:
bash git clone https://github.com/opspawn/Google-Flights-MCP-Server.git cd Google-Flights-MCP-Server
- 创建虚拟环境 (推荐):
bash python -m venv .venv source .venv/bin/activate # Windows 使用 `.venv\Scripts\activate`
- 安装依赖:
bash pip install -r requirements.txt
- 安装 Playwright 浏览器:
bash playwright install
安装教程
- 完成上述依赖安装后,直接运行服务器:
bash python server.py
调试方式
- 确保虚拟环境已激活。
- 确保所有依赖已正确安装。
- 运行服务器并检查输出是否有错误信息。
集成 MCP 客户端
在 MCP 客户端的配置文件中添加服务器配置,例如 cline_mcp_settings.json
或 claude_desktop_config.json
:
{
"mcpServers": {
"google-flights": {
"command": "/path/to/your/.venv/bin/python",
"args": [
"/absolute/path/to/flight_mcp_server/server.py"
],
"env": {},
"disabled": false,
"autoApprove": []
}
}
}
注意: 替换 command
和 args
中的路径为实际的绝对路径。