Skip to main content
Glama
HaroldLeo

Google Flights MCP Server

by HaroldLeo

generate_google_flights_url

Create Google Flights search URLs from natural language queries for flight searches, price comparisons, and itinerary planning with customizable parameters.

Instructions

Generate a Google Flights search URL that opens in the browser.
Creates search URLs using natural language queries.

Args:
    origin: Origin airport code (e.g., "SFO").
    destination: Destination airport code (e.g., "JFK").
    departure_date: Departure date (YYYY-MM-DD format).
    return_date: Return date for round-trip (YYYY-MM-DD format, optional).
    adults: Number of adult passengers (default: 1).
    children: Number of children (default: 0).
    seat_type: Fare class - economy/premium_economy/business/first (default: "economy").

Returns:
    JSON with the Google Flights URL.

Example Args:
    {"origin": "SFO", "destination": "JFK", "departure_date": "2025-07-20"}
    {"origin": "SFO", "destination": "JFK", "departure_date": "2025-07-20", "return_date": "2025-07-27"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
originYes
destinationYes
departure_dateYes
return_dateNo
adultsNo
childrenNo
seat_typeNoeconomy

Implementation Reference

  • Helper function that constructs a Google Flights URL (tfs parameter format) from flight parameters. This is the exact implementation for generating the Google Flights shareable link used in the fallback flight search.
    def create_booking_url(origin: str, destination: str, outbound_date: str, return_date: Optional[str] = None, seat_type: str = "economy", adults: int = 1) -> str:
        """
        Create Google Flights booking URL.
    
        Args:
            origin: Origin airport code
            destination: Destination airport code
            outbound_date: Departure date
            return_date: Return date (optional)
            seat_type: Cabin class
            adults: Number of passengers
    
        Returns:
            Google Flights URL
        """
        base_url = "https://www.google.com/travel/flights"
    
        # Build query params
        params = []
    
        # Add origin and destination
        params.append(f"f=0.{origin}.{destination}.{outbound_date}")
    
        if return_date:
            params.append(f"*{destination}.{origin}.{return_date}")
    
        # Add passengers
        params.append(f"1.{adults}.0.0.0")
    
        # Add class
        class_map = {"economy": "y", "premium_economy": "w", "business": "c", "first": "f"}
        class_code = class_map.get(seat_type.lower(), "y")
        params.append(class_code)
    
        query = ".".join(params)
    
        return f"{base_url}?tfs={query}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HaroldLeo/google-flights-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server