Skip to main content
Glama
Beijing to US Flight Deals MCP Server

Beijing to US Flight Deals MCP Server

by zerolbsony
README.md
# Beijing to US Flight Deals MCP Server

An MCP server that searches Amadeus flight offers from Beijing to Los Angeles, San Francisco, and New York. It checks each departure date in an inclusive window of up to 14 days and returns the lowest-priced offers for each destination, using itinerary duration and departure time as tie-breakers.

## Research and data source

This project uses the Amadeus Self-Service Flight Offers Search API. Amadeus uses OAuth 2.0 client credentials for API authentication and exposes flight offers through `GET /v2/shopping/flight-offers`. The server searches the Beijing city code `BJS` and the destination codes `LAX`, `SFO`, and `NYC`.

- [Amadeus Flight Offers Search API reference](https://developers.amadeus.com/self-service/category/flights/api-doc/flight-offers-search/api-reference)
- [Amadeus API authentication guide](https://developers.amadeus.com/self-service/apis-docs/guides/developer-guides/API-key/)
- [Model Context Protocol](https://modelcontextprotocol.io/)

Flight search data and API access depend on the Amadeus account and environment. The test environment may return limited or representative data. This server reports search offers and does not book tickets. Prices and inventory can change, so users should recheck an offer with the airline or booking provider before purchase.

## Setup

1. Create an Amadeus for Developers application and obtain its API key and secret.
2. Install Python 3.10 or later.
3. Install dependencies with `python -m pip install -r requirements.txt`.
4. Set `AMADEUS_CLIENT_ID` and `AMADEUS_CLIENT_SECRET` in the environment. `AMADEUS_ENV` defaults to `test`. Set it to `production` for production API credentials and access.
5. Run `python server.py` as an MCP server over stdio.

Never commit API credentials. `.env.example` lists the supported environment variables.

## MCP capabilities

- Tool `search_beijing_us_fares` searches one-way or round-trip fares across the three destinations and ranks offers by total fare, duration, then departure time.
- Resource `flights://supported-routes` describes the supported routes and search limits.
- Prompt `compare_beijing_flight_fares` guides an assistant to compare offers and report missing results and fare caveats.

Example tool arguments:

```json
{
  "start_date": "2026-12-10",
  "end_date": "2026-12-14",
  "adults": 1,
  "trip_type": "one_way",
  "currency_code": "CNY",
  "results_per_destination": 3
}
```

For a round trip, set `trip_type` to `round_trip` and provide `return_date` after the departure window. A maximum of 14 departure dates can be queried per request. Searches make one API call per destination and departure date, capped at five concurrent requests.

## Tests

Run the offline tests with:

```bash
python -m unittest discover -s tests -v
```

Tests use a fake Amadeus client and do not require API credentials or make network requests.