Google Flights

io.github.ThiagoJacobLannes由 GitHub 账号 ThiagoJacobLannes 发布v0.1.0更新于 Nov 1, 2026

Search Google Flights prices, cheapest travel dates and airport codes.

概览

AI 生成的概览

搜索 Google Flights 的机票价格、航班时刻与最便宜出行日期,并把城市或机场名称解析为 IATA 代码。

可以做什么
  • 按出发地、目的地、日期、乘客数、舱位、币种、经停次数和排序方式搜索航班,返回按价格排序的选项,含航司、起降时间、时长和 Google Flights 链接
  • 在日期窗口内(最多 21 天)找出最便宜的出发日,类似价格日历
  • 用离线机场数据把城市或机场名称解析为 IATA 代码
适用场景
适合让助手在不打开浏览器的情况下比较机票价格与时刻,或在某段日期范围内找出最便宜的出行日。搜索前查机场代码时也用得上。
运行要求
以 stdio 本地运行,通常通过 uvx 从 PyPI 启动(需 Python 3.11+ 和 uv)。默认抓取方式无需 API 密钥;设置 SERPAPI_KEY 会改用 SerpApi,提供航班号、经停详情和碳排放信息。可选 GOOGLE_FLIGHTS_DEFAULT_ORIGIN 和 GOOGLE_FLIGHTS_DEFAULT_CURRENCY。需要能访问 Google Flights 的网络。
安装前请注意
默认数据源直接抓取 Google Flights 内部搜索接口,Google 改动后可能失效;在欧盟/英国地区会自动提交 Cookie 同意弹窗中的“全部拒绝”选项。往返搜索结果给出的是去程选项加估算总价,而非单独定价的回程航段。cheapest_dates 每天执行一次搜索,速度较慢。若设置 SERPAPI_KEY,该密钥会保存在客户端配置中,查询也会发送给 SerpApi。可选的 HTTP 模式若要暴露到 localhost 之外,需自行配置反向代理和鉴权。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Google Flights,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

google-flights-mcp

MCP server for searching Google Flights prices and schedules from Claude.

Two interchangeable data sources behind one interface (google_flights_mcp/providers/base.py):

  • fast-flights (default) — scrapes Google Flights' internal protobuf search API directly. No API key, works out of the box.
  • SerpApi — used automatically when a SERPAPI_KEY environment variable is set. Adds flight numbers, layover detail, and carbon emissions.

Tools

  • search_flights — origin (default LIS), destination, departure_date, optional return_date, passenger counts, cabin_class, currency (default EUR), max_stops, sort_by. Returns a price-ranked list: price, airline(s), departure/arrival times, duration, stops, and a Google Flights link.
  • cheapest_dates — cheapest day(s) to fly in a date window (max 21 days), price-calendar style. Runs one search per day — see "Known limitations" below.
  • airport_search — resolve a city or airport name ("Lisbon") to an IATA code (LIS), backed by the offline airportsdata package.

Known limitations

  • Round trips: for return_date searches, both providers return outbound flight options annotated with an estimated round-trip total price (paired with the cheapest matching return) — not a separately priced return leg. stops/duration/legs describe the outbound flight only. Open the result's booking_link on Google Flights to pick the exact return.
  • cheapest_dates: neither fast-flights nor SerpApi's Google Flights engine expose a real bulk price-calendar endpoint, so this runs one search_flights call per candidate day. Capped at a 21-day window to keep that bounded.
  • EU/UK cookie-consent wall: Google shows a cookie-consent interstitial to requests from those regions before returning real results. The fast-flights provider detects this and auto-submits "Reject all" (the privacy-preserving option) before retrying — see providers/fast_flights_provider.py if this ever needs updating for a change on Google's side.

Install

Quickest (needs uv): no clone needed, it runs straight from PyPI.

bash
claude mcp add google-flights -- uvx google-flights-search-mcp

For Claude Desktop, use "command": "uvx", "args": ["google-flights-search-mcp"].

From source:

Requires Python 3.11+ and uv.

bash
git clone https://github.com/ThiagoJacobLannes/google-flights-mcpcd google-flights-mcpuv sync --extra dev

On Windows, if you keep code in a cloud-synced folder (Google Drive, OneDrive), create the venv outside it — sync clients drop desktop.ini marker files into folders, which can crash packages on startup:

