Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Flights MCP Server

An MCP (Model Context Protocol) server that wraps the Google Flights API via SerpAPI, enabling Claude Code to search and analyze flight data.

Features

  • 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

Prerequisites

Installation

  1. Clone this repository:
git clone <repository-url>
cd google_flights_mcp
  1. Install dependencies:
npm install
  1. Create .env file from the example:
cp .env.example .env
  1. Add your SerpAPI key to .env:
SERPAPI_API_KEY=your_actual_api_key_here
  1. Build the TypeScript project:
npm run build

Usage with Claude Desktop

Add this server to your Claude Desktop configuration file:

macOS

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"
      }
    }
  }
}

Windows

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"
      }
    }
  }
}

Linux

Edit ~/.config/Claude/claude_desktop_config.json (same format as macOS)

Available Tools

1. search_google_flights

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-city
  • travel_class (1|2|3|4): 1=Economy, 2=Premium Economy, 3=Business, 4=First
  • adults (number): Number of adult passengers (default: 1)
  • children (number): Number of child passengers
  • stops (0|1|2|3): 0=Any, 1=Nonstop, 2=≤1 stop, 3=≤2 stops
  • sort_by (1|2|3|4|5|6): 1=Top, 2=Price, 3=Dep time, 4=Arr time, 5=Duration, 6=Emissions
  • max_price (number): Maximum price filter
  • include_airlines (string): Comma-separated airline codes (e.g., "UA,AA")
  • exclude_airlines (string): Comma-separated airline codes to exclude
  • bags (number): Number of carry-on bags
  • currency (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"
}

2. get_return_flights

Fetch return or next-leg flight options using a departure token from previous search results.

Parameters:

  • departure_token (string, required): Token from previous search
  • no_cache (boolean, optional): Bypass cache

3. get_booking_options

Get bookable providers and prices for a selected flight.

Parameters:

  • booking_token (string, required): Token from selected flight
  • no_cache (boolean, optional): Bypass cache

Response Format

All tools return structured JSON data from SerpAPI, including:

  • best_flights: Array of top recommended flights
  • other_flights: Array of additional flight options
  • price_insights: Price trends and typical ranges
  • airports: Metadata about departure/arrival airports
  • search_metadata: Request status and timing info

Each flight includes:

  • flights: Segment details (departure/arrival times, airline, flight number, etc.)
  • layovers: Layover information
  • total_duration: Total trip duration in minutes
  • carbon_emissions: Carbon footprint data
  • price: Price in selected currency
  • departure_token: Use for return flight lookup
  • booking_token: Use for booking options

Development

Build

npm run build

Watch mode (rebuild on changes)

npm run watch

Run directly

npm run dev

Error Handling

The 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.

Example Queries for Claude

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?"

License

MIT

Links

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages