hasdata-google-flights-mcp 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hasdata_google_flights_mcp-1.0.0/.github/ISSUE_TEMPLATE/inaccuracy.md +21 -0
- hasdata_google_flights_mcp-1.0.0/.github/workflows/contract.yml +31 -0
- hasdata_google_flights_mcp-1.0.0/.github/workflows/publish.yml +65 -0
- hasdata_google_flights_mcp-1.0.0/.gitignore +11 -0
- hasdata_google_flights_mcp-1.0.0/LICENSE +21 -0
- hasdata_google_flights_mcp-1.0.0/PKG-INFO +362 -0
- hasdata_google_flights_mcp-1.0.0/README.md +348 -0
- hasdata_google_flights_mcp-1.0.0/glama.json +7 -0
- hasdata_google_flights_mcp-1.0.0/hasdata_google_flights_mcp/__init__.py +28 -0
- hasdata_google_flights_mcp-1.0.0/index.mjs +24 -0
- hasdata_google_flights_mcp-1.0.0/package.json +16 -0
- hasdata_google_flights_mcp-1.0.0/pyproject.toml +24 -0
- hasdata_google_flights_mcp-1.0.0/server.json +44 -0
- hasdata_google_flights_mcp-1.0.0/test/tools.test.mjs +137 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Something in the README is wrong
|
|
3
|
+
about: A tool table, a response sample or a documented behaviour does not match reality
|
|
4
|
+
labels: documentation
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Where in the README**
|
|
8
|
+
|
|
9
|
+
Section or heading.
|
|
10
|
+
|
|
11
|
+
**What it says**
|
|
12
|
+
|
|
13
|
+
Quote the line.
|
|
14
|
+
|
|
15
|
+
**The call you made**
|
|
16
|
+
|
|
17
|
+
Tool name and arguments, or the equivalent REST URL with your key removed.
|
|
18
|
+
|
|
19
|
+
**What came back**
|
|
20
|
+
|
|
21
|
+
Trimmed response, with anything private removed.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# The tool contract is checked on a schedule as well as on push, because the upstream tool list
|
|
2
|
+
# can change without a single commit in this repository.
|
|
3
|
+
name: tool contract
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
pull_request:
|
|
9
|
+
schedule:
|
|
10
|
+
- cron: '0 6 * * 1'
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
contract:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
timeout-minutes: 5
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: '22'
|
|
25
|
+
# Forks cannot read repository secrets. The suite skips its live checks when the key is
|
|
26
|
+
# absent, so a pull request from a fork stays green instead of failing for a reason the
|
|
27
|
+
# contributor cannot fix.
|
|
28
|
+
- name: Assert the tool list still matches the README
|
|
29
|
+
env:
|
|
30
|
+
HASDATA_API_KEY: ${{ secrets.HASDATA_API_KEY }}
|
|
31
|
+
run: npm test
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Publishes the npm and PyPI wrapper packages on a version tag, using OIDC
|
|
2
|
+
# trusted publishing. No NPM_TOKEN or PYPI_TOKEN is stored anywhere: GitHub
|
|
3
|
+
# mints a short-lived OIDC token per run, and npmjs.org / pypi.org accept it
|
|
4
|
+
# because this repo + workflow are configured as trusted publishers.
|
|
5
|
+
#
|
|
6
|
+
# One-time setup, done once per package on the registries (not in this repo):
|
|
7
|
+
# npmjs.org -> package settings -> Trusted Publisher -> GitHub Actions,
|
|
8
|
+
# repo HasData/google-flights-mcp, workflow publish.yml
|
|
9
|
+
# pypi.org -> the hasdata org -> Publishing -> add a trusted publisher
|
|
10
|
+
# (pending publisher works before the first release),
|
|
11
|
+
# repo HasData/google-flights-mcp, workflow publish.yml
|
|
12
|
+
#
|
|
13
|
+
# The MCP registry entry (com.hasdata/google-flights) is NOT published here. It uses
|
|
14
|
+
# domain auth, which would need the namespace-wide Ed25519 key as a secret in
|
|
15
|
+
# every repo. That key stays off CI; the registry entry is published by hand
|
|
16
|
+
# when server.json changes, after the package versions below are live.
|
|
17
|
+
#
|
|
18
|
+
# Release: bump nothing by hand. Tag the commit `vX.Y.Z` and push the tag; the
|
|
19
|
+
# tag is the single source of the version and is written into both manifests.
|
|
20
|
+
|
|
21
|
+
name: publish
|
|
22
|
+
|
|
23
|
+
on:
|
|
24
|
+
push:
|
|
25
|
+
tags: ['v*.*.*']
|
|
26
|
+
|
|
27
|
+
permissions:
|
|
28
|
+
contents: read
|
|
29
|
+
id-token: write
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
npm:
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: actions/setup-node@v4
|
|
37
|
+
with:
|
|
38
|
+
node-version: '22'
|
|
39
|
+
registry-url: 'https://registry.npmjs.org'
|
|
40
|
+
- name: Set version from the tag
|
|
41
|
+
run: npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version --allow-same-version
|
|
42
|
+
- name: Publish to npm (OIDC, no token)
|
|
43
|
+
run: npm publish --access public
|
|
44
|
+
|
|
45
|
+
pypi:
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
- uses: actions/setup-python@v5
|
|
50
|
+
with:
|
|
51
|
+
python-version: '3.12'
|
|
52
|
+
- name: Set version from the tag
|
|
53
|
+
run: |
|
|
54
|
+
python - "${GITHUB_REF_NAME#v}" <<'PY'
|
|
55
|
+
import re, sys
|
|
56
|
+
v = sys.argv[1]
|
|
57
|
+
p = "pyproject.toml"
|
|
58
|
+
t = open(p, encoding="utf-8").read()
|
|
59
|
+
t = re.sub(r'(?m)^version = ".*"$', f'version = "{v}"', t, count=1)
|
|
60
|
+
open(p, "w", encoding="utf-8", newline="\n").write(t)
|
|
61
|
+
PY
|
|
62
|
+
- name: Build the wheel and sdist
|
|
63
|
+
run: pipx run build
|
|
64
|
+
- name: Publish to PyPI (OIDC, no token)
|
|
65
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HasData
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: hasdata-google-flights-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: MCP server for Google Flights through HasData's hosted API. No Google account.
|
|
5
|
+
Project-URL: Homepage, https://hasdata.com/apis/google-flights-api
|
|
6
|
+
Project-URL: Repository, https://github.com/HasData/google-flights-mcp
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: flights,google-flights,hasdata,mcp,model-context-protocol,travel
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Requires-Dist: mcp-proxy>=0.12.0
|
|
12
|
+
Requires-Dist: mcp<2,>=1.17
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# Google Flights MCP Server
|
|
16
|
+
|
|
17
|
+
<!-- mcp-name: com.hasdata/google-flights -->
|
|
18
|
+
|
|
19
|
+
A hosted Model Context Protocol (MCP) server that gives Claude, Cursor, Windsurf and any other MCP client one Google Flights tool. Search one-way, round-trip and multi-city itineraries with fares, flight legs, carbon emissions and price history, all as structured JSON, with no Google account and no retired travel API to work around.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
https://mcp.hasdata.com/api/mcp?apis=google_travel_flights
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
[](https://glama.ai/mcp/servers/HasData/google-flights-mcp)
|
|
26
|
+
[](https://github.com/HasData/google-flights-mcp/actions/workflows/contract.yml)
|
|
27
|
+
[](https://modelcontextprotocol.io)
|
|
28
|
+
[](#tools)
|
|
29
|
+
[](LICENSE)
|
|
30
|
+
|
|
31
|
+
## Contents
|
|
32
|
+
|
|
33
|
+
- [What you need](#what-you-need)
|
|
34
|
+
- [Quick start](#quick-start)
|
|
35
|
+
- [Example prompts](#example-prompts)
|
|
36
|
+
- [Tools](#tools)
|
|
37
|
+
- [Errors and failure paths](#errors-and-failure-paths)
|
|
38
|
+
- [Pricing, free tier and limits](#pricing-free-tier-and-limits)
|
|
39
|
+
- [Tool selection](#tool-selection)
|
|
40
|
+
- [How it compares](#how-it-compares)
|
|
41
|
+
- [FAQ](#faq)
|
|
42
|
+
- [HasData links](#hasdata-links)
|
|
43
|
+
- [Development](#development)
|
|
44
|
+
- [Contributing](#contributing)
|
|
45
|
+
- [License](#license)
|
|
46
|
+
|
|
47
|
+
## What you need
|
|
48
|
+
|
|
49
|
+
An MCP client and a HasData API key from the [dashboard](https://app.hasdata.com/sign-up?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp), free to create with no card, and the trial covers about 66 calls at the 15-credit rate. This is a remote server, so the simplest path is a URL and an `x-api-key` header, with no container to run and no Google account anywhere in the flow. A client that only speaks stdio reaches it through a thin launcher, published as `@hasdata/google-flights-mcp` on npm and `hasdata-google-flights-mcp` on PyPI, shown below.
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
The server URL is the same for every client. We run it hands-on in Claude Code and Claude Desktop. The other blocks follow each client's own documented format for a remote server.
|
|
54
|
+
|
|
55
|
+
| Field | Value |
|
|
56
|
+
| :--- | :--- |
|
|
57
|
+
| URL | `https://mcp.hasdata.com/api/mcp?apis=google_travel_flights` |
|
|
58
|
+
| Transport | HTTP, streamable |
|
|
59
|
+
| Auth header | `x-api-key: HASDATA_API_KEY` |
|
|
60
|
+
|
|
61
|
+
Clients with OAuth support can add the same URL as a connector and sign in without putting a key in a config file.
|
|
62
|
+
|
|
63
|
+
<details>
|
|
64
|
+
<summary><b>Claude Code</b></summary>
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
claude mcp add --transport http google-flights "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights" \
|
|
68
|
+
--header "x-api-key: HASDATA_API_KEY"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
<details>
|
|
74
|
+
<summary><b>Claude Desktop</b></summary>
|
|
75
|
+
|
|
76
|
+
Settings, then Connectors, then Add custom connector, then paste `https://mcp.hasdata.com/api/mcp?apis=google_travel_flights` and sign in.
|
|
77
|
+
|
|
78
|
+
For the config-file route, Claude Desktop loads only local (stdio) servers, so it reaches a remote server through a stdio launcher. The `@hasdata/google-flights-mcp` package is that launcher, and it reads the key from the environment. Add this to `claude_desktop_config.json`:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"google-flights": {
|
|
84
|
+
"command": "npx",
|
|
85
|
+
"args": ["-y", "@hasdata/google-flights-mcp"],
|
|
86
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For Python instead of Node, swap the launcher for the PyPI package, which `uvx` runs without a manual install:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"mcpServers": {
|
|
97
|
+
"google-flights": {
|
|
98
|
+
"command": "uvx",
|
|
99
|
+
"args": ["hasdata-google-flights-mcp"],
|
|
100
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary><b>Cursor</b></summary>
|
|
110
|
+
|
|
111
|
+
`~/.cursor/mcp.json` for every project, or `.cursor/mcp.json` for one:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"mcpServers": {
|
|
116
|
+
"google-flights": {
|
|
117
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights",
|
|
118
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
</details>
|
|
125
|
+
|
|
126
|
+
<details>
|
|
127
|
+
<summary><b>Windsurf</b></summary>
|
|
128
|
+
|
|
129
|
+
`~/.codeium/windsurf/mcp_config.json`. Windsurf calls the field `serverUrl`, not `url`:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"google-flights": {
|
|
135
|
+
"serverUrl": "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights",
|
|
136
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
</details>
|
|
143
|
+
|
|
144
|
+
<details>
|
|
145
|
+
<summary><b>VS Code</b></summary>
|
|
146
|
+
|
|
147
|
+
`.vscode/mcp.json` in the workspace:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"servers": {
|
|
152
|
+
"google-flights": {
|
|
153
|
+
"type": "http",
|
|
154
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights",
|
|
155
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
</details>
|
|
162
|
+
|
|
163
|
+
## Example prompts
|
|
164
|
+
|
|
165
|
+
Prompts, not code. Paste one in and the agent picks the tool itself. Each is annotated with the calls it takes, because every successful call costs 15 credits.
|
|
166
|
+
|
|
167
|
+
> Find one-way flights from JFK to London Heathrow on September 15, sorted by price, and give me the three cheapest with airline and carbon estimate.
|
|
168
|
+
|
|
169
|
+
*One call, 15 credits. Fares, legs and emissions all come back together.*
|
|
170
|
+
|
|
171
|
+
> Same route but non-stop only, in business class, and tell me which option has the lowest emissions.
|
|
172
|
+
|
|
173
|
+
*One call, 15 credits. Cabin and stops are filters on the one request.*
|
|
174
|
+
|
|
175
|
+
> Is $295 a good price for JFK to LHR right now, given the price history?
|
|
176
|
+
|
|
177
|
+
*One call, 15 credits. The response carries `priceInsights` with a typical range and a price level.*
|
|
178
|
+
|
|
179
|
+
> Round trip JFK to LHR, out September 15 back September 22, cheapest fare.
|
|
180
|
+
|
|
181
|
+
*Two calls, 30 credits. Google returns outbound options first, then the return leg is a second call keyed by the option you pick.*
|
|
182
|
+
|
|
183
|
+
A round trip is two calls by design. The first returns outbound itineraries each with a `departureToken`, and you pass that token back to get the matching return flights. One-way and the price check are a single call each.
|
|
184
|
+
|
|
185
|
+
## Tools
|
|
186
|
+
|
|
187
|
+
One tool, read-only. The sample below is trimmed from a real call, and fares move constantly. Read it as a shape. The tool name links to its endpoint reference, which carries the full parameter list.
|
|
188
|
+
|
|
189
|
+
The sample is the payload, not the whole response. A `tools/call` result carries one text block, and that text is itself JSON holding `url`, `status`, `text` and `json`, with the scraped data under `json`. From a raw JSON-RPC response the path is `result.content[0].text`, parsed, then `.json`. A chat client unwraps that for you and code talking to the endpoint directly does not.
|
|
190
|
+
|
|
191
|
+
### Get Google Flights results
|
|
192
|
+
|
|
193
|
+
[`hasdata_google_travel_flights_getGoogleFlights`](https://docs.hasdata.com/apis/google-travel/flights?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp)
|
|
194
|
+
|
|
195
|
+
Itineraries for a route and date, with fares, legs, emissions and price history.
|
|
196
|
+
|
|
197
|
+
| Parameter | Type | Required | Notes |
|
|
198
|
+
| :--- | :--- | :--- | :--- |
|
|
199
|
+
| `departureId` | string | yes | IATA code such as `JFK`, or a location kgmid like `/m/02_286`. Comma-separate several airports |
|
|
200
|
+
| `arrivalId` | string | yes | Same format as `departureId` |
|
|
201
|
+
| `outboundDate` | string | yes | `YYYY-MM-DD` |
|
|
202
|
+
| `type` | string | | `roundTrip` by default, `oneWay`, or `multiCity` with `multiCityJson` |
|
|
203
|
+
| `returnDate` | string | | Required when `type` is `roundTrip` |
|
|
204
|
+
| `travelClass` | string | | `economy`, `premiumEconomy`, `business` or `first` |
|
|
205
|
+
| `stops` | string | | `nonStop`, `oneStopOrFewer` or `twoStopsOrFewer` |
|
|
206
|
+
| `sortBy` | string | | `topFlights` default, plus `price`, `duration`, `emissions`, `departureTime`, `arrivalTime` |
|
|
207
|
+
| `adults` / `children` / `infantsInSeat` / `infantsOnLap` | number | | Passenger mix |
|
|
208
|
+
| `maxPrice` / `maxDuration` / `bags` | number | | Ceilings and carry-on count |
|
|
209
|
+
| `includeAirlines` / `excludeAirlines` | string | | Comma-separated IATA airline codes, one or the other, not both |
|
|
210
|
+
| `departureToken` | string | | Select an outbound option and fetch its return or next leg |
|
|
211
|
+
| `bookingToken` | string | | Fetch booking options for a chosen itinerary |
|
|
212
|
+
| `currency` / `gl` / `hl` | string | | Currency and the country and language of the search |
|
|
213
|
+
| `deepSearch` | boolean | | Match what Google shows in a browser, slower to return |
|
|
214
|
+
|
|
215
|
+
The reference also documents `includeConnections`, `excludeConnections`, `layoverDuration`, `outboundTimes`, `returnTimes`, `showHidden`, `lessEmissions` and `multiCityJson`.
|
|
216
|
+
|
|
217
|
+
Results split into `bestFlights` and `otherFlights`. Each itinerary carries `price`, `type`, `totalDuration` in minutes, a `flights` array of legs, a `carbonEmissions` object, and a `bookingToken`. Each leg holds the `departureAirport` and `arrivalAirport` (each with `id`, `name` and local `time`), `duration`, `airline`, `flightNumber`, `airplane`, `legroom`, `travelClass`, an `extensions` array, and `oftenDelayedByOver30Min` on legs Google flags. A non-stop itinerary has one leg, a connection has several.
|
|
218
|
+
|
|
219
|
+
> `carbonEmissions` is in grams, not kilograms. `thisFlight: 433000` is 433 kg. `differencePercent` compares it to `typicalForThisRoute`, so a negative number is a greener-than-average flight.
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"price": 295,
|
|
224
|
+
"type": "One way",
|
|
225
|
+
"totalDuration": 415,
|
|
226
|
+
"flights": [
|
|
227
|
+
{
|
|
228
|
+
"departureAirport": { "id": "JFK", "name": "John F. Kennedy International Airport", "time": "2026-09-15 8:15" },
|
|
229
|
+
"arrivalAirport": { "id": "LHR", "name": "Heathrow Airport", "time": "2026-09-15 20:10" },
|
|
230
|
+
"duration": 415,
|
|
231
|
+
"airline": "Virgin Atlantic",
|
|
232
|
+
"flightNumber": "VS 26",
|
|
233
|
+
"airplane": "Boeing 787",
|
|
234
|
+
"travelClass": "Economy"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
"carbonEmissions": { "thisFlight": 367000, "typicalForThisRoute": 419000, "differencePercent": -12 },
|
|
238
|
+
"bookingToken": "W1t7..."
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
`priceInsights` sits alongside the itineraries with `lowestPrice`, a `typicalPriceRange`, a `priceLevel` such as `typical`, and a `priceHistory` of `[timestamp, price]` points. `airports` echoes the resolved departure and arrival airports with city and country.
|
|
243
|
+
|
|
244
|
+
## Errors and failure paths
|
|
245
|
+
|
|
246
|
+
Your client almost never sees an HTTP error code from a tool call. The MCP layer answers 200 and puts the failure inside the result, with `isError` set to `true` and the reason as text. The agent reads a message where you might expect a status line.
|
|
247
|
+
|
|
248
|
+
**A wrong key surfaces as tool output, not as a failed connection.** `tools/list` accepts any non-empty key and returns the tool, so the client completes its handshake and shows green. The first tool call then comes back with `isError: true` and the text `HasData API error: 401 Unauthorized`. Watch for that string, because nothing earlier in the flow reports the problem.
|
|
249
|
+
|
|
250
|
+
**A missing key is the one real HTTP error.** Authorization runs before any tool, and the connection itself fails with 401. CORS headers are present, and a browser client reads the status and not an opaque network failure.
|
|
251
|
+
|
|
252
|
+
**An argument that breaks the tool's schema is rejected before it becomes a scrape.** The server answers with `isError: true` and the text `MCP error -32602: Input validation error`, naming the offending field. A `roundTrip` without a `returnDate`, or `includeAirlines` together with `excludeAirlines`, is caught here.
|
|
253
|
+
|
|
254
|
+
**A route with no flights on the date returns a successful result with the itinerary arrays empty**, not an error. `requestMetadata.status` still reads `ok`. Test for the flights before you rank them.
|
|
255
|
+
|
|
256
|
+
**A bad airport code returns 400** with `requestMetadata.status` set to `error`. Use IATA codes or kgmids, not city names.
|
|
257
|
+
|
|
258
|
+
Results that carry data also carry a `requestMetadata.id` worth quoting in support.
|
|
259
|
+
|
|
260
|
+
## Pricing, free tier and limits
|
|
261
|
+
|
|
262
|
+
Every Google Flights call costs **15 credits per successful call**. Response size does not change the price, and the deep search costs the same as a standard one.
|
|
263
|
+
|
|
264
|
+
The free trial is **1,000 credits over 30 days with no card**, which is about 66 flight searches. After that an active account keeps getting 100 credits topped up each day whenever its balance drops below 100, so a low-volume agent runs on the free tier indefinitely.
|
|
265
|
+
|
|
266
|
+
Paid plans start at **$49 a month** for 200,000 credits, which is about 13,000 searches. The unit price falls with volume, from **$3.68 per 1,000 calls** on the entry plan to **$1.49** on Business, **$1.25** on Growth and **$1.12** on the largest [high-volume plans](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp).
|
|
267
|
+
|
|
268
|
+
Your plan also sets concurrency. The free trial allows 1 request at a time, Startup 15, Business 30, Growth 50, and the high-volume plans run from 200 to 1,500. Handle the overflow case defensively in anything unattended.
|
|
269
|
+
|
|
270
|
+
A request that comes back non-200 is not billed. A round trip is two calls, so budget for it.
|
|
271
|
+
|
|
272
|
+
## Tool selection
|
|
273
|
+
|
|
274
|
+
The `apis` query parameter decides which tools your agent sees. Fewer tools means less context spent on tool definitions, and fewer chances for the model to reach for the wrong one.
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
?apis=google_travel_flights the one tool in this repo
|
|
278
|
+
?apis=google_travel add Google Hotels
|
|
279
|
+
?apis=google_travel_flights,airbnb flights plus Airbnb stays
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The parameter takes provider names like `google_travel` and individual API names like `google_travel_flights`. Misspelled names are ignored. If every name is wrong the request fails with 400, and the body lists both what it did not recognise and every valid value. Drop the parameter and the same endpoint exposes all 57 HasData tools.
|
|
283
|
+
|
|
284
|
+
## How it compares
|
|
285
|
+
|
|
286
|
+
Google retired its QPX Express flight API in 2018 and never replaced it, so there is no official Google Flights API. The remaining routes are scraping the public results or licensing raw GDS fare data, which is heavy and expensive. This server reads the same results the site shows and returns them as JSON.
|
|
287
|
+
|
|
288
|
+
| | Official Google API | This server |
|
|
289
|
+
| :--- | :--- | :--- |
|
|
290
|
+
| Availability | None since QPX Express closed in 2018 | Maintained schema over the live results |
|
|
291
|
+
| Emissions data | Not offered | Per-itinerary, compared to the route average |
|
|
292
|
+
| Price history | Not offered | `priceInsights` with a typical range |
|
|
293
|
+
| Setup | Nothing to set up, because it does not exist | One key and one URL |
|
|
294
|
+
| Cost | Not applicable | Paid past the trial, 15 credits a call |
|
|
295
|
+
|
|
296
|
+
**What this server does not do.** No booking and no payment. It reads fares, legs and the tokens Google itself uses to move to booking, and hands the booking step back to you.
|
|
297
|
+
|
|
298
|
+
## FAQ
|
|
299
|
+
|
|
300
|
+
### Is there an official Google Flights API?
|
|
301
|
+
|
|
302
|
+
No. Google closed QPX Express in 2018 and has not shipped a replacement. Every option reads the same public results the website serves. This one is maintained by HasData and returns them as structured JSON.
|
|
303
|
+
|
|
304
|
+
### What is a Google Flights MCP server?
|
|
305
|
+
|
|
306
|
+
A server that exposes Google Flights as a tool an AI client can call. The client sends a tool call over the Model Context Protocol, the server fetches the itineraries and returns structured JSON, and the model works with the result. This one exposes a single tool and runs remotely.
|
|
307
|
+
|
|
308
|
+
### Why is a round trip two calls?
|
|
309
|
+
|
|
310
|
+
Google returns outbound options first, each with a `departureToken`. You pick one and pass its token back to get the return flights that pair with it. That mirrors how the site works, and it is why a round trip costs 30 credits.
|
|
311
|
+
|
|
312
|
+
### Are the carbon numbers in kilograms?
|
|
313
|
+
|
|
314
|
+
No, grams. `thisFlight: 433000` means 433 kg, and `differencePercent` compares it to the route average.
|
|
315
|
+
|
|
316
|
+
### What is deep search?
|
|
317
|
+
|
|
318
|
+
A slower mode that returns exactly what Google Flights shows in a browser. Leave it off for speed, turn it on when you need parity with the site.
|
|
319
|
+
|
|
320
|
+
### Can I use this together with other HasData APIs?
|
|
321
|
+
|
|
322
|
+
Yes. The `apis` parameter takes a list, and `?apis=google_travel` adds Google Hotels alongside flights. [Drop the parameter](#tool-selection) and you get everything.
|
|
323
|
+
|
|
324
|
+
### Compliance and personal data
|
|
325
|
+
|
|
326
|
+
HasData accesses publicly available data only. A platform's terms may restrict automated access, and you are responsible for your own compliance.
|
|
327
|
+
|
|
328
|
+
## HasData links
|
|
329
|
+
|
|
330
|
+
| | |
|
|
331
|
+
| :--- | :--- |
|
|
332
|
+
| Product page and request builder | [Google Flights API](https://hasdata.com/apis/google-flights-api?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
333
|
+
| Server documentation | [MCP server docs](https://docs.hasdata.com/mcp-server?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
334
|
+
| All 57 tools in one server | [HasData/hasdata-mcp](https://github.com/HasData/hasdata-mcp) |
|
|
335
|
+
| Client walkthroughs | [MCP clients and integrations](https://hasdata.com/integrations/mcp?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
336
|
+
| Everything else we scrape | [Google Flights API and 54 more](https://hasdata.com/apis/?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
337
|
+
| Plans and credit costs | [Plans and credit costs](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
338
|
+
| Keys and usage | [HasData dashboard](https://app.hasdata.com?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
339
|
+
|
|
340
|
+
## Development
|
|
341
|
+
|
|
342
|
+
This repository is configuration and documentation for a remote server. There is no build step and nothing to containerize.
|
|
343
|
+
|
|
344
|
+
The tests in `test/` assert the tool contract, the part that can break without a commit here. They check that `?apis=google_travel_flights` returns exactly one tool, that it still declares its required parameters, that the name has not changed, and that the key in use is actually accepted. That last check calls the tool for real and costs 15 credits, which is the price of a canary that can fail for the right reason.
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# macOS and Linux
|
|
348
|
+
HASDATA_API_KEY=your_key_here npm test
|
|
349
|
+
|
|
350
|
+
# Windows PowerShell
|
|
351
|
+
$env:HASDATA_API_KEY="your_key_here"; npm test
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
The same suite runs in CI on every push and once a week on a schedule, because the upstream tool list can change without anyone touching this repository. A failure means the tool list moved, the key stopped working, or the endpoint was unreachable, and the assertion message says which.
|
|
355
|
+
|
|
356
|
+
## Contributing
|
|
357
|
+
|
|
358
|
+
Corrections to the parameter table and the response sample are the most useful contribution, because those are the parts that drift. Include the call you made and the response you got. Pull requests from forks run the suite without a key, and the live checks skip instead of going red.
|
|
359
|
+
|
|
360
|
+
## License
|
|
361
|
+
|
|
362
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
# Google Flights MCP Server
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: com.hasdata/google-flights -->
|
|
4
|
+
|
|
5
|
+
A hosted Model Context Protocol (MCP) server that gives Claude, Cursor, Windsurf and any other MCP client one Google Flights tool. Search one-way, round-trip and multi-city itineraries with fares, flight legs, carbon emissions and price history, all as structured JSON, with no Google account and no retired travel API to work around.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
https://mcp.hasdata.com/api/mcp?apis=google_travel_flights
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
[](https://glama.ai/mcp/servers/HasData/google-flights-mcp)
|
|
12
|
+
[](https://github.com/HasData/google-flights-mcp/actions/workflows/contract.yml)
|
|
13
|
+
[](https://modelcontextprotocol.io)
|
|
14
|
+
[](#tools)
|
|
15
|
+
[](LICENSE)
|
|
16
|
+
|
|
17
|
+
## Contents
|
|
18
|
+
|
|
19
|
+
- [What you need](#what-you-need)
|
|
20
|
+
- [Quick start](#quick-start)
|
|
21
|
+
- [Example prompts](#example-prompts)
|
|
22
|
+
- [Tools](#tools)
|
|
23
|
+
- [Errors and failure paths](#errors-and-failure-paths)
|
|
24
|
+
- [Pricing, free tier and limits](#pricing-free-tier-and-limits)
|
|
25
|
+
- [Tool selection](#tool-selection)
|
|
26
|
+
- [How it compares](#how-it-compares)
|
|
27
|
+
- [FAQ](#faq)
|
|
28
|
+
- [HasData links](#hasdata-links)
|
|
29
|
+
- [Development](#development)
|
|
30
|
+
- [Contributing](#contributing)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
|
|
33
|
+
## What you need
|
|
34
|
+
|
|
35
|
+
An MCP client and a HasData API key from the [dashboard](https://app.hasdata.com/sign-up?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp), free to create with no card, and the trial covers about 66 calls at the 15-credit rate. This is a remote server, so the simplest path is a URL and an `x-api-key` header, with no container to run and no Google account anywhere in the flow. A client that only speaks stdio reaches it through a thin launcher, published as `@hasdata/google-flights-mcp` on npm and `hasdata-google-flights-mcp` on PyPI, shown below.
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
The server URL is the same for every client. We run it hands-on in Claude Code and Claude Desktop. The other blocks follow each client's own documented format for a remote server.
|
|
40
|
+
|
|
41
|
+
| Field | Value |
|
|
42
|
+
| :--- | :--- |
|
|
43
|
+
| URL | `https://mcp.hasdata.com/api/mcp?apis=google_travel_flights` |
|
|
44
|
+
| Transport | HTTP, streamable |
|
|
45
|
+
| Auth header | `x-api-key: HASDATA_API_KEY` |
|
|
46
|
+
|
|
47
|
+
Clients with OAuth support can add the same URL as a connector and sign in without putting a key in a config file.
|
|
48
|
+
|
|
49
|
+
<details>
|
|
50
|
+
<summary><b>Claude Code</b></summary>
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
claude mcp add --transport http google-flights "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights" \
|
|
54
|
+
--header "x-api-key: HASDATA_API_KEY"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
<details>
|
|
60
|
+
<summary><b>Claude Desktop</b></summary>
|
|
61
|
+
|
|
62
|
+
Settings, then Connectors, then Add custom connector, then paste `https://mcp.hasdata.com/api/mcp?apis=google_travel_flights` and sign in.
|
|
63
|
+
|
|
64
|
+
For the config-file route, Claude Desktop loads only local (stdio) servers, so it reaches a remote server through a stdio launcher. The `@hasdata/google-flights-mcp` package is that launcher, and it reads the key from the environment. Add this to `claude_desktop_config.json`:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"google-flights": {
|
|
70
|
+
"command": "npx",
|
|
71
|
+
"args": ["-y", "@hasdata/google-flights-mcp"],
|
|
72
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For Python instead of Node, swap the launcher for the PyPI package, which `uvx` runs without a manual install:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"google-flights": {
|
|
84
|
+
"command": "uvx",
|
|
85
|
+
"args": ["hasdata-google-flights-mcp"],
|
|
86
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
</details>
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary><b>Cursor</b></summary>
|
|
96
|
+
|
|
97
|
+
`~/.cursor/mcp.json` for every project, or `.cursor/mcp.json` for one:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"mcpServers": {
|
|
102
|
+
"google-flights": {
|
|
103
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights",
|
|
104
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
</details>
|
|
111
|
+
|
|
112
|
+
<details>
|
|
113
|
+
<summary><b>Windsurf</b></summary>
|
|
114
|
+
|
|
115
|
+
`~/.codeium/windsurf/mcp_config.json`. Windsurf calls the field `serverUrl`, not `url`:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"google-flights": {
|
|
121
|
+
"serverUrl": "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights",
|
|
122
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
</details>
|
|
129
|
+
|
|
130
|
+
<details>
|
|
131
|
+
<summary><b>VS Code</b></summary>
|
|
132
|
+
|
|
133
|
+
`.vscode/mcp.json` in the workspace:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"servers": {
|
|
138
|
+
"google-flights": {
|
|
139
|
+
"type": "http",
|
|
140
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights",
|
|
141
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
</details>
|
|
148
|
+
|
|
149
|
+
## Example prompts
|
|
150
|
+
|
|
151
|
+
Prompts, not code. Paste one in and the agent picks the tool itself. Each is annotated with the calls it takes, because every successful call costs 15 credits.
|
|
152
|
+
|
|
153
|
+
> Find one-way flights from JFK to London Heathrow on September 15, sorted by price, and give me the three cheapest with airline and carbon estimate.
|
|
154
|
+
|
|
155
|
+
*One call, 15 credits. Fares, legs and emissions all come back together.*
|
|
156
|
+
|
|
157
|
+
> Same route but non-stop only, in business class, and tell me which option has the lowest emissions.
|
|
158
|
+
|
|
159
|
+
*One call, 15 credits. Cabin and stops are filters on the one request.*
|
|
160
|
+
|
|
161
|
+
> Is $295 a good price for JFK to LHR right now, given the price history?
|
|
162
|
+
|
|
163
|
+
*One call, 15 credits. The response carries `priceInsights` with a typical range and a price level.*
|
|
164
|
+
|
|
165
|
+
> Round trip JFK to LHR, out September 15 back September 22, cheapest fare.
|
|
166
|
+
|
|
167
|
+
*Two calls, 30 credits. Google returns outbound options first, then the return leg is a second call keyed by the option you pick.*
|
|
168
|
+
|
|
169
|
+
A round trip is two calls by design. The first returns outbound itineraries each with a `departureToken`, and you pass that token back to get the matching return flights. One-way and the price check are a single call each.
|
|
170
|
+
|
|
171
|
+
## Tools
|
|
172
|
+
|
|
173
|
+
One tool, read-only. The sample below is trimmed from a real call, and fares move constantly. Read it as a shape. The tool name links to its endpoint reference, which carries the full parameter list.
|
|
174
|
+
|
|
175
|
+
The sample is the payload, not the whole response. A `tools/call` result carries one text block, and that text is itself JSON holding `url`, `status`, `text` and `json`, with the scraped data under `json`. From a raw JSON-RPC response the path is `result.content[0].text`, parsed, then `.json`. A chat client unwraps that for you and code talking to the endpoint directly does not.
|
|
176
|
+
|
|
177
|
+
### Get Google Flights results
|
|
178
|
+
|
|
179
|
+
[`hasdata_google_travel_flights_getGoogleFlights`](https://docs.hasdata.com/apis/google-travel/flights?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp)
|
|
180
|
+
|
|
181
|
+
Itineraries for a route and date, with fares, legs, emissions and price history.
|
|
182
|
+
|
|
183
|
+
| Parameter | Type | Required | Notes |
|
|
184
|
+
| :--- | :--- | :--- | :--- |
|
|
185
|
+
| `departureId` | string | yes | IATA code such as `JFK`, or a location kgmid like `/m/02_286`. Comma-separate several airports |
|
|
186
|
+
| `arrivalId` | string | yes | Same format as `departureId` |
|
|
187
|
+
| `outboundDate` | string | yes | `YYYY-MM-DD` |
|
|
188
|
+
| `type` | string | | `roundTrip` by default, `oneWay`, or `multiCity` with `multiCityJson` |
|
|
189
|
+
| `returnDate` | string | | Required when `type` is `roundTrip` |
|
|
190
|
+
| `travelClass` | string | | `economy`, `premiumEconomy`, `business` or `first` |
|
|
191
|
+
| `stops` | string | | `nonStop`, `oneStopOrFewer` or `twoStopsOrFewer` |
|
|
192
|
+
| `sortBy` | string | | `topFlights` default, plus `price`, `duration`, `emissions`, `departureTime`, `arrivalTime` |
|
|
193
|
+
| `adults` / `children` / `infantsInSeat` / `infantsOnLap` | number | | Passenger mix |
|
|
194
|
+
| `maxPrice` / `maxDuration` / `bags` | number | | Ceilings and carry-on count |
|
|
195
|
+
| `includeAirlines` / `excludeAirlines` | string | | Comma-separated IATA airline codes, one or the other, not both |
|
|
196
|
+
| `departureToken` | string | | Select an outbound option and fetch its return or next leg |
|
|
197
|
+
| `bookingToken` | string | | Fetch booking options for a chosen itinerary |
|
|
198
|
+
| `currency` / `gl` / `hl` | string | | Currency and the country and language of the search |
|
|
199
|
+
| `deepSearch` | boolean | | Match what Google shows in a browser, slower to return |
|
|
200
|
+
|
|
201
|
+
The reference also documents `includeConnections`, `excludeConnections`, `layoverDuration`, `outboundTimes`, `returnTimes`, `showHidden`, `lessEmissions` and `multiCityJson`.
|
|
202
|
+
|
|
203
|
+
Results split into `bestFlights` and `otherFlights`. Each itinerary carries `price`, `type`, `totalDuration` in minutes, a `flights` array of legs, a `carbonEmissions` object, and a `bookingToken`. Each leg holds the `departureAirport` and `arrivalAirport` (each with `id`, `name` and local `time`), `duration`, `airline`, `flightNumber`, `airplane`, `legroom`, `travelClass`, an `extensions` array, and `oftenDelayedByOver30Min` on legs Google flags. A non-stop itinerary has one leg, a connection has several.
|
|
204
|
+
|
|
205
|
+
> `carbonEmissions` is in grams, not kilograms. `thisFlight: 433000` is 433 kg. `differencePercent` compares it to `typicalForThisRoute`, so a negative number is a greener-than-average flight.
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"price": 295,
|
|
210
|
+
"type": "One way",
|
|
211
|
+
"totalDuration": 415,
|
|
212
|
+
"flights": [
|
|
213
|
+
{
|
|
214
|
+
"departureAirport": { "id": "JFK", "name": "John F. Kennedy International Airport", "time": "2026-09-15 8:15" },
|
|
215
|
+
"arrivalAirport": { "id": "LHR", "name": "Heathrow Airport", "time": "2026-09-15 20:10" },
|
|
216
|
+
"duration": 415,
|
|
217
|
+
"airline": "Virgin Atlantic",
|
|
218
|
+
"flightNumber": "VS 26",
|
|
219
|
+
"airplane": "Boeing 787",
|
|
220
|
+
"travelClass": "Economy"
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"carbonEmissions": { "thisFlight": 367000, "typicalForThisRoute": 419000, "differencePercent": -12 },
|
|
224
|
+
"bookingToken": "W1t7..."
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
`priceInsights` sits alongside the itineraries with `lowestPrice`, a `typicalPriceRange`, a `priceLevel` such as `typical`, and a `priceHistory` of `[timestamp, price]` points. `airports` echoes the resolved departure and arrival airports with city and country.
|
|
229
|
+
|
|
230
|
+
## Errors and failure paths
|
|
231
|
+
|
|
232
|
+
Your client almost never sees an HTTP error code from a tool call. The MCP layer answers 200 and puts the failure inside the result, with `isError` set to `true` and the reason as text. The agent reads a message where you might expect a status line.
|
|
233
|
+
|
|
234
|
+
**A wrong key surfaces as tool output, not as a failed connection.** `tools/list` accepts any non-empty key and returns the tool, so the client completes its handshake and shows green. The first tool call then comes back with `isError: true` and the text `HasData API error: 401 Unauthorized`. Watch for that string, because nothing earlier in the flow reports the problem.
|
|
235
|
+
|
|
236
|
+
**A missing key is the one real HTTP error.** Authorization runs before any tool, and the connection itself fails with 401. CORS headers are present, and a browser client reads the status and not an opaque network failure.
|
|
237
|
+
|
|
238
|
+
**An argument that breaks the tool's schema is rejected before it becomes a scrape.** The server answers with `isError: true` and the text `MCP error -32602: Input validation error`, naming the offending field. A `roundTrip` without a `returnDate`, or `includeAirlines` together with `excludeAirlines`, is caught here.
|
|
239
|
+
|
|
240
|
+
**A route with no flights on the date returns a successful result with the itinerary arrays empty**, not an error. `requestMetadata.status` still reads `ok`. Test for the flights before you rank them.
|
|
241
|
+
|
|
242
|
+
**A bad airport code returns 400** with `requestMetadata.status` set to `error`. Use IATA codes or kgmids, not city names.
|
|
243
|
+
|
|
244
|
+
Results that carry data also carry a `requestMetadata.id` worth quoting in support.
|
|
245
|
+
|
|
246
|
+
## Pricing, free tier and limits
|
|
247
|
+
|
|
248
|
+
Every Google Flights call costs **15 credits per successful call**. Response size does not change the price, and the deep search costs the same as a standard one.
|
|
249
|
+
|
|
250
|
+
The free trial is **1,000 credits over 30 days with no card**, which is about 66 flight searches. After that an active account keeps getting 100 credits topped up each day whenever its balance drops below 100, so a low-volume agent runs on the free tier indefinitely.
|
|
251
|
+
|
|
252
|
+
Paid plans start at **$49 a month** for 200,000 credits, which is about 13,000 searches. The unit price falls with volume, from **$3.68 per 1,000 calls** on the entry plan to **$1.49** on Business, **$1.25** on Growth and **$1.12** on the largest [high-volume plans](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp).
|
|
253
|
+
|
|
254
|
+
Your plan also sets concurrency. The free trial allows 1 request at a time, Startup 15, Business 30, Growth 50, and the high-volume plans run from 200 to 1,500. Handle the overflow case defensively in anything unattended.
|
|
255
|
+
|
|
256
|
+
A request that comes back non-200 is not billed. A round trip is two calls, so budget for it.
|
|
257
|
+
|
|
258
|
+
## Tool selection
|
|
259
|
+
|
|
260
|
+
The `apis` query parameter decides which tools your agent sees. Fewer tools means less context spent on tool definitions, and fewer chances for the model to reach for the wrong one.
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
?apis=google_travel_flights the one tool in this repo
|
|
264
|
+
?apis=google_travel add Google Hotels
|
|
265
|
+
?apis=google_travel_flights,airbnb flights plus Airbnb stays
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The parameter takes provider names like `google_travel` and individual API names like `google_travel_flights`. Misspelled names are ignored. If every name is wrong the request fails with 400, and the body lists both what it did not recognise and every valid value. Drop the parameter and the same endpoint exposes all 57 HasData tools.
|
|
269
|
+
|
|
270
|
+
## How it compares
|
|
271
|
+
|
|
272
|
+
Google retired its QPX Express flight API in 2018 and never replaced it, so there is no official Google Flights API. The remaining routes are scraping the public results or licensing raw GDS fare data, which is heavy and expensive. This server reads the same results the site shows and returns them as JSON.
|
|
273
|
+
|
|
274
|
+
| | Official Google API | This server |
|
|
275
|
+
| :--- | :--- | :--- |
|
|
276
|
+
| Availability | None since QPX Express closed in 2018 | Maintained schema over the live results |
|
|
277
|
+
| Emissions data | Not offered | Per-itinerary, compared to the route average |
|
|
278
|
+
| Price history | Not offered | `priceInsights` with a typical range |
|
|
279
|
+
| Setup | Nothing to set up, because it does not exist | One key and one URL |
|
|
280
|
+
| Cost | Not applicable | Paid past the trial, 15 credits a call |
|
|
281
|
+
|
|
282
|
+
**What this server does not do.** No booking and no payment. It reads fares, legs and the tokens Google itself uses to move to booking, and hands the booking step back to you.
|
|
283
|
+
|
|
284
|
+
## FAQ
|
|
285
|
+
|
|
286
|
+
### Is there an official Google Flights API?
|
|
287
|
+
|
|
288
|
+
No. Google closed QPX Express in 2018 and has not shipped a replacement. Every option reads the same public results the website serves. This one is maintained by HasData and returns them as structured JSON.
|
|
289
|
+
|
|
290
|
+
### What is a Google Flights MCP server?
|
|
291
|
+
|
|
292
|
+
A server that exposes Google Flights as a tool an AI client can call. The client sends a tool call over the Model Context Protocol, the server fetches the itineraries and returns structured JSON, and the model works with the result. This one exposes a single tool and runs remotely.
|
|
293
|
+
|
|
294
|
+
### Why is a round trip two calls?
|
|
295
|
+
|
|
296
|
+
Google returns outbound options first, each with a `departureToken`. You pick one and pass its token back to get the return flights that pair with it. That mirrors how the site works, and it is why a round trip costs 30 credits.
|
|
297
|
+
|
|
298
|
+
### Are the carbon numbers in kilograms?
|
|
299
|
+
|
|
300
|
+
No, grams. `thisFlight: 433000` means 433 kg, and `differencePercent` compares it to the route average.
|
|
301
|
+
|
|
302
|
+
### What is deep search?
|
|
303
|
+
|
|
304
|
+
A slower mode that returns exactly what Google Flights shows in a browser. Leave it off for speed, turn it on when you need parity with the site.
|
|
305
|
+
|
|
306
|
+
### Can I use this together with other HasData APIs?
|
|
307
|
+
|
|
308
|
+
Yes. The `apis` parameter takes a list, and `?apis=google_travel` adds Google Hotels alongside flights. [Drop the parameter](#tool-selection) and you get everything.
|
|
309
|
+
|
|
310
|
+
### Compliance and personal data
|
|
311
|
+
|
|
312
|
+
HasData accesses publicly available data only. A platform's terms may restrict automated access, and you are responsible for your own compliance.
|
|
313
|
+
|
|
314
|
+
## HasData links
|
|
315
|
+
|
|
316
|
+
| | |
|
|
317
|
+
| :--- | :--- |
|
|
318
|
+
| Product page and request builder | [Google Flights API](https://hasdata.com/apis/google-flights-api?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
319
|
+
| Server documentation | [MCP server docs](https://docs.hasdata.com/mcp-server?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
320
|
+
| All 57 tools in one server | [HasData/hasdata-mcp](https://github.com/HasData/hasdata-mcp) |
|
|
321
|
+
| Client walkthroughs | [MCP clients and integrations](https://hasdata.com/integrations/mcp?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
322
|
+
| Everything else we scrape | [Google Flights API and 54 more](https://hasdata.com/apis/?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
323
|
+
| Plans and credit costs | [Plans and credit costs](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
324
|
+
| Keys and usage | [HasData dashboard](https://app.hasdata.com?utm_source=github&utm_medium=syndication&utm_campaign=google-flights-mcp) |
|
|
325
|
+
|
|
326
|
+
## Development
|
|
327
|
+
|
|
328
|
+
This repository is configuration and documentation for a remote server. There is no build step and nothing to containerize.
|
|
329
|
+
|
|
330
|
+
The tests in `test/` assert the tool contract, the part that can break without a commit here. They check that `?apis=google_travel_flights` returns exactly one tool, that it still declares its required parameters, that the name has not changed, and that the key in use is actually accepted. That last check calls the tool for real and costs 15 credits, which is the price of a canary that can fail for the right reason.
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# macOS and Linux
|
|
334
|
+
HASDATA_API_KEY=your_key_here npm test
|
|
335
|
+
|
|
336
|
+
# Windows PowerShell
|
|
337
|
+
$env:HASDATA_API_KEY="your_key_here"; npm test
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
The same suite runs in CI on every push and once a week on a schedule, because the upstream tool list can change without anyone touching this repository. A failure means the tool list moved, the key stopped working, or the endpoint was unreachable, and the assertion message says which.
|
|
341
|
+
|
|
342
|
+
## Contributing
|
|
343
|
+
|
|
344
|
+
Corrections to the parameter table and the response sample are the most useful contribution, because those are the parts that drift. Include the call you made and the response you got. Pull requests from forks run the suite without a key, and the live checks skip instead of going red.
|
|
345
|
+
|
|
346
|
+
## License
|
|
347
|
+
|
|
348
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Thin launcher for HasData's hosted Google Flights MCP server.
|
|
2
|
+
|
|
3
|
+
Connects an MCP client to the remote streamable-HTTP endpoint through mcp-proxy.
|
|
4
|
+
The server runs on HasData's infrastructure. This package only proxies stdio to it.
|
|
5
|
+
"""
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
import subprocess
|
|
9
|
+
|
|
10
|
+
URL = "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main() -> None:
|
|
14
|
+
key = os.environ.get("HASDATA_API_KEY")
|
|
15
|
+
if not key:
|
|
16
|
+
sys.stderr.write(
|
|
17
|
+
"HASDATA_API_KEY is not set. Create a free key at https://app.hasdata.com "
|
|
18
|
+
"and set HASDATA_API_KEY.\n"
|
|
19
|
+
)
|
|
20
|
+
raise SystemExit(1)
|
|
21
|
+
args = [
|
|
22
|
+
sys.executable, "-m", "mcp_proxy", URL,
|
|
23
|
+
"--transport=streamablehttp",
|
|
24
|
+
"--headers", "x-api-key", key,
|
|
25
|
+
]
|
|
26
|
+
rc = subprocess.call(args)
|
|
27
|
+
# subprocess returns -N when mcp_proxy is killed by signal N; map to 128+N.
|
|
28
|
+
raise SystemExit(rc if rc >= 0 else 128 - rc)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin launcher: connects an MCP client to HasData's hosted Google Flights MCP server
|
|
3
|
+
// (streamable HTTP) through the mcp-remote stdio bridge. The server runs remotely.
|
|
4
|
+
// This package only proxies, so nothing here scrapes anything.
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { dirname, join } from 'node:path';
|
|
8
|
+
|
|
9
|
+
const URL = 'https://mcp.hasdata.com/api/mcp?apis=google_travel_flights';
|
|
10
|
+
const key = process.env.HASDATA_API_KEY;
|
|
11
|
+
if (!key) {
|
|
12
|
+
process.stderr.write('HASDATA_API_KEY is not set. Create a free key at https://app.hasdata.com and set HASDATA_API_KEY.\n');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
// Resolve mcp-remote's CLI from its own package.json bin, so a future layout change
|
|
16
|
+
// or an exports map does not break a hardcoded deep path.
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const pkg = require('mcp-remote/package.json');
|
|
19
|
+
const proxy = join(dirname(require.resolve('mcp-remote/package.json')), pkg.bin['mcp-remote']);
|
|
20
|
+
const child = spawn(process.execPath, [proxy, URL, '--header', `x-api-key:${key}`], { stdio: 'inherit' });
|
|
21
|
+
child.on('exit', (code, signal) => {
|
|
22
|
+
if (signal) process.kill(process.pid, signal);
|
|
23
|
+
else process.exit(code ?? 0);
|
|
24
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hasdata/google-flights-mcp",
|
|
3
|
+
"mcpName": "com.hasdata/google-flights",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "MCP server for Google Flights through HasData's hosted API: one-way, round-trip and multi-city itineraries with fares, legs, carbon emissions and price history. No Google account.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": { "hasdata-google-flights-mcp": "index.mjs" },
|
|
8
|
+
"files": ["index.mjs", "README.md", "LICENSE"],
|
|
9
|
+
"scripts": { "test": "node --test" },
|
|
10
|
+
"dependencies": { "mcp-remote": "^0.1.43" },
|
|
11
|
+
"engines": { "node": ">=18" },
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": { "type": "git", "url": "https://github.com/HasData/google-flights-mcp.git" },
|
|
14
|
+
"homepage": "https://hasdata.com/apis/google-flights-api",
|
|
15
|
+
"keywords": ["mcp", "google-flights", "google-flights-mcp", "flights", "travel", "model-context-protocol", "hasdata", "scraper"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "hasdata-google-flights-mcp"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "MCP server for Google Flights through HasData's hosted API. No Google account."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
keywords = ["mcp", "google-flights", "flights", "travel", "model-context-protocol", "hasdata"]
|
|
9
|
+
# mcp is pinned below 2 because mcp-proxy 0.12.0 imports request_ctx, removed in the mcp 2.x SDK.
|
|
10
|
+
dependencies = ["mcp-proxy>=0.12.0", "mcp>=1.17,<2"]
|
|
11
|
+
|
|
12
|
+
[project.urls]
|
|
13
|
+
Homepage = "https://hasdata.com/apis/google-flights-api"
|
|
14
|
+
Repository = "https://github.com/HasData/google-flights-mcp"
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
hasdata-google-flights-mcp = "hasdata_google_flights_mcp:main"
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["hatchling"]
|
|
21
|
+
build-backend = "hatchling.build"
|
|
22
|
+
|
|
23
|
+
[tool.hatch.build.targets.wheel]
|
|
24
|
+
packages = ["hasdata_google_flights_mcp"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "com.hasdata/google-flights",
|
|
4
|
+
"title": "HasData Google Flights",
|
|
5
|
+
"description": "Google Flights itineraries with fares, legs, carbon emissions and price history, as JSON.",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"websiteUrl": "https://hasdata.com/apis/google-flights-api",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/HasData/google-flights-mcp",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=google_travel_flights",
|
|
16
|
+
"headers": [
|
|
17
|
+
{
|
|
18
|
+
"name": "x-api-key",
|
|
19
|
+
"description": "HasData API key, created at app.hasdata.com. The free trial needs no card.",
|
|
20
|
+
"isRequired": true,
|
|
21
|
+
"isSecret": true
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"packages": [
|
|
27
|
+
{
|
|
28
|
+
"registryType": "npm",
|
|
29
|
+
"identifier": "@hasdata/google-flights-mcp",
|
|
30
|
+
"version": "1.0.0",
|
|
31
|
+
"transport": {
|
|
32
|
+
"type": "stdio"
|
|
33
|
+
},
|
|
34
|
+
"environmentVariables": [
|
|
35
|
+
{
|
|
36
|
+
"name": "HASDATA_API_KEY",
|
|
37
|
+
"description": "HasData API key, created at app.hasdata.com. The free trial needs no card.",
|
|
38
|
+
"isRequired": true,
|
|
39
|
+
"isSecret": true
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// Tool contract test.
|
|
2
|
+
//
|
|
3
|
+
// The README promises one tool with a specific name and required parameters. The upstream list
|
|
4
|
+
// can change without a single commit here, and the README would start lying silently. These
|
|
5
|
+
// checks catch that before a user does.
|
|
6
|
+
//
|
|
7
|
+
// The last test calls the tool for real. Listing tools accepts any non-empty key, so a contract
|
|
8
|
+
// check that only lists tools stays green with a revoked or mistyped key. That call costs
|
|
9
|
+
// 15 credits, which is the price of a canary that can fail for the right reason.
|
|
10
|
+
//
|
|
11
|
+
// Run: HASDATA_API_KEY=your_key_here npm test
|
|
12
|
+
|
|
13
|
+
import { test } from 'node:test';
|
|
14
|
+
import assert from 'node:assert/strict';
|
|
15
|
+
|
|
16
|
+
const ENDPOINT = 'https://mcp.hasdata.com/api/mcp?apis=google_travel_flights';
|
|
17
|
+
const KEY = process.env.HASDATA_API_KEY;
|
|
18
|
+
const TIMEOUT_MS = 30_000;
|
|
19
|
+
|
|
20
|
+
const EXPECTED = {
|
|
21
|
+
hasdata_google_travel_flights_getGoogleFlights: ['departureId', 'arrivalId', 'outboundDate'],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// A streamable HTTP body arrives either as plain JSON or as server-sent events. One SSE event
|
|
25
|
+
// can span several data: lines, several events can share one response, and a server is free to
|
|
26
|
+
// send progress notifications before the answer. So collect every event and pick the message
|
|
27
|
+
// carrying our request id instead of trusting the first data: line.
|
|
28
|
+
function parseRpc(raw, id) {
|
|
29
|
+
const trimmed = raw.trim();
|
|
30
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) return JSON.parse(trimmed);
|
|
31
|
+
|
|
32
|
+
const messages = [];
|
|
33
|
+
for (const event of trimmed.split(/\r?\n\r?\n+/)) {
|
|
34
|
+
const data = event
|
|
35
|
+
.split(/\r?\n/)
|
|
36
|
+
.filter((l) => l.startsWith('data:'))
|
|
37
|
+
.map((l) => l.slice(5).replace(/^ /, ''))
|
|
38
|
+
.join('\n');
|
|
39
|
+
if (!data || data === '[DONE]') continue;
|
|
40
|
+
try {
|
|
41
|
+
messages.push(JSON.parse(data));
|
|
42
|
+
} catch {
|
|
43
|
+
// A keep-alive or a partial event is not our response.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
assert.ok(messages.length, `no JSON-RPC message in the response: ${raw.slice(0, 300)}`);
|
|
47
|
+
const match = messages.find((m) => m.id === id);
|
|
48
|
+
assert.ok(match, `no message with id ${id} in the response: ${raw.slice(0, 300)}`);
|
|
49
|
+
return match;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let nextId = 1;
|
|
53
|
+
|
|
54
|
+
async function rpc(method, params = {}) {
|
|
55
|
+
const id = nextId++;
|
|
56
|
+
const res = await fetch(ENDPOINT, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
headers: {
|
|
59
|
+
'x-api-key': KEY,
|
|
60
|
+
'Content-Type': 'application/json',
|
|
61
|
+
// The server answers over streamable HTTP, so accept both a plain body and a stream.
|
|
62
|
+
Accept: 'application/json, text/event-stream',
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({ jsonrpc: '2.0', id, method, params }),
|
|
65
|
+
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
66
|
+
});
|
|
67
|
+
assert.equal(res.status, 200, `${method} returned ${res.status}`);
|
|
68
|
+
const raw = await res.text();
|
|
69
|
+
return { raw, body: parseRpc(raw, id) };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// One network round trip for every test that needs the list.
|
|
73
|
+
let toolsPromise;
|
|
74
|
+
function listTools() {
|
|
75
|
+
toolsPromise ??= rpc('tools/list').then(({ body }) => {
|
|
76
|
+
assert.ok(body.result?.tools, 'the response carried no result.tools');
|
|
77
|
+
return body.result.tools;
|
|
78
|
+
});
|
|
79
|
+
return toolsPromise;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const live = { skip: KEY ? false : 'HASDATA_API_KEY is not set, skipping the live checks' };
|
|
83
|
+
|
|
84
|
+
test('apis=google_travel_flights exposes exactly one tool', live, async () => {
|
|
85
|
+
const tools = await listTools();
|
|
86
|
+
const names = tools.map((t) => t.name).sort().join(', ');
|
|
87
|
+
assert.equal(
|
|
88
|
+
tools.length,
|
|
89
|
+
Object.keys(EXPECTED).length,
|
|
90
|
+
`expected ${Object.keys(EXPECTED).length} tool, got ${tools.length}: ${names}`
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('the tool name has not changed', live, async () => {
|
|
95
|
+
const tools = await listTools();
|
|
96
|
+
const names = new Set(tools.map((t) => t.name));
|
|
97
|
+
for (const expected of Object.keys(EXPECTED)) {
|
|
98
|
+
assert.ok(names.has(expected), `tool ${expected} is missing from the list`);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('the tool still declares its required parameter', live, async () => {
|
|
103
|
+
const tools = await listTools();
|
|
104
|
+
for (const tool of tools) {
|
|
105
|
+
const required = tool.inputSchema?.required ?? [];
|
|
106
|
+
const want = EXPECTED[tool.name];
|
|
107
|
+
assert.ok(want, `tool ${tool.name} is not covered by this test`);
|
|
108
|
+
for (const param of want) {
|
|
109
|
+
assert.ok(
|
|
110
|
+
required.includes(param),
|
|
111
|
+
`${tool.name} should require ${param}, declares: ${required.join(', ') || 'nothing'}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('the tool carries a description', live, async () => {
|
|
118
|
+
const tools = await listTools();
|
|
119
|
+
for (const tool of tools) {
|
|
120
|
+
assert.ok(
|
|
121
|
+
(tool.description || '').trim().length > 20,
|
|
122
|
+
`${tool.name} has an empty or near-empty description`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('the key is accepted by HasData', live, async () => {
|
|
128
|
+
// Compute the date at run time. A hardcoded future date silently becomes a past date and
|
|
129
|
+
// then Google rejects the outbound date, turning this canary red for the wrong reason.
|
|
130
|
+
const outboundDate = new Date(Date.now() + 30 * 86_400_000).toISOString().slice(0, 10);
|
|
131
|
+
const { raw } = await rpc('tools/call', {
|
|
132
|
+
name: 'hasdata_google_travel_flights_getGoogleFlights',
|
|
133
|
+
arguments: { departureId: 'JFK', arrivalId: 'LHR', outboundDate, type: 'oneWay' },
|
|
134
|
+
});
|
|
135
|
+
assert.ok(!raw.includes('401 Unauthorized'), 'HasData rejected the key');
|
|
136
|
+
assert.ok(!raw.includes('"isError":true'), `the tool call failed: ${raw.slice(0, 300)}`);
|
|
137
|
+
});
|