Google Flights MCP Server

Google Flights MCP Server

site icon
2025.04.07 1
Python航班查询旅行规划位置服务
Google Flights MCP Server 是一个提供与 Google Flights 数据交互的工具的服务,通过集成的 `fast_flights` 库实现核心功能。该服务主要用于查询航班信息,包括单程航班、往返航班以及指定日期范围内的航班。
View on GitHub

Overview

基本能力

产品定位

Google Flights MCP Server 主要用于航班信息的查询和交互,适用于需要获取航班数据的场景。

核心功能

  1. get_flights_on_date: 查询指定日期的单程航班信息。
  2. 参数:origin(出发地)、destination(目的地)、date(日期,格式为YYYY-MM-DD)、adults(成人数量,可选)、seat_type(座位类型,可选)、return_cheapest_only(是否仅返回最便宜的航班,默认为False)。
  3. get_round_trip_flights: 查询指定出发和返回日期的往返航班信息。
  4. 参数:origindestinationdeparture_date(出发日期)、return_date(返回日期)、adultsseat_typereturn_cheapest_only
  5. find_all_flights_in_range: 查询指定日期范围内的往返航班信息,可选项包括仅返回每个日期对的最便宜航班。
  6. 参数:origindestinationstart_date_str(开始日期)、end_date_str(结束日期)、min_stay_days(最短停留天数,可选)、max_stay_days(最长停留天数,可选)、adultsseat_typereturn_cheapest_only

适用场景

  • 旅行规划:帮助用户查询航班信息,规划行程。
  • 价格比较:比较不同日期的航班价格,找到最便宜的选项。
  • 自动化工具:集成到其他工具或服务中,自动获取航班数据。

工具列表

  1. get_flights_on_date: 查询单程航班信息。
  2. get_round_trip_flights: 查询往返航班信息。
  3. find_all_flights_in_range: 查询日期范围内的往返航班信息。

常见问题解答

  • 航班抓取不可靠或慢:取决于 Google Flights 的变化和网络条件,工具包含基本的错误处理。
  • 资源密集型find_all_flights_in_range 工具可能会检查许多日期组合,因此资源消耗较大。

使用教程

使用依赖

  1. 克隆仓库bash git clone https://github.com/opspawn/Google-Flights-MCP-Server.git cd Google-Flights-MCP-Server
  2. 创建虚拟环境(推荐)bash python -m venv .venv source .venv/bin/activate # Windows 使用 `.venv\Scripts\activate`
  3. 安装依赖bash pip install -r requirements.txt
  4. 安装 Playwright 浏览器bash playwright install

安装教程

  1. 完成上述依赖安装后,直接运行服务器: bash python server.py

调试方式

  • 服务器默认使用 STDIO 传输,可以通过日志或输出信息进行调试。

集成到 MCP 客户端

在 MCP 客户端的配置文件中添加服务器配置,例如 cline_mcp_settings.jsonclaude_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": []
    }
  }
}

注意:替换 commandargs 中的路径为实际的绝对路径。

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。