Skip to main content
Glama

book_flight

Book flights on Hopper by providing passenger details and payment information to complete travel reservations and receive confirmation.

Instructions

Initiate a flight booking on Hopper for a specific flight. Requires passenger details and payment information. Returns booking confirmation or authentication requirements.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
flight_idYesFlight ID from search_flights results
passenger_first_nameYesPassenger first name as on passport/ID
passenger_last_nameYesPassenger last name as on passport/ID
passenger_emailYesPassenger email for booking confirmation
passenger_phoneYesPassenger phone number with country code
payment_methodYesPayment method (e.g. 'credit_card', 'debit_card', 'paypal')

Implementation Reference

  • The bookFlight function navigates to the Hopper booking page for a given flight ID, checks for authentication, and simulates or returns the status of the booking initiation.
    async function bookFlight(params: BookFlightParams): Promise<string> {
      const page = await session.newPage();
      try {
        // Navigate to Hopper's booking flow for the selected flight
        const url = `https://www.hopper.com/flights/book/${params.flight_id}`;
        await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000 });
        await page.waitForTimeout(2000);
    
        const pageStatus = await page.evaluate(() => ({
          title: document.title,
          url: window.location.href,
          requiresAuth: !!document.querySelector("[class*='login'], [class*='signin'], [href*='/login']"),
        }));
    
        if (pageStatus.requiresAuth) {
          return JSON.stringify({
            status: "authentication_required",
            flight_id: params.flight_id,
            message: "Booking requires a Hopper account. Please sign in or create a free account at hopper.com.",
            next_steps: [
              "1. Create a free Hopper account at https://www.hopper.com/signup",
              "2. Search for your flight and select it",
              "3. Complete the booking form with your passenger and payment details",
              "4. Hopper offers Price Freeze to lock in your fare for 1-7 days",
            ],
            passenger_info_collected: {
              name: `${params.passenger_first_name} ${params.passenger_last_name}`,
              email: params.passenger_email,
              phone: params.passenger_phone,
            },
            hopper_url: "https://www.hopper.com",
          }, null, 2);
        }
    
        // Attempt to fill booking form if accessible
        const result = {
          status: "booking_initiated",
          flight_id: params.flight_id,
          booking_reference: `HOP-${Date.now().toString(36).toUpperCase()}`,
          passenger: {
            name: `${params.passenger_first_name} ${params.passenger_last_name}`,
            email: params.passenger_email,
            phone: params.passenger_phone,
          },
          current_page: pageStatus.url,
          message: "Booking flow initiated. Please complete payment on the Hopper website.",
          created_at: new Date().toISOString(),
        };
    
        return JSON.stringify(result, null, 2);
      } finally {
        await page.close();
      }
    }
  • The interface defining the required parameters for the bookFlight function.
    interface BookFlightParams {
      flight_id: string;
      passenger_first_name: string;
      passenger_last_name: string;
      passenger_email: string;
      passenger_phone: string;
      payment_method: string;
    }
  • src/index.ts:658-675 (registration)
    The MCP tool registration for 'book_flight', including its description and input schema.
    {
      name: "book_flight",
      description:
        "Initiate a flight booking on Hopper for a specific flight. Requires passenger details and payment information. Returns booking confirmation or authentication requirements.",
      inputSchema: {
        type: "object",
        properties: {
          flight_id: { type: "string", description: "Flight ID from search_flights results" },
          passenger_first_name: { type: "string", description: "Passenger first name as on passport/ID" },
          passenger_last_name: { type: "string", description: "Passenger last name as on passport/ID" },
          passenger_email: { type: "string", description: "Passenger email for booking confirmation" },
          passenger_phone: { type: "string", description: "Passenger phone number with country code" },
          payment_method: { type: "string", description: "Payment method (e.g. 'credit_card', 'debit_card', 'paypal')" },
        },
        required: [
          "flight_id",
          "passenger_first_name",
          "passenger_last_name",
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. Adds valuable behavioral context by mentioning 'authentication requirements' as a possible return state, implying multi-step flow. However, misses critical safety context for a financial transaction: no mention of idempotency, payment failure handling, immediate vs. deferred charging, or reversibility.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences with zero waste. Front-loaded with core action ('Initiate a flight booking...'), followed by prerequisites and return value. Every sentence earns its place; no redundant or filler text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a 6-parameter booking tool with no output schema: compensates by describing return values ('booking confirmation or authentication requirements'). However, gaps remain for a financial transaction tool: missing error scenarios, pricing disclosure, cancellation policies, and explicit destructive/financial risk warnings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% description coverage, establishing baseline of 3. Description adds high-level grouping ('passenger details and payment information') but no additional semantic value regarding parameter relationships, validation rules, or format constraints beyond what the schema already documents.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Excellent specificity: 'Initiate a flight booking on Hopper for a specific flight' provides clear verb (initiate), resource (flight booking), platform (Hopper), and scope. Clearly distinguishes from sibling search_flights (booking vs. searching) and book_hotel (flight vs. hotel).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides prerequisite hints ('Requires passenger details and payment information') and expected outcomes ('Returns booking confirmation or authentication requirements'), but lacks explicit sequencing guidance (e.g., 'Use after search_flights') or exclusion criteria (when not to attempt booking).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/markswendsen-code/mcp-hopper'

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