An MCP (Model Context Protocol) server that wraps the Google Flights API via SerpAPI, enabling Claude Code to search and analyze flight data.
- Primary Flight Search: Search for round-trip, one-way, or multi-city flights
- Return Flight Lookup: Fetch return/next-leg options using departure tokens
- Booking Options: Get bookable providers and prices using booking tokens
- Node.js 18+
- SerpAPI account with API key (Get one here)
- Clone this repository:
git clone <repository-url>
cd google_flights_mcp- Install dependencies:
npm install- Create
.envfile from the example:
cp .env.example .env- Add your SerpAPI key to
.env:
SERPAPI_API_KEY=your_actual_api_key_here
- Build the TypeScript project:
npm run buildAdd this server to your Claude Desktop configuration file:
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"google-flights": {
"command": "node",
"args": ["/absolute/path/to/google_flights_mcp/build/index.js"],
"env": {
"SERPAPI_API_KEY": "your_api_key_here"
}
}
}
}Edit %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"google-flights": {
"command": "node",
"args": ["C:\\absolute\\path\\to\\google_flights_mcp\\build\\index.js"],
"env": {
"SERPAPI_API_KEY": "your_api_key_here"
}
}
}
}Edit ~/.config/Claude/claude_desktop_config.json (same format as macOS)
Perform the initial flights search with extensive filtering options.
Required Parameters:
departure_id(string): Departure airport IATA code (e.g., "SFO")arrival_id(string): Arrival airport IATA code (e.g., "JFK")outbound_date(string): Departure date in YYYY-MM-DD format
Common Optional Parameters:
return_date(string): Return date (required for round trips)type(1|2|3): Trip type - 1=round trip, 2=one way, 3=multi-citytravel_class(1|2|3|4): 1=Economy, 2=Premium Economy, 3=Business, 4=Firstadults(number): Number of adult passengers (default: 1)children(number): Number of child passengersstops(0|1|2|3): 0=Any, 1=Nonstop, 2=≤1 stop, 3=≤2 stopssort_by(1|2|3|4|5|6): 1=Top, 2=Price, 3=Dep time, 4=Arr time, 5=Duration, 6=Emissionsmax_price(number): Maximum price filterinclude_airlines(string): Comma-separated airline codes (e.g., "UA,AA")exclude_airlines(string): Comma-separated airline codes to excludebags(number): Number of carry-on bagscurrency(string): Currency code (e.g., "USD")gl(string): Country code (e.g., "us")hl(string): Language code (e.g., "en")deep_search(boolean): Enable for browser-parity results (slower)
Example:
{
"departure_id": "SFO",
"arrival_id": "JFK",
"outbound_date": "2025-12-15",
"return_date": "2025-12-22",
"type": 1,
"travel_class": 1,
"adults": 1,
"stops": 1,
"sort_by": 2,
"currency": "USD",
"gl": "us"
}Fetch return or next-leg flight options using a departure token from previous search results.
Parameters:
departure_token(string, required): Token from previous searchno_cache(boolean, optional): Bypass cache
Get bookable providers and prices for a selected flight.
Parameters:
booking_token(string, required): Token from selected flightno_cache(boolean, optional): Bypass cache
All tools return structured JSON data from SerpAPI, including:
best_flights: Array of top recommended flightsother_flights: Array of additional flight optionsprice_insights: Price trends and typical rangesairports: Metadata about departure/arrival airportssearch_metadata: Request status and timing info
Each flight includes:
flights: Segment details (departure/arrival times, airline, flight number, etc.)layovers: Layover informationtotal_duration: Total trip duration in minutescarbon_emissions: Carbon footprint dataprice: Price in selected currencydeparture_token: Use for return flight lookupbooking_token: Use for booking options
npm run buildnpm run watchnpm run devThe server handles various error scenarios:
- Missing API key
- Invalid parameters
- HTTP errors from SerpAPI
- API-level errors in responses
Errors are returned with descriptive messages to help debugging.
Once configured, you can ask Claude things like:
- "Find me flights from San Francisco to New York for December 15-22"
- "Search for one-way business class flights from LAX to Tokyo on January 5th"
- "Show me nonstop flights under $500 from Chicago to Miami next month"
- "What are the cheapest round-trip flights from Boston to London in March?"
MIT