hasdata-booking-mcp 1.0.1__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_booking_mcp-1.0.1/.github/ISSUE_TEMPLATE/inaccuracy.md +21 -0
- hasdata_booking_mcp-1.0.1/.github/workflows/contract.yml +31 -0
- hasdata_booking_mcp-1.0.1/.github/workflows/publish.yml +65 -0
- hasdata_booking_mcp-1.0.1/.gitignore +11 -0
- hasdata_booking_mcp-1.0.1/LICENSE +21 -0
- hasdata_booking_mcp-1.0.1/PKG-INFO +389 -0
- hasdata_booking_mcp-1.0.1/README.md +375 -0
- hasdata_booking_mcp-1.0.1/glama.json +7 -0
- hasdata_booking_mcp-1.0.1/hasdata_booking_mcp/__init__.py +28 -0
- hasdata_booking_mcp-1.0.1/index.mjs +24 -0
- hasdata_booking_mcp-1.0.1/package.json +41 -0
- hasdata_booking_mcp-1.0.1/pyproject.toml +24 -0
- hasdata_booking_mcp-1.0.1/server.json +44 -0
- hasdata_booking_mcp-1.0.1/test/tools.test.mjs +139 -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/booking-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/booking-mcp, workflow publish.yml
|
|
12
|
+
#
|
|
13
|
+
# The MCP registry entry (com.hasdata/booking) 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,389 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: hasdata-booking-mcp
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: MCP server for Booking.com through HasData's hosted API. No Booking.com account.
|
|
5
|
+
Project-URL: Homepage, https://hasdata.com/apis/booking-api
|
|
6
|
+
Project-URL: Repository, https://github.com/HasData/booking-mcp
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: booking,booking-com,hasdata,hotels,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
|
+
# Booking.com MCP Server
|
|
16
|
+
|
|
17
|
+
<!-- mcp-name: com.hasdata/booking -->
|
|
18
|
+
|
|
19
|
+
A hosted Model Context Protocol (MCP) server that gives Claude, Cursor, Windsurf and any other MCP client two read-only Booking.com tools. Search stays by destination and dates with rich filters, and read a single property in full, all as structured JSON, with no Booking.com account and nothing to host.
|
|
20
|
+
|
|
21
|
+
It reads public property pages on Booking.com that a signed-out visitor can see.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
https://mcp.hasdata.com/api/mcp?apis=booking
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
[](https://glama.ai/mcp/servers/HasData/booking-mcp)
|
|
28
|
+
[](https://github.com/HasData/booking-mcp/actions/workflows/contract.yml)
|
|
29
|
+
[](https://modelcontextprotocol.io)
|
|
30
|
+
[](#tools)
|
|
31
|
+
[](https://www.npmjs.com/package/@hasdata/booking-mcp)
|
|
32
|
+
[](https://pypi.org/project/hasdata-booking-mcp/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
|
|
35
|
+
## Contents
|
|
36
|
+
|
|
37
|
+
- [What you need](#what-you-need)
|
|
38
|
+
- [Quick start](#quick-start)
|
|
39
|
+
- [Example prompts](#example-prompts)
|
|
40
|
+
- [Tools](#tools)
|
|
41
|
+
- [Errors and failure paths](#errors-and-failure-paths)
|
|
42
|
+
- [Pricing, free tier and limits](#pricing-free-tier-and-limits)
|
|
43
|
+
- [Tool selection](#tool-selection)
|
|
44
|
+
- [How it compares](#how-it-compares)
|
|
45
|
+
- [FAQ](#faq)
|
|
46
|
+
- [HasData links](#hasdata-links)
|
|
47
|
+
- [Development](#development)
|
|
48
|
+
- [Contributing](#contributing)
|
|
49
|
+
- [License](#license)
|
|
50
|
+
|
|
51
|
+
## What you need
|
|
52
|
+
|
|
53
|
+
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=booking-mcp), free to create with no card, and the trial covers 100 calls at the 10-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 Booking.com account anywhere in the flow. A client that only speaks stdio reaches it through a thin launcher, published as `@hasdata/booking-mcp` on npm and `hasdata-booking-mcp` on PyPI, shown below.
|
|
54
|
+
|
|
55
|
+
## Quick start
|
|
56
|
+
|
|
57
|
+
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.
|
|
58
|
+
|
|
59
|
+
| Field | Value |
|
|
60
|
+
| :--- | :--- |
|
|
61
|
+
| URL | `https://mcp.hasdata.com/api/mcp?apis=booking` |
|
|
62
|
+
| Transport | HTTP, streamable |
|
|
63
|
+
| Auth header | `x-api-key: HASDATA_API_KEY` |
|
|
64
|
+
|
|
65
|
+
Clients with OAuth support can add the same URL as a connector and sign in without putting a key in a config file.
|
|
66
|
+
|
|
67
|
+
<details>
|
|
68
|
+
<summary><b>Claude Code</b></summary>
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
claude mcp add --transport http booking "https://mcp.hasdata.com/api/mcp?apis=booking" \
|
|
72
|
+
--header "x-api-key: HASDATA_API_KEY"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
</details>
|
|
76
|
+
|
|
77
|
+
<details>
|
|
78
|
+
<summary><b>Claude Desktop</b></summary>
|
|
79
|
+
|
|
80
|
+
Settings, then Connectors, then Add custom connector, then paste `https://mcp.hasdata.com/api/mcp?apis=booking` and sign in.
|
|
81
|
+
|
|
82
|
+
For the config-file route, Claude Desktop loads only local (stdio) servers, so it reaches a remote server through a stdio launcher. The `@hasdata/booking-mcp` package is that launcher, and it reads the key from the environment. Add this to `claude_desktop_config.json`:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"mcpServers": {
|
|
87
|
+
"booking": {
|
|
88
|
+
"command": "npx",
|
|
89
|
+
"args": ["-y", "@hasdata/booking-mcp"],
|
|
90
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
For Python instead of Node, swap the launcher for the PyPI package, which `uvx` runs without a manual install:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"booking": {
|
|
102
|
+
"command": "uvx",
|
|
103
|
+
"args": ["hasdata-booking-mcp"],
|
|
104
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
</details>
|
|
111
|
+
|
|
112
|
+
<details>
|
|
113
|
+
<summary><b>Cursor</b></summary>
|
|
114
|
+
|
|
115
|
+
`~/.cursor/mcp.json` for every project, or `.cursor/mcp.json` for one:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"mcpServers": {
|
|
120
|
+
"booking": {
|
|
121
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=booking",
|
|
122
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
</details>
|
|
129
|
+
|
|
130
|
+
<details>
|
|
131
|
+
<summary><b>Windsurf</b></summary>
|
|
132
|
+
|
|
133
|
+
`~/.codeium/windsurf/mcp_config.json`. Windsurf calls the field `serverUrl`, not `url`:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"booking": {
|
|
139
|
+
"serverUrl": "https://mcp.hasdata.com/api/mcp?apis=booking",
|
|
140
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
</details>
|
|
147
|
+
|
|
148
|
+
<details>
|
|
149
|
+
<summary><b>VS Code</b></summary>
|
|
150
|
+
|
|
151
|
+
`.vscode/mcp.json` in the workspace:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"servers": {
|
|
156
|
+
"booking": {
|
|
157
|
+
"type": "http",
|
|
158
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=booking",
|
|
159
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
</details>
|
|
166
|
+
|
|
167
|
+
## Example prompts
|
|
168
|
+
|
|
169
|
+
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 10 credits.
|
|
170
|
+
|
|
171
|
+
> Search Booking.com for hotels in Paris from September 15 to 18 for two adults, and give me the ten best-reviewed under $700 for the stay.
|
|
172
|
+
|
|
173
|
+
*One call, 10 credits. Price, review score and location come back on the search result.*
|
|
174
|
+
|
|
175
|
+
> Take the top result and pull its full detail: facilities, house rules, the room options, and the category ratings.
|
|
176
|
+
|
|
177
|
+
*One call, 10 credits. Those live on the property page, which the details tool reads by URL and dates.*
|
|
178
|
+
|
|
179
|
+
> Find four-star hotels in Paris with free cancellation near the center, and list price and review score.
|
|
180
|
+
|
|
181
|
+
*One call, 10 credits. Star rating, cancellation policy and distance are filters on the one request.*
|
|
182
|
+
|
|
183
|
+
> Compare the cheapest stay in Paris against Rome for the same dates.
|
|
184
|
+
|
|
185
|
+
*Two calls, 20 credits, one search per city.*
|
|
186
|
+
|
|
187
|
+
The property tool needs the same dates and guest counts as the search, because availability and price depend on the window. A search to shortlist plus a detail call on three properties is one search and three property calls.
|
|
188
|
+
|
|
189
|
+
## Tools
|
|
190
|
+
|
|
191
|
+
Two tools, read-only. Samples below are trimmed from real calls, and prices move constantly. Read them as shapes. Each tool name links to its endpoint reference, which carries the full field list.
|
|
192
|
+
|
|
193
|
+
The samples are 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.
|
|
194
|
+
|
|
195
|
+
### Get Booking.com search results
|
|
196
|
+
|
|
197
|
+
[`hasdata_booking_search_getBookingSearchResults`](https://docs.hasdata.com/apis/booking/search?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp)
|
|
198
|
+
|
|
199
|
+
A page of stays by destination and dates.
|
|
200
|
+
|
|
201
|
+
| Parameter | Type | Required | Notes |
|
|
202
|
+
| :--- | :--- | :--- | :--- |
|
|
203
|
+
| `keyword` | string | yes | Destination, such as `Paris` or a specific property name |
|
|
204
|
+
| `checkInDate` / `checkOutDate` | string | yes | `YYYY-MM-DD`, check-in in the future and before check-out |
|
|
205
|
+
| `rooms` / `adults` / `children` | number | yes | Guest composition. Pass `children: 0` when there are none |
|
|
206
|
+
| `childrenAges` | string | | Comma-separated ages, required when `children > 0` |
|
|
207
|
+
| `sort` | string | | `priceLowestFirst`, `ratingHighToLow`, `bestReviewedAndLowestPrice`, `distanceFromDowntown` and more |
|
|
208
|
+
| `propertyType__` / `rating__` / `reviewScore__` | array | | Property type, star rating, and guest-score buckets |
|
|
209
|
+
| `facilities__` / `roomFacilities__` / `reservationPolicy__` | array | | Facility, in-room and cancellation filters |
|
|
210
|
+
| `price_min_` / `price_max_` | number | | Total-stay price band |
|
|
211
|
+
| `page` | number | | About 25 results per page, `2` for the next page |
|
|
212
|
+
|
|
213
|
+
The reference documents the full filter set, including distance, meals, accessibility, bed preference and travel group.
|
|
214
|
+
|
|
215
|
+
Returns `searchInformation`, a `results` array, and `pagination` with `page`, `totalResults` and `totalPages`. Each result carries `hotelId`, `title`, `url`, the offered `room` and `bedTypes`, a `location` object, a `policies` object, a `price` object, the star `rating`, a `reviews` object with `score`, `count` and a text label, and a `photo`.
|
|
216
|
+
|
|
217
|
+
> The discount field in `price` is spelled `dicsount` (`dicsountRaw` and `dicsountParsed`), which mirrors the upstream key. Read that spelling, not `discount`. Also note `rating` is the official star rating while `reviews.score` is the guest score out of 10, two different numbers.
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"hotelId": 50724,
|
|
222
|
+
"title": "Hôtel du Jardin des Plantes",
|
|
223
|
+
"url": "https://www.booking.com/hotel/fr/timjardindesplantes.html",
|
|
224
|
+
"room": "Comfort Double Room",
|
|
225
|
+
"location": { "city": "Paris", "address": "5 rue Linné", "mainDistance": "0.9 miles from downtown", "centrallyLocated": true },
|
|
226
|
+
"policies": { "freeCancellation": true, "noPrepayment": true },
|
|
227
|
+
"price": { "pricePerStayParsed": 451.36, "priceBeforeDiscountParsed": 885.03, "dicsountParsed": 433.66, "currency": "USD" },
|
|
228
|
+
"rating": 3,
|
|
229
|
+
"reviews": { "score": 7.5, "count": 1721, "text": "Good" }
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Get Booking.com property details
|
|
234
|
+
|
|
235
|
+
[`hasdata_booking_place_getBookingPlaceDetails`](https://docs.hasdata.com/apis/booking/place?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp)
|
|
236
|
+
|
|
237
|
+
One property in full, by its URL and the stay window.
|
|
238
|
+
|
|
239
|
+
| Parameter | Type | Required | Notes |
|
|
240
|
+
| :--- | :--- | :--- | :--- |
|
|
241
|
+
| `url` | string | yes | A Booking.com property URL, the `url` field from a search result |
|
|
242
|
+
| `checkInDate` / `checkOutDate` | string | yes | `YYYY-MM-DD`, the window to price and check availability for |
|
|
243
|
+
| `rooms` / `adults` / `children` | number | yes | Guest composition, same meaning as the search tool |
|
|
244
|
+
| `childrenAges` | string | | Comma-separated ages, required when `children > 0` |
|
|
245
|
+
|
|
246
|
+
Returns the page as sections rather than one flat object: `overview` (`id`, `title`, `propertyType`, a structured `address`, a `description`, `highlights`, `mostPopularFacilities` and `photos`), `bookingDetails` (the window and currency the prices reflect), a `rooms` array of the available suites each with `name`, `beds`, `facilities` and priced `variants`, a `facilities` list, `houseRules`, a `ratings` array of category scores, `reviews`, and `questionsAndAnswers`.
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"overview": {
|
|
251
|
+
"id": "50724",
|
|
252
|
+
"title": "Hôtel du Jardin des Plantes",
|
|
253
|
+
"propertyType": "HOTEL",
|
|
254
|
+
"address": { "country": "France", "zipcode": "75005" },
|
|
255
|
+
"mostPopularFacilities": ["Non-smoking rooms", "Free Wifi", "24-hour front desk"]
|
|
256
|
+
},
|
|
257
|
+
"bookingDetails": { "checkIn": "2026-09-15", "checkOut": "2026-09-18", "adults": 2, "rooms": 1, "currency": "USD" },
|
|
258
|
+
"ratings": [
|
|
259
|
+
{ "label": "Average", "value": 7.5, "votes": 1721 },
|
|
260
|
+
{ "label": "Cleanliness", "value": 7.8 }
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Errors and failure paths
|
|
266
|
+
|
|
267
|
+
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.
|
|
268
|
+
|
|
269
|
+
**A wrong key surfaces as tool output, not as a failed connection.** `tools/list` accepts any non-empty key and returns both tools, 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.
|
|
270
|
+
|
|
271
|
+
**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.
|
|
272
|
+
|
|
273
|
+
**An argument that breaks a 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 `children` count without matching `childrenAges`, or a check-out on or before check-in, is caught here.
|
|
274
|
+
|
|
275
|
+
**A search with no availability returns a successful result with an empty `results` array**, not an error. A destination and window with nothing open still comes back with `requestMetadata.status` set to `ok`. Test for the array length before you iterate.
|
|
276
|
+
|
|
277
|
+
**A property URL that no longer resolves returns 400** with `requestMetadata.status` set to `error`.
|
|
278
|
+
|
|
279
|
+
Results that carry data also carry a `requestMetadata.id` worth quoting in support.
|
|
280
|
+
|
|
281
|
+
## Pricing, free tier and limits
|
|
282
|
+
|
|
283
|
+
Each Booking.com tool costs **10 credits per successful call**. Response size does not change the price. A search page of 25 stays costs the same as one with two.
|
|
284
|
+
|
|
285
|
+
The free trial is **1,000 credits over 30 days with no card**, which is 100 Booking.com calls. 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.
|
|
286
|
+
|
|
287
|
+
Paid plans start at **$49 a month** for 200,000 credits, which is 20,000 calls. The unit price falls with volume, from **$2.45 per 1,000 calls** on the entry plan to **$0.99** on Business, **$0.83** on Growth and **$0.75** on the largest [high-volume plans](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp).
|
|
288
|
+
|
|
289
|
+
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.
|
|
290
|
+
|
|
291
|
+
A request that comes back non-200 is not billed. A successful call that finds nothing is still a call.
|
|
292
|
+
|
|
293
|
+
## Tool selection
|
|
294
|
+
|
|
295
|
+
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.
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
?apis=booking the two tools in this repo
|
|
299
|
+
?apis=booking,airbnb add Airbnb stays
|
|
300
|
+
?apis=booking,google_travel add Google Hotels and Flights
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
The parameter takes provider names like `booking` and individual API names like `booking_search`. 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.
|
|
304
|
+
|
|
305
|
+
## How it compares
|
|
306
|
+
|
|
307
|
+
Booking.com's own programs, the Demand API and the affiliate partner network, are for approved partners who send bookings and earn commission, not a self-serve way to read the public market. For searching stays and reading arbitrary properties, scraping the public pages is the route, and this server does that behind a stable schema.
|
|
308
|
+
|
|
309
|
+
| | Booking.com partner programs | This server |
|
|
310
|
+
| :--- | :--- | :--- |
|
|
311
|
+
| Purpose | Send bookings as an approved affiliate | Read the public market |
|
|
312
|
+
| Access | Partner approval | One key and one URL |
|
|
313
|
+
| Search across the market | Within partner terms | Yes, with rich filters |
|
|
314
|
+
| Setup | Business onboarding | None |
|
|
315
|
+
| Output | Partner feeds | Structured JSON, price and score pre-parsed |
|
|
316
|
+
|
|
317
|
+
**What this server does not do.** No booking, no payment, no partner commission, no account data. It reads what a signed-out visitor can see on Booking.com.
|
|
318
|
+
|
|
319
|
+
## FAQ
|
|
320
|
+
|
|
321
|
+
### Is there an official Booking.com MCP server?
|
|
322
|
+
|
|
323
|
+
Booking.com does not publish one. This one is maintained by HasData and reads public pages, which is why it needs no Booking.com account.
|
|
324
|
+
|
|
325
|
+
### What is a Booking.com MCP server?
|
|
326
|
+
|
|
327
|
+
A server that exposes Booking.com data as tools an AI client can call. The client sends a tool call over the Model Context Protocol, the server fetches the data and returns structured JSON, and the model works with the result. This one exposes two tools and runs remotely.
|
|
328
|
+
|
|
329
|
+
### Do I need a Booking.com account or partner approval?
|
|
330
|
+
|
|
331
|
+
No. The only credential is your HasData key. There is no partner onboarding, because the tools read public Booking.com pages.
|
|
332
|
+
|
|
333
|
+
### Why does the property tool need dates?
|
|
334
|
+
|
|
335
|
+
Because availability, room options and price all depend on the stay window. Pass the same `checkInDate`, `checkOutDate` and guest counts you searched with, and the detail reflects that window.
|
|
336
|
+
|
|
337
|
+
### What is the difference between rating and review score?
|
|
338
|
+
|
|
339
|
+
`rating` is the official star rating of the property. `reviews.score` is the guest review score out of 10. A three-star hotel can carry a 9.0 guest score, so read the one you mean.
|
|
340
|
+
|
|
341
|
+
### Can I use this together with other HasData APIs?
|
|
342
|
+
|
|
343
|
+
Yes. The `apis` parameter takes a list, and `?apis=booking,airbnb` gives your agent Booking.com plus Airbnb. [Drop the parameter](#tool-selection) and you get everything.
|
|
344
|
+
|
|
345
|
+
### Is HasData affiliated with Booking.com?
|
|
346
|
+
|
|
347
|
+
No. HasData is an independent service and is not affiliated with, endorsed by, or sponsored by Booking.com. Booking.com is a trademark of its respective owner.
|
|
348
|
+
|
|
349
|
+
### Compliance and personal data
|
|
350
|
+
|
|
351
|
+
HasData accesses publicly available data only. A platform's terms may restrict automated access, and you are responsible for your own compliance. Where the data you collect includes personal information, make sure you have a lawful basis for it under GDPR, CCPA or the equivalent rules in your jurisdiction.
|
|
352
|
+
|
|
353
|
+
## HasData links
|
|
354
|
+
|
|
355
|
+
| | |
|
|
356
|
+
| :--- | :--- |
|
|
357
|
+
| Product page and request builder | [Booking.com Scraper API](https://hasdata.com/apis/booking-api?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
358
|
+
| Server documentation | [MCP server docs](https://docs.hasdata.com/mcp-server?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
359
|
+
| All 57 tools in one server | [HasData/hasdata-mcp](https://github.com/HasData/hasdata-mcp) |
|
|
360
|
+
| Client walkthroughs | [MCP clients and integrations](https://hasdata.com/integrations/mcp?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
361
|
+
| Everything else we scrape | [Booking.com Scraper API and 54 more](https://hasdata.com/apis/?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
362
|
+
| Plans and credit costs | [Plans and credit costs](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
363
|
+
| Keys and usage | [HasData dashboard](https://app.hasdata.com?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
364
|
+
| Node launcher on npm | [@hasdata/booking-mcp](https://www.npmjs.com/package/@hasdata/booking-mcp) |
|
|
365
|
+
| Python launcher on PyPI | [hasdata-booking-mcp](https://pypi.org/project/hasdata-booking-mcp/) |
|
|
366
|
+
|
|
367
|
+
## Development
|
|
368
|
+
|
|
369
|
+
This repository is configuration and documentation for a remote server. There is no build step and nothing to containerize.
|
|
370
|
+
|
|
371
|
+
The tests in `test/` assert the tool contract, the part that can break without a commit here. They check that `?apis=booking` returns exactly two tools, that every tool still declares its required parameters, that no name changed, and that the key in use is actually accepted. That last check calls a tool for real and costs 10 credits, which is the price of a canary that can fail for the right reason.
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
# macOS and Linux
|
|
375
|
+
HASDATA_API_KEY=your_key_here npm test
|
|
376
|
+
|
|
377
|
+
# Windows PowerShell
|
|
378
|
+
$env:HASDATA_API_KEY="your_key_here"; npm test
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
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.
|
|
382
|
+
|
|
383
|
+
## Contributing
|
|
384
|
+
|
|
385
|
+
Corrections to the tool tables and the response samples 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.
|
|
386
|
+
|
|
387
|
+
## License
|
|
388
|
+
|
|
389
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# Booking.com MCP Server
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: com.hasdata/booking -->
|
|
4
|
+
|
|
5
|
+
A hosted Model Context Protocol (MCP) server that gives Claude, Cursor, Windsurf and any other MCP client two read-only Booking.com tools. Search stays by destination and dates with rich filters, and read a single property in full, all as structured JSON, with no Booking.com account and nothing to host.
|
|
6
|
+
|
|
7
|
+
It reads public property pages on Booking.com that a signed-out visitor can see.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
https://mcp.hasdata.com/api/mcp?apis=booking
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
[](https://glama.ai/mcp/servers/HasData/booking-mcp)
|
|
14
|
+
[](https://github.com/HasData/booking-mcp/actions/workflows/contract.yml)
|
|
15
|
+
[](https://modelcontextprotocol.io)
|
|
16
|
+
[](#tools)
|
|
17
|
+
[](https://www.npmjs.com/package/@hasdata/booking-mcp)
|
|
18
|
+
[](https://pypi.org/project/hasdata-booking-mcp/)
|
|
19
|
+
[](LICENSE)
|
|
20
|
+
|
|
21
|
+
## Contents
|
|
22
|
+
|
|
23
|
+
- [What you need](#what-you-need)
|
|
24
|
+
- [Quick start](#quick-start)
|
|
25
|
+
- [Example prompts](#example-prompts)
|
|
26
|
+
- [Tools](#tools)
|
|
27
|
+
- [Errors and failure paths](#errors-and-failure-paths)
|
|
28
|
+
- [Pricing, free tier and limits](#pricing-free-tier-and-limits)
|
|
29
|
+
- [Tool selection](#tool-selection)
|
|
30
|
+
- [How it compares](#how-it-compares)
|
|
31
|
+
- [FAQ](#faq)
|
|
32
|
+
- [HasData links](#hasdata-links)
|
|
33
|
+
- [Development](#development)
|
|
34
|
+
- [Contributing](#contributing)
|
|
35
|
+
- [License](#license)
|
|
36
|
+
|
|
37
|
+
## What you need
|
|
38
|
+
|
|
39
|
+
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=booking-mcp), free to create with no card, and the trial covers 100 calls at the 10-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 Booking.com account anywhere in the flow. A client that only speaks stdio reaches it through a thin launcher, published as `@hasdata/booking-mcp` on npm and `hasdata-booking-mcp` on PyPI, shown below.
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
| Field | Value |
|
|
46
|
+
| :--- | :--- |
|
|
47
|
+
| URL | `https://mcp.hasdata.com/api/mcp?apis=booking` |
|
|
48
|
+
| Transport | HTTP, streamable |
|
|
49
|
+
| Auth header | `x-api-key: HASDATA_API_KEY` |
|
|
50
|
+
|
|
51
|
+
Clients with OAuth support can add the same URL as a connector and sign in without putting a key in a config file.
|
|
52
|
+
|
|
53
|
+
<details>
|
|
54
|
+
<summary><b>Claude Code</b></summary>
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
claude mcp add --transport http booking "https://mcp.hasdata.com/api/mcp?apis=booking" \
|
|
58
|
+
--header "x-api-key: HASDATA_API_KEY"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
</details>
|
|
62
|
+
|
|
63
|
+
<details>
|
|
64
|
+
<summary><b>Claude Desktop</b></summary>
|
|
65
|
+
|
|
66
|
+
Settings, then Connectors, then Add custom connector, then paste `https://mcp.hasdata.com/api/mcp?apis=booking` and sign in.
|
|
67
|
+
|
|
68
|
+
For the config-file route, Claude Desktop loads only local (stdio) servers, so it reaches a remote server through a stdio launcher. The `@hasdata/booking-mcp` package is that launcher, and it reads the key from the environment. Add this to `claude_desktop_config.json`:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"booking": {
|
|
74
|
+
"command": "npx",
|
|
75
|
+
"args": ["-y", "@hasdata/booking-mcp"],
|
|
76
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
For Python instead of Node, swap the launcher for the PyPI package, which `uvx` runs without a manual install:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"mcpServers": {
|
|
87
|
+
"booking": {
|
|
88
|
+
"command": "uvx",
|
|
89
|
+
"args": ["hasdata-booking-mcp"],
|
|
90
|
+
"env": { "HASDATA_API_KEY": "YOUR_KEY" }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
</details>
|
|
97
|
+
|
|
98
|
+
<details>
|
|
99
|
+
<summary><b>Cursor</b></summary>
|
|
100
|
+
|
|
101
|
+
`~/.cursor/mcp.json` for every project, or `.cursor/mcp.json` for one:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"booking": {
|
|
107
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=booking",
|
|
108
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
<details>
|
|
117
|
+
<summary><b>Windsurf</b></summary>
|
|
118
|
+
|
|
119
|
+
`~/.codeium/windsurf/mcp_config.json`. Windsurf calls the field `serverUrl`, not `url`:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"mcpServers": {
|
|
124
|
+
"booking": {
|
|
125
|
+
"serverUrl": "https://mcp.hasdata.com/api/mcp?apis=booking",
|
|
126
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
</details>
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary><b>VS Code</b></summary>
|
|
136
|
+
|
|
137
|
+
`.vscode/mcp.json` in the workspace:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"servers": {
|
|
142
|
+
"booking": {
|
|
143
|
+
"type": "http",
|
|
144
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=booking",
|
|
145
|
+
"headers": { "x-api-key": "HASDATA_API_KEY" }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
</details>
|
|
152
|
+
|
|
153
|
+
## Example prompts
|
|
154
|
+
|
|
155
|
+
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 10 credits.
|
|
156
|
+
|
|
157
|
+
> Search Booking.com for hotels in Paris from September 15 to 18 for two adults, and give me the ten best-reviewed under $700 for the stay.
|
|
158
|
+
|
|
159
|
+
*One call, 10 credits. Price, review score and location come back on the search result.*
|
|
160
|
+
|
|
161
|
+
> Take the top result and pull its full detail: facilities, house rules, the room options, and the category ratings.
|
|
162
|
+
|
|
163
|
+
*One call, 10 credits. Those live on the property page, which the details tool reads by URL and dates.*
|
|
164
|
+
|
|
165
|
+
> Find four-star hotels in Paris with free cancellation near the center, and list price and review score.
|
|
166
|
+
|
|
167
|
+
*One call, 10 credits. Star rating, cancellation policy and distance are filters on the one request.*
|
|
168
|
+
|
|
169
|
+
> Compare the cheapest stay in Paris against Rome for the same dates.
|
|
170
|
+
|
|
171
|
+
*Two calls, 20 credits, one search per city.*
|
|
172
|
+
|
|
173
|
+
The property tool needs the same dates and guest counts as the search, because availability and price depend on the window. A search to shortlist plus a detail call on three properties is one search and three property calls.
|
|
174
|
+
|
|
175
|
+
## Tools
|
|
176
|
+
|
|
177
|
+
Two tools, read-only. Samples below are trimmed from real calls, and prices move constantly. Read them as shapes. Each tool name links to its endpoint reference, which carries the full field list.
|
|
178
|
+
|
|
179
|
+
The samples are 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.
|
|
180
|
+
|
|
181
|
+
### Get Booking.com search results
|
|
182
|
+
|
|
183
|
+
[`hasdata_booking_search_getBookingSearchResults`](https://docs.hasdata.com/apis/booking/search?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp)
|
|
184
|
+
|
|
185
|
+
A page of stays by destination and dates.
|
|
186
|
+
|
|
187
|
+
| Parameter | Type | Required | Notes |
|
|
188
|
+
| :--- | :--- | :--- | :--- |
|
|
189
|
+
| `keyword` | string | yes | Destination, such as `Paris` or a specific property name |
|
|
190
|
+
| `checkInDate` / `checkOutDate` | string | yes | `YYYY-MM-DD`, check-in in the future and before check-out |
|
|
191
|
+
| `rooms` / `adults` / `children` | number | yes | Guest composition. Pass `children: 0` when there are none |
|
|
192
|
+
| `childrenAges` | string | | Comma-separated ages, required when `children > 0` |
|
|
193
|
+
| `sort` | string | | `priceLowestFirst`, `ratingHighToLow`, `bestReviewedAndLowestPrice`, `distanceFromDowntown` and more |
|
|
194
|
+
| `propertyType__` / `rating__` / `reviewScore__` | array | | Property type, star rating, and guest-score buckets |
|
|
195
|
+
| `facilities__` / `roomFacilities__` / `reservationPolicy__` | array | | Facility, in-room and cancellation filters |
|
|
196
|
+
| `price_min_` / `price_max_` | number | | Total-stay price band |
|
|
197
|
+
| `page` | number | | About 25 results per page, `2` for the next page |
|
|
198
|
+
|
|
199
|
+
The reference documents the full filter set, including distance, meals, accessibility, bed preference and travel group.
|
|
200
|
+
|
|
201
|
+
Returns `searchInformation`, a `results` array, and `pagination` with `page`, `totalResults` and `totalPages`. Each result carries `hotelId`, `title`, `url`, the offered `room` and `bedTypes`, a `location` object, a `policies` object, a `price` object, the star `rating`, a `reviews` object with `score`, `count` and a text label, and a `photo`.
|
|
202
|
+
|
|
203
|
+
> The discount field in `price` is spelled `dicsount` (`dicsountRaw` and `dicsountParsed`), which mirrors the upstream key. Read that spelling, not `discount`. Also note `rating` is the official star rating while `reviews.score` is the guest score out of 10, two different numbers.
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"hotelId": 50724,
|
|
208
|
+
"title": "Hôtel du Jardin des Plantes",
|
|
209
|
+
"url": "https://www.booking.com/hotel/fr/timjardindesplantes.html",
|
|
210
|
+
"room": "Comfort Double Room",
|
|
211
|
+
"location": { "city": "Paris", "address": "5 rue Linné", "mainDistance": "0.9 miles from downtown", "centrallyLocated": true },
|
|
212
|
+
"policies": { "freeCancellation": true, "noPrepayment": true },
|
|
213
|
+
"price": { "pricePerStayParsed": 451.36, "priceBeforeDiscountParsed": 885.03, "dicsountParsed": 433.66, "currency": "USD" },
|
|
214
|
+
"rating": 3,
|
|
215
|
+
"reviews": { "score": 7.5, "count": 1721, "text": "Good" }
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Get Booking.com property details
|
|
220
|
+
|
|
221
|
+
[`hasdata_booking_place_getBookingPlaceDetails`](https://docs.hasdata.com/apis/booking/place?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp)
|
|
222
|
+
|
|
223
|
+
One property in full, by its URL and the stay window.
|
|
224
|
+
|
|
225
|
+
| Parameter | Type | Required | Notes |
|
|
226
|
+
| :--- | :--- | :--- | :--- |
|
|
227
|
+
| `url` | string | yes | A Booking.com property URL, the `url` field from a search result |
|
|
228
|
+
| `checkInDate` / `checkOutDate` | string | yes | `YYYY-MM-DD`, the window to price and check availability for |
|
|
229
|
+
| `rooms` / `adults` / `children` | number | yes | Guest composition, same meaning as the search tool |
|
|
230
|
+
| `childrenAges` | string | | Comma-separated ages, required when `children > 0` |
|
|
231
|
+
|
|
232
|
+
Returns the page as sections rather than one flat object: `overview` (`id`, `title`, `propertyType`, a structured `address`, a `description`, `highlights`, `mostPopularFacilities` and `photos`), `bookingDetails` (the window and currency the prices reflect), a `rooms` array of the available suites each with `name`, `beds`, `facilities` and priced `variants`, a `facilities` list, `houseRules`, a `ratings` array of category scores, `reviews`, and `questionsAndAnswers`.
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"overview": {
|
|
237
|
+
"id": "50724",
|
|
238
|
+
"title": "Hôtel du Jardin des Plantes",
|
|
239
|
+
"propertyType": "HOTEL",
|
|
240
|
+
"address": { "country": "France", "zipcode": "75005" },
|
|
241
|
+
"mostPopularFacilities": ["Non-smoking rooms", "Free Wifi", "24-hour front desk"]
|
|
242
|
+
},
|
|
243
|
+
"bookingDetails": { "checkIn": "2026-09-15", "checkOut": "2026-09-18", "adults": 2, "rooms": 1, "currency": "USD" },
|
|
244
|
+
"ratings": [
|
|
245
|
+
{ "label": "Average", "value": 7.5, "votes": 1721 },
|
|
246
|
+
{ "label": "Cleanliness", "value": 7.8 }
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Errors and failure paths
|
|
252
|
+
|
|
253
|
+
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.
|
|
254
|
+
|
|
255
|
+
**A wrong key surfaces as tool output, not as a failed connection.** `tools/list` accepts any non-empty key and returns both tools, 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.
|
|
256
|
+
|
|
257
|
+
**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.
|
|
258
|
+
|
|
259
|
+
**An argument that breaks a 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 `children` count without matching `childrenAges`, or a check-out on or before check-in, is caught here.
|
|
260
|
+
|
|
261
|
+
**A search with no availability returns a successful result with an empty `results` array**, not an error. A destination and window with nothing open still comes back with `requestMetadata.status` set to `ok`. Test for the array length before you iterate.
|
|
262
|
+
|
|
263
|
+
**A property URL that no longer resolves returns 400** with `requestMetadata.status` set to `error`.
|
|
264
|
+
|
|
265
|
+
Results that carry data also carry a `requestMetadata.id` worth quoting in support.
|
|
266
|
+
|
|
267
|
+
## Pricing, free tier and limits
|
|
268
|
+
|
|
269
|
+
Each Booking.com tool costs **10 credits per successful call**. Response size does not change the price. A search page of 25 stays costs the same as one with two.
|
|
270
|
+
|
|
271
|
+
The free trial is **1,000 credits over 30 days with no card**, which is 100 Booking.com calls. 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.
|
|
272
|
+
|
|
273
|
+
Paid plans start at **$49 a month** for 200,000 credits, which is 20,000 calls. The unit price falls with volume, from **$2.45 per 1,000 calls** on the entry plan to **$0.99** on Business, **$0.83** on Growth and **$0.75** on the largest [high-volume plans](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp).
|
|
274
|
+
|
|
275
|
+
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.
|
|
276
|
+
|
|
277
|
+
A request that comes back non-200 is not billed. A successful call that finds nothing is still a call.
|
|
278
|
+
|
|
279
|
+
## Tool selection
|
|
280
|
+
|
|
281
|
+
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.
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
?apis=booking the two tools in this repo
|
|
285
|
+
?apis=booking,airbnb add Airbnb stays
|
|
286
|
+
?apis=booking,google_travel add Google Hotels and Flights
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The parameter takes provider names like `booking` and individual API names like `booking_search`. 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.
|
|
290
|
+
|
|
291
|
+
## How it compares
|
|
292
|
+
|
|
293
|
+
Booking.com's own programs, the Demand API and the affiliate partner network, are for approved partners who send bookings and earn commission, not a self-serve way to read the public market. For searching stays and reading arbitrary properties, scraping the public pages is the route, and this server does that behind a stable schema.
|
|
294
|
+
|
|
295
|
+
| | Booking.com partner programs | This server |
|
|
296
|
+
| :--- | :--- | :--- |
|
|
297
|
+
| Purpose | Send bookings as an approved affiliate | Read the public market |
|
|
298
|
+
| Access | Partner approval | One key and one URL |
|
|
299
|
+
| Search across the market | Within partner terms | Yes, with rich filters |
|
|
300
|
+
| Setup | Business onboarding | None |
|
|
301
|
+
| Output | Partner feeds | Structured JSON, price and score pre-parsed |
|
|
302
|
+
|
|
303
|
+
**What this server does not do.** No booking, no payment, no partner commission, no account data. It reads what a signed-out visitor can see on Booking.com.
|
|
304
|
+
|
|
305
|
+
## FAQ
|
|
306
|
+
|
|
307
|
+
### Is there an official Booking.com MCP server?
|
|
308
|
+
|
|
309
|
+
Booking.com does not publish one. This one is maintained by HasData and reads public pages, which is why it needs no Booking.com account.
|
|
310
|
+
|
|
311
|
+
### What is a Booking.com MCP server?
|
|
312
|
+
|
|
313
|
+
A server that exposes Booking.com data as tools an AI client can call. The client sends a tool call over the Model Context Protocol, the server fetches the data and returns structured JSON, and the model works with the result. This one exposes two tools and runs remotely.
|
|
314
|
+
|
|
315
|
+
### Do I need a Booking.com account or partner approval?
|
|
316
|
+
|
|
317
|
+
No. The only credential is your HasData key. There is no partner onboarding, because the tools read public Booking.com pages.
|
|
318
|
+
|
|
319
|
+
### Why does the property tool need dates?
|
|
320
|
+
|
|
321
|
+
Because availability, room options and price all depend on the stay window. Pass the same `checkInDate`, `checkOutDate` and guest counts you searched with, and the detail reflects that window.
|
|
322
|
+
|
|
323
|
+
### What is the difference between rating and review score?
|
|
324
|
+
|
|
325
|
+
`rating` is the official star rating of the property. `reviews.score` is the guest review score out of 10. A three-star hotel can carry a 9.0 guest score, so read the one you mean.
|
|
326
|
+
|
|
327
|
+
### Can I use this together with other HasData APIs?
|
|
328
|
+
|
|
329
|
+
Yes. The `apis` parameter takes a list, and `?apis=booking,airbnb` gives your agent Booking.com plus Airbnb. [Drop the parameter](#tool-selection) and you get everything.
|
|
330
|
+
|
|
331
|
+
### Is HasData affiliated with Booking.com?
|
|
332
|
+
|
|
333
|
+
No. HasData is an independent service and is not affiliated with, endorsed by, or sponsored by Booking.com. Booking.com is a trademark of its respective owner.
|
|
334
|
+
|
|
335
|
+
### Compliance and personal data
|
|
336
|
+
|
|
337
|
+
HasData accesses publicly available data only. A platform's terms may restrict automated access, and you are responsible for your own compliance. Where the data you collect includes personal information, make sure you have a lawful basis for it under GDPR, CCPA or the equivalent rules in your jurisdiction.
|
|
338
|
+
|
|
339
|
+
## HasData links
|
|
340
|
+
|
|
341
|
+
| | |
|
|
342
|
+
| :--- | :--- |
|
|
343
|
+
| Product page and request builder | [Booking.com Scraper API](https://hasdata.com/apis/booking-api?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
344
|
+
| Server documentation | [MCP server docs](https://docs.hasdata.com/mcp-server?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
345
|
+
| All 57 tools in one server | [HasData/hasdata-mcp](https://github.com/HasData/hasdata-mcp) |
|
|
346
|
+
| Client walkthroughs | [MCP clients and integrations](https://hasdata.com/integrations/mcp?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
347
|
+
| Everything else we scrape | [Booking.com Scraper API and 54 more](https://hasdata.com/apis/?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
348
|
+
| Plans and credit costs | [Plans and credit costs](https://hasdata.com/prices?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
349
|
+
| Keys and usage | [HasData dashboard](https://app.hasdata.com?utm_source=github&utm_medium=syndication&utm_campaign=booking-mcp) |
|
|
350
|
+
| Node launcher on npm | [@hasdata/booking-mcp](https://www.npmjs.com/package/@hasdata/booking-mcp) |
|
|
351
|
+
| Python launcher on PyPI | [hasdata-booking-mcp](https://pypi.org/project/hasdata-booking-mcp/) |
|
|
352
|
+
|
|
353
|
+
## Development
|
|
354
|
+
|
|
355
|
+
This repository is configuration and documentation for a remote server. There is no build step and nothing to containerize.
|
|
356
|
+
|
|
357
|
+
The tests in `test/` assert the tool contract, the part that can break without a commit here. They check that `?apis=booking` returns exactly two tools, that every tool still declares its required parameters, that no name changed, and that the key in use is actually accepted. That last check calls a tool for real and costs 10 credits, which is the price of a canary that can fail for the right reason.
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
# macOS and Linux
|
|
361
|
+
HASDATA_API_KEY=your_key_here npm test
|
|
362
|
+
|
|
363
|
+
# Windows PowerShell
|
|
364
|
+
$env:HASDATA_API_KEY="your_key_here"; npm test
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
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.
|
|
368
|
+
|
|
369
|
+
## Contributing
|
|
370
|
+
|
|
371
|
+
Corrections to the tool tables and the response samples 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.
|
|
372
|
+
|
|
373
|
+
## License
|
|
374
|
+
|
|
375
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Thin launcher for HasData's hosted Booking.com 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=booking"
|
|
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 Booking.com 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=booking';
|
|
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,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hasdata/booking-mcp",
|
|
3
|
+
"mcpName": "com.hasdata/booking",
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"description": "MCP server for Booking.com through HasData's hosted API: search stays by destination and dates, and read a single property in full. No Booking.com account.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"hasdata-booking-mcp": "index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.mjs",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "node --test"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"mcp-remote": "^0.1.43"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/HasData/booking-mcp.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://hasdata.com/apis/booking-api",
|
|
30
|
+
"keywords": [
|
|
31
|
+
"mcp",
|
|
32
|
+
"booking",
|
|
33
|
+
"booking-com",
|
|
34
|
+
"booking-mcp",
|
|
35
|
+
"hotels",
|
|
36
|
+
"travel",
|
|
37
|
+
"model-context-protocol",
|
|
38
|
+
"hasdata",
|
|
39
|
+
"scraper"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "hasdata-booking-mcp"
|
|
3
|
+
version = "1.0.1"
|
|
4
|
+
description = "MCP server for Booking.com through HasData's hosted API. No Booking.com account."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
keywords = ["mcp", "booking", "booking-com", "hotels", "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/booking-api"
|
|
14
|
+
Repository = "https://github.com/HasData/booking-mcp"
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
hasdata-booking-mcp = "hasdata_booking_mcp:main"
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["hatchling"]
|
|
21
|
+
build-backend = "hatchling.build"
|
|
22
|
+
|
|
23
|
+
[tool.hatch.build.targets.wheel]
|
|
24
|
+
packages = ["hasdata_booking_mcp"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "com.hasdata/booking",
|
|
4
|
+
"title": "HasData Booking.com",
|
|
5
|
+
"description": "Booking.com stays by destination and dates, and full property details, as structured JSON.",
|
|
6
|
+
"version": "1.0.1",
|
|
7
|
+
"websiteUrl": "https://hasdata.com/apis/booking-api",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/HasData/booking-mcp",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://mcp.hasdata.com/api/mcp?apis=booking",
|
|
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/booking-mcp",
|
|
30
|
+
"version": "1.0.1",
|
|
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,139 @@
|
|
|
1
|
+
// Tool contract test.
|
|
2
|
+
//
|
|
3
|
+
// The README promises two tools with specific names 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 a 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
|
+
// 10 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=booking';
|
|
17
|
+
const KEY = process.env.HASDATA_API_KEY;
|
|
18
|
+
const TIMEOUT_MS = 30_000;
|
|
19
|
+
|
|
20
|
+
const EXPECTED = {
|
|
21
|
+
hasdata_booking_search_getBookingSearchResults: ['keyword', 'checkInDate', 'checkOutDate', 'rooms', 'adults', 'children'],
|
|
22
|
+
hasdata_booking_place_getBookingPlaceDetails: ['url', 'checkInDate', 'checkOutDate', 'rooms', 'adults', 'children'],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// A streamable HTTP body arrives either as plain JSON or as server-sent events. One SSE event
|
|
26
|
+
// can span several data: lines, several events can share one response, and a server is free to
|
|
27
|
+
// send progress notifications before the answer. So collect every event and pick the message
|
|
28
|
+
// carrying our request id instead of trusting the first data: line.
|
|
29
|
+
function parseRpc(raw, id) {
|
|
30
|
+
const trimmed = raw.trim();
|
|
31
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[')) return JSON.parse(trimmed);
|
|
32
|
+
|
|
33
|
+
const messages = [];
|
|
34
|
+
for (const event of trimmed.split(/\r?\n\r?\n+/)) {
|
|
35
|
+
const data = event
|
|
36
|
+
.split(/\r?\n/)
|
|
37
|
+
.filter((l) => l.startsWith('data:'))
|
|
38
|
+
.map((l) => l.slice(5).replace(/^ /, ''))
|
|
39
|
+
.join('\n');
|
|
40
|
+
if (!data || data === '[DONE]') continue;
|
|
41
|
+
try {
|
|
42
|
+
messages.push(JSON.parse(data));
|
|
43
|
+
} catch {
|
|
44
|
+
// A keep-alive or a partial event is not our response.
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
assert.ok(messages.length, `no JSON-RPC message in the response: ${raw.slice(0, 300)}`);
|
|
48
|
+
const match = messages.find((m) => m.id === id);
|
|
49
|
+
assert.ok(match, `no message with id ${id} in the response: ${raw.slice(0, 300)}`);
|
|
50
|
+
return match;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let nextId = 1;
|
|
54
|
+
|
|
55
|
+
async function rpc(method, params = {}) {
|
|
56
|
+
const id = nextId++;
|
|
57
|
+
const res = await fetch(ENDPOINT, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: {
|
|
60
|
+
'x-api-key': KEY,
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
// The server answers over streamable HTTP, so accept both a plain body and a stream.
|
|
63
|
+
Accept: 'application/json, text/event-stream',
|
|
64
|
+
},
|
|
65
|
+
body: JSON.stringify({ jsonrpc: '2.0', id, method, params }),
|
|
66
|
+
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
67
|
+
});
|
|
68
|
+
assert.equal(res.status, 200, `${method} returned ${res.status}`);
|
|
69
|
+
const raw = await res.text();
|
|
70
|
+
return { raw, body: parseRpc(raw, id) };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// One network round trip for every test that needs the list.
|
|
74
|
+
let toolsPromise;
|
|
75
|
+
function listTools() {
|
|
76
|
+
toolsPromise ??= rpc('tools/list').then(({ body }) => {
|
|
77
|
+
assert.ok(body.result?.tools, 'the response carried no result.tools');
|
|
78
|
+
return body.result.tools;
|
|
79
|
+
});
|
|
80
|
+
return toolsPromise;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const live = { skip: KEY ? false : 'HASDATA_API_KEY is not set, skipping the live checks' };
|
|
84
|
+
|
|
85
|
+
test('apis=booking exposes exactly two tools', live, async () => {
|
|
86
|
+
const tools = await listTools();
|
|
87
|
+
const names = tools.map((t) => t.name).sort().join(', ');
|
|
88
|
+
assert.equal(
|
|
89
|
+
tools.length,
|
|
90
|
+
Object.keys(EXPECTED).length,
|
|
91
|
+
`expected ${Object.keys(EXPECTED).length} tools, got ${tools.length}: ${names}`
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('the tool names have not changed', live, async () => {
|
|
96
|
+
const tools = await listTools();
|
|
97
|
+
const names = new Set(tools.map((t) => t.name));
|
|
98
|
+
for (const expected of Object.keys(EXPECTED)) {
|
|
99
|
+
assert.ok(names.has(expected), `tool ${expected} is missing from the list`);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('every tool still declares its required parameter', live, async () => {
|
|
104
|
+
const tools = await listTools();
|
|
105
|
+
for (const tool of tools) {
|
|
106
|
+
const required = tool.inputSchema?.required ?? [];
|
|
107
|
+
const want = EXPECTED[tool.name];
|
|
108
|
+
assert.ok(want, `tool ${tool.name} is not covered by this test`);
|
|
109
|
+
for (const param of want) {
|
|
110
|
+
assert.ok(
|
|
111
|
+
required.includes(param),
|
|
112
|
+
`${tool.name} should require ${param}, declares: ${required.join(', ') || 'nothing'}`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('every tool carries a description', live, async () => {
|
|
119
|
+
const tools = await listTools();
|
|
120
|
+
for (const tool of tools) {
|
|
121
|
+
assert.ok(
|
|
122
|
+
(tool.description || '').trim().length > 20,
|
|
123
|
+
`${tool.name} has an empty or near-empty description`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('the key is accepted by HasData', live, async () => {
|
|
129
|
+
// Compute the dates at run time. A hardcoded future date silently becomes a past date and
|
|
130
|
+
// then Booking.com rejects the check-in, turning this canary red for the wrong reason.
|
|
131
|
+
const checkInDate = new Date(Date.now() + 30 * 86_400_000).toISOString().slice(0, 10);
|
|
132
|
+
const checkOutDate = new Date(Date.now() + 33 * 86_400_000).toISOString().slice(0, 10);
|
|
133
|
+
const { raw } = await rpc('tools/call', {
|
|
134
|
+
name: 'hasdata_booking_search_getBookingSearchResults',
|
|
135
|
+
arguments: { keyword: 'Paris', checkInDate, checkOutDate, rooms: 1, adults: 2, children: 0 },
|
|
136
|
+
});
|
|
137
|
+
assert.ok(!raw.includes('401 Unauthorized'), 'HasData rejected the key');
|
|
138
|
+
assert.ok(!raw.includes('"isError":true'), `the tool call failed: ${raw.slice(0, 300)}`);
|
|
139
|
+
});
|