bash
uv venv C:\dev\google-flights-mcp-venvuv pip install --python C:\dev\google-flights-mcp-venv -e ".[dev]"

The command paths below assume that venv location; adjust to wherever yours lives.

Add to Claude Desktop

Merge claude_desktop_config.snippet.json into your Claude Desktop config (%APPDATA%\Claude\claude_desktop_config.json):

json
{  "mcpServers": {    "google-flights": {      "command": "C:\\dev\\google-flights-mcp-venv\\Scripts\\python.exe",      "args": ["-m", "google_flights_mcp.server"]    }  }}

Restart Claude Desktop after editing. To use SerpApi instead of the default scraper, add an env block:

json
{  "mcpServers": {    "google-flights": {      "command": "C:\\dev\\google-flights-mcp-venv\\Scripts\\python.exe",      "args": ["-m", "google_flights_mcp.server"],      "env": { "SERPAPI_KEY": "your-serpapi-key" }    }  }}

Get a key at serpapi.com (free tier available).

Other env vars: GOOGLE_FLIGHTS_DEFAULT_ORIGIN (default LIS), GOOGLE_FLIGHTS_DEFAULT_CURRENCY (default EUR).

Running over HTTP (for a remote connector)

bash
C:\dev\google-flights-mcp-venv\Scripts\python.exe -m google_flights_mcp.server --http

Or set MCP_TRANSPORT=streamable-http. Configure the bind address with MCP_HOST (default 127.0.0.1) and MCP_PORT (default 8000); the server listens at http://<host>:<port>/mcp. Put this behind whatever reverse proxy / auth you use for your other remote connectors before exposing it beyond localhost.

Smoke test

Real network call (no mocks) — searches LIS → GRU about a month out:

bash
C:\dev\google-flights-mcp-venv\Scripts\python.exe tools\google-flights-mcp\examples\smoke_test.py

Tests

bash
C:\dev\google-flights-mcp-venv\Scripts\python.exe -m pytest tools\google-flights-mcp\tests

These are unit tests against the provider abstraction (factory selection, passenger validation, the shared cheapest_dates day-loop, airport resolution) — no network access required.

来源:README.md,提交 d0d92f2

工具

3

search_flights

Search flight prices and options on Google Flights. Args: destination: Destination airport IATA code (e.g. "GRU"). If you only have a city name, call airport_search first. departure_date: Outbound date, YYYY-MM-DD. origin: Origin airport IATA code. Defaults to Lisbon (LIS) if omitted. return_date: Return date YYYY-MM-DD to search a round trip; omit for one-way. For round trips, each result's price is Google's estimated round-trip total for that outbound flight paired with its cheapest matching return — stops/duration/legs describe the outbound only. Open booking_link to pick the exact return flight. adults: Number of adult passengers (default 1). children: Number of child passengers (default 0). infants: Number of lap infants, under 2 with no own seat (default 0). cabin_class: "economy" | "premium" | "business" | "first". currency: ISO currency code. Defaults to EUR. max_stops: Maximum stops to allow (0 = nonstop only, 1 = up to one stop, etc.). Omit to allow any number of stops. sort_by: "price" (default, ascending) or "duration" (ascending).

输入参数adultsorigininfantssort_bychildrencurrencymax_stopscabin_classdestination必填return_datedeparture_date必填

cheapest_dates

Find the cheapest day(s) to fly within a date window (price-calendar style). Runs one search per candidate departure day in the window (capped at 21 days — neither of this server's data sources expose a real bulk price-calendar endpoint) and returns each day's cheapest fare, sorted by price ascending. Args: destination: Destination airport IATA code. start_date: First candidate departure date, YYYY-MM-DD. end_date: Last candidate departure date, YYYY-MM-DD (inclusive; max 21 days after start_date). origin: Origin airport IATA code. Defaults to Lisbon (LIS). trip_length: Nights for a round trip, applied to every departure day in the window. Omit to price one-way fares. adults, children, infants: Passenger counts (see search_flights). cabin_class: "economy" | "premium" | "business" | "first". currency: ISO currency code. Defaults to EUR. max_stops: Maximum stops to allow. Omit to allow any.

输入参数adultsorigininfantschildrencurrencyend_date必填max_stopsstart_date必填cabin_classdestination必填trip_length

版本历史

1
  1. v0.1.0最新Nov 1, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分