G

Google-Flights-MCP-Server

A15570082312/Google-Flights-MCP-Server
0 Stars 57 次浏览 更新于 2026-08-23

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "google-flight": {
      "args": [],
      "command": "python server.py"
    }
  }
}

服务介绍

Google Flights 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)。

设置

  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浏览器(fast_flights需要):
    bash
    playwright install

运行服务器

你可以直接使用Python运行服务器:

bash
python server.py

服务器默认使用STDIO传输。

与MCP客户端集成(例如,Cline, Claude Desktop)

将服务器添加到你的MCP客户端的配置文件中。例如在cline_mcp_settings.jsonclaude_desktop_config.json中:

json
{
"mcpServers": {
"google-flights": {
"command": "/path/to/your/.venv/bin/python", // 使用虚拟环境Python的绝对路径
"args": [
"/absolute/path/to/flight_mcp_server/server.py" // 使用server.py脚本的绝对路径
],
"env": {},
"disabled": false,
"autoApprove": []
}
// ... 其他服务器
}
}

重要提示: 请将commandargs中的路径替换为你系统上虚拟环境的Python可执行文件和server.py脚本的绝对路径。

注意事项

  • 该服务器捆绑了fast_flights库(最初来自https://github.com/AWeirdDev/flights),用于其核心航班抓取功能。请参阅包含的LICENSE文件以了解其条款。
  • 航班抓取有时可能会因Google Flights的变化和网络条件而变得不可靠或缓慢。这些工具包括基本的错误处理。
  • find_all_flights_in_range工具可能非常耗费资源,因为它会检查许多日期组合。

相关 MCP 服务