Skip to main content
Glama
mtnrabi

google-flights-mcp

by mtnrabi

Google Flights MCP — 让您的 agent 可以搜索整个日期范围内实时票价的工具,零广告

claude mcp add --transport http google-flights https://google-flights-mcp.flightpowers.com/mcp --header "x-rapidapi-key: YOUR_RAPIDAPI_KEY"

托管服务。无需克隆,无需构建。已列入官方 MCP Registry 中,标识符为 com.flightpowers/google-flights-mcp。健康检查端点:/health

需要 key 吗? 请先在 RapidAPI 上订阅 Google Flights Live API(提供免费额度),然后把您的 x-rapidapi-key 复制下来:https://rapidapi.com/mtnrabi/api/google-flights-live-appi

还没有 key? 先用免费服务器 —— 同样的搜索功能,无需注册: claude mcp add --transport http google_flights-free https://google-flights-lulu.flightpowers.com/mcp (服务由广告赞助:每条结果一条已明示的赞助卡片,扇出上限为 15,且无法渲染商家赞助卡片的客户端可能被进一步限制。)当广告、15 次搜索上限或这些客户端限制阻碍到您的使用体验时,再回到本页。


您的 agent 可具备

它提供的是两个工具,回答价格问题,而不是日期检索

  • 可以进行开放式提问。 比如“十月里去斯里兰卡最便宜的单程票”“5 月某个时间在罗马住 5 到 7 晚,从特拉维夫或拉纳卡出发”—— 每一个都只要一次工具调用。两个工具均接受出发日期范围一个列表的目的地机场,/单向飞行需要固定返程。若有固定返程,也接受 nights 夜晚数,而不是固定返回日,并在服务器内部展开。

  • 直接告诉你价高不高。 每个结果都包含 Google 针对该航线与时段给出的历史价格区间 —— price_insights_lowprice_insights_high,以及一个 price_range_in_relation_to_other_periods 的结论,值为 low / typical / high。正因如此,agent 才能回答“209 美元在此航线属于常态,不要急着订”,而不只是报一个代码。

  • 直接可订票,而不只是浏览。 每个结果都含有一个外部 buy_link 假向 Google Flights 订票页。

  • 可以查看花费。 每一条响应都携带 api_usage,显示本次调用消耗了多少上游请求、计划还剩多少,做到您可按这个报告查看(见费用报告(api_usage)。

  • 知道自己搜索了什么。 每条响应都带 search_coverage,模型可以被“诚实地说:回答是基于哪些日期、目的地得到的”。

注意: 结果是实时票价。差异性只保持几分钟 —— 绝不缓存或复用以往结果;重新搜索时,请注明数据获取的时间。


获取 key(免费版可用)

服务器自身不持有任何上游的凭据。每次搜索都被计入使用 您自己的 RapidAPI 订阅,所以 key 必须随请求一路携带。

  1. 订阅 Google Flights Live API: https://rapidapi.com/mtnab/api/google_flights-live-api>

  2. 复制好您的 api_key(名为 x-rapidapi-key)。

  3. 用下面三种方式中的任意一种,把 key 传给服务器。

如果没有 key,工具也不会静默失败,也不会产生花费 —— 工具直接随结果带 needs_api_key: true 并附注册链接和以上相应提示,好让模型把 peprue 用户。


三种传 key 的方式

方式

示例/操作

什么时候用

Header(推荐)

添加一句请求头:--header "x-rapidapi-key: YOUR_RAPIDAPI_KEY"

凡是允许设 Header 的环境都可用。key 不进入 URL,也就不经过代理和访问日志。

Query 参数

例如 https://google-flights-mcp.flightpower.com/flight?rapidapi_key=YOUR_RAPIDAPI_KEY

只支持填 URL 的托管平台(如 claude.ai 自定义连接器的)时用它。

客户端 API-key 字段

直接粘贴到客户端的“API key”栏

若工具让你在 Host 上加:authorization: Bearer <key>/x-api-key 的,也有人用。Smithery 保存的 config.rapidApiKey= 也识别。

以下规律生效:非空 key 最优先(左边起)。凡是 key 绝对不会进日志、不会在一条错误里被回显,也不会在 supply 结果里返回。


API 工具一览

工具

说明

search_oneway_flights

实时单程票。输入:出发(IATA)、目的地:一字区/列表,和一个出发日期或日期区间;返回票价、航空公司、时长、转机次数、buy_link,以及 Google 的价区(历史价)。最适“单程・开放式”问题,建议一次调用并带上整段区间,而不是一日期一调。

search_roundtrip_flights

实时往返票,以往返双程(paired legs) 计价,而非两个一方。输入:出发地、(或多个目的地)、出发日期或区间;以及 returne_datenights值(数字 or 数列如 [5, 6, 7]);返回:全价、各程航空公司/中转/时间、以及一趟总程的单一 buy_link

search_oneway_flights

search_oneway_flights(
    from_airport: str,                     # origin IATA, e.g. "TLV"
    to_airport: str | list[str],           # destination IATA, or a list to compare
    departure_date: str | None = None,     # "YYYY-MM-DD"
    departure_date_from: str | None = None,# first date of a range
    departure_date_to: str | None = None,  # last date of a range
    max_stops: int | None = None,          # 0 = non-stop only
    airline_codes: list[str] | None = None,
    exclude_airline_codes: list[str] | None = None,
    departure_time_min: int | None = None, # hour, 0-23
    departure_time_max: int | None = None,
    arrival_time_min: int | None = None,
    arrival_time_max: int | None = None,
    currency: str = "usd",
    max_price: int | None = None,
    seat_type: int | None = None,          # 1 economy, 2 premium economy, 3 business, 4 first
    passengers: list[int] | None = None,   # [adults, children, infants]
    sort_by: str = "best",                 # "best" | "price" | "duration"
    limit: int = 10,                       # results returned after merge + sort
    max_searches: int | None = None,       # cap the billed requests this call may make
    use_fallback: bool = False,            # slower, fewer empty results on hard routes
)

search_roundtrip_flights

search_roundtrip_flights(
    from_airport: str,
    to_airport: str | list[str],
    departure_date: str | None = None,
    departure_date_from: str | None = None,
    departure_date_to: str | None = None,
    return_date: str | None = None,        # use this OR nights, not both
    nights: int | list[int] | None = None, # e.g. 7, or [5, 6, 7]
    max_departure_stops: int | None = None,
    max_return_stops: int | None = None,
    departure_airline_codes: list[str] | None = None,
    return_airline_codes: list[str] | None = None,
    currency: str = "usd",
    max_price: int | None = None,
    seat_type: int | None = None,
    passengers: list[int] | None = None,
    sort_by: str = "best",
    limit: int = 10,
    max_searches: int | None = None,
    use_fallback: bool = False,
)

又注意:规则:sort_by 顺序由这一整服务在其已执行的所有搜索结果上进行合并套用,因此有几个组合被扩展其排序都可预期——快。


一个实际示例

用户: “我在特拉维夫,五天——一够一周——去 Cons this. 罗马或雅典的玩,5 月 1..”...

嗯——不多见了 Good Cà确认原文:

用户问题原 p:

“我在特拉维夫。从五月这半个月任意一天出发,去罗马或雅典,求最省的——周往返”

一次:

{
  "name": "search_roundtrip_flights",
  "arguments": {
    "from_airport": "TLV",
    "to_airport": ["FCO", "ATH"],
    "departure_date_from": "2026-05-01",
    "departure_date_to": "2026-05-15",
    "nights": 7,
    "sort_by": "price",
    "limit": 5
  }
}

这组展开为 15 日 × 2 个目的地 =30 组合——恰为本次调用的上限。返回形状(字段真实,下面数仅示意,不是报价,自来之真跑调用):

{
  "results": [
    {
      "from_airport": "Tel Aviv (TLV)",
      "to_airport": "Rome (FCO)",
      "departure_date": "2026-05-05",
      "return_date": "2026-05-12",
      "total_price": "$XXX",
      "total_price_as_number": 0,
      "total_duration_seconds": 0,
      "total_stops": 0,
      "price_range_in_relation_to_other_periods": "low",
      "price_insights_low": 0,
      "price_insights_high": 0,
      "departure_flight_airline": "...",
      "departure_flight_departure_description": "...",
      "departure_flight_arrival_description": "...",
      "departure_flight_duration": "...",
      "departure_flight_stops": 0,
      "departure_stops_info": [],
      "return_flight_airline": "...",
      "return_flight_departure_description": "...",
      "return_flight_arrival_description": "...",
      "return_flight_duration": "...",
      "return_flight_stops": 0,
      "return_stops_info": [],
      "buy_link": "https://www.google.com/travel/flights?tfs=..."
    }
  ],
  "result_count": 5,
  "search_coverage": {
    "requested_combinations": 30,
    "searched_combinations": 30,
    "truncated": false,
    "max_searches_per_request": 30,
    "departure_dates_searched": ["2026-05-01", "..."],
    "destinations_searched": ["ATH", "FCO"]
  },
  "api_usage": {
    "requests_used_by_this_call": 30,
    "plan_requests_remaining": 0,
    "plan_requests_limit": 0,
    "note": "This search used 30 of your RapidAPI plan's requests; ... remain in the current period. Each date and destination combination is one billed request."
  }
}

其余的响应 shape 也常见,全部正常:

  • 这些日期没有班机。 results: [] + message — Google 对极多航线/日结合确实没有任何票;这不是异常。可尝试贴近的日期、附近机场,或设 use_fallback: true

  • 部分搜索失败。 一种 partial 数告诉你 个搜索中失败了几组,结果代表其余。

  • 区间太大。 看到 search_coverage.truncated: truenote —— 就会从整个窗口内均匀抽样(保留首尾),而非取头部 N 天。那样样本能代表全域。当您想容量增加可升 max_searches,或收小听。

  • 没有 key / key 被拒回。 needs_api_key: true(支出零)并说明修复方法。常见:有效 RapidAPI Key 但未订阅此 API。

  • 额度用荆。 quota_exhausted: true 跟随 api_usage,还提「视出度和缩实际日期让剩余数量够用更久」。


用户看的费用(api_usage

费用是您出自己的,因此可见记表条目。每条成功响应都带:

字段

含义

requests_used

这 一次工具调用所耗的 上游计费请求数量。

remaining_quota

本期 RapidAPI 计划还余多少。

quota_limit

你计划这些总数本来就。

note

一句汇总,模型在回答你之前很可以“直接告诉你”

remaining / limit(计费还是上游返回才有,源没返回就跳过)note 也随之显示。模应 应该规则不多说只要你记住了这两句:一个日期 × 一个目的地 = 一次收费请求。

调成本还可以这样微调(从直接到再细):每次调用某 max_searches(数字)上限。缩小日期区间缩短目的地列表 「法由 to max_searches 做首级」


一次调用,干…相当于三十各斩

底层 REST 每次请求只能传一个 (origin,destination,date) 三组,如果用逐 day / 一个地夹就好决策调用的话:方案“最便宜 tore Sri Lanka anywhere October” → 会被拆成 31 独立 sub-task —— 模型也联 31 次询回、有 31 次失良机,而用户要查看自己信用卡以后可能才发现账单多少钱。

现在是一次调用。扇出电话在私侧服务器端分配给全国、实时负载、有上限、均匀抽样、buy_link 去重、合并、按您 sort_by 排序。并会在 完成后把整个目录以 search_coverageapi_usage 上报。

本服务(Paid)

免费服务器

每次调用 扇出上限

30(硬上限 60;可在每次传 max_searches 调高/调低)

15

广告

每一条带卡为广告

key

要带上自己的 RapidAPI key

无需

上报使用

每请求都 api_usage

n/a

能被目录收录

本服务器不含任何广告。:这不像是“品味差”,而受平台规则入—— Anthropic 的商业模式和 OpenAI 的应用商店工具政策都禁在工具结果里的第三方广告;一个广告服务器可靠又可笑;而后面的可被列。


本地开发

git clone <this repo> && cd mcp_server_paid
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
cp example.env .env          # fill it in; leave RAPIDAPI_KEY empty
set -a && . .env && set +a
.venv/bin/python -m src      # streamable HTTP on http://localhost:8000/mcp

设备本地进程就这么连:

claude mcp add --transport http google-flights-local http://localhost:8000/mcp --header "x-rapidapi-key: YOUR_RAPIDAPI_KEY"

cts(124 条用例通过,已验):

.venv/bin/python -m pytest -q

全部配置都在 example.env;每个都不解释。关注重点:

变量

默认值

为什么重要

MAX_SEARCHES_PER_TOOL_CALL

30

每次调用的扇出上限。硬性上限为 60。

MAX_CONCURRENT_SEARCHES

10

扇出的并发度。

MAX_HTTP_CONNECTIONS

60

连接池上限;serverless 实例共享文件描述符池。

REQUEST_TIMEOUT_SECONDS

105

与上游上限一致,因此本端绝不会先超时。

DEFAULT_RESULT_LIMIT

10

每次独立上游搜索请求返回的结果数量。

SIGNUP_URL

RapidAPI listing

未携带 key 的用户访问时,将该 URL 原样返回作为提示。

MCP_PUBLIC_URL

http://localhost:8000/mcp

/health 报告。

RAPIDAPI_KEY

(空)

生产环境中请保持为空。 如果设置了该值,那么每个无 key 的调用方都会由该订阅提供服务,并将其费用计入该订阅。服务器在启动时会记录警告,而 /health 会报告 server_side_key_configured

METRICS_TOKEN

(空)

设置后,/metrics 会要求提供 x-metrics-token 请求头。

LOG_PATH

(空)

为空时禁用文件输出;stdout 上的 MCP_CALL 行仍然保留为记录。在 serverless 环境下这是正确的。

操作路由:GET /health(公开、无需认证——注册中心会轮询它)、GET /metricsGET /metrics/calls?hours=24

部署目标是 Vercel,通过 api/index.py(一个 FastAPI 包装器,向 FastMCP 传入其 lifespan,并设置 stateless_http=True)部署。标准的 MCP 路径为 /mcp不能带尾部斜杠

绝不要提交真实密钥。example.env 附带的是占位符;请务必保持这样。

非关联声明

这是一个返回公开航班定价的独立 API。它与 Google 无关联、未经其认可或赞助。仅使用“Google Flights”来描述该公共数据源。票价由上游提供并提供,且随时变动,且不保证有效——购买前请务必在航空公司或预订网站上确认最终价格。

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Flight Intelligence MCP — search, cheapest dates, multi-city, airline compare via Google Flights

  • Live flight prices and working booking links for AI agents and travel apps.

  • Free, no-login flight search with real-time pricing from multiple airlines.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mtnrabi/google-flights-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server