Skip to main content
Glama

search_flights

Read-onlyIdempotent

Search real-time flight prices and schedules from 800+ airlines between two cities. Filter by date, cabin class, stops, and passengers to find and compare airfares.

Instructions

Search airline flights / airfares between two cities by date, cabin class (economy / premium economy / business / first), and number of passengers. Returns available flights from 800+ airlines (Duffel) with real-time pricing, schedules, and stops. Uses IATA airport codes (e.g., MIA, JFK, LAX, LHR). Use this when the user wants to book a flight, fly somewhere, find airfare, or compare airlines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
originYesIATA origin airport code (e.g., 'MIA', 'JFK', 'LAX')
destinationYesIATA destination airport code
departure_dateYesDeparture date (YYYY-MM-DD)
return_dateNoReturn date for round-trip (YYYY-MM-DD). Omit for one-way.
passengersNoNumber of passengers (1-9, default: 1)
cabin_classNoCabin class (default: economy)
max_price_usdNoMaximum total price in USD
nonstop_onlyNoOnly show nonstop flights (default: false)

Implementation Reference

  • src/server.ts:204-226 (registration)
    Tool definition (name, description, inputSchema) for 'search_flights' registered in ALL_TOOLS array. This is where the tool is declared with its schema for MCP discovery.
    {
      name: "search_flights",
      description:
        "Search airline flights / airfares between two cities by date, cabin class (economy / premium economy / business / first), and number of passengers. Returns available flights from 800+ airlines (Duffel) with real-time pricing, schedules, and stops. Uses IATA airport codes (e.g., MIA, JFK, LAX, LHR). Use this when the user wants to book a flight, fly somewhere, find airfare, or compare airlines.",
      inputSchema: {
        type: "object" as const,
        properties: {
          origin: { type: "string", description: "IATA origin airport code (e.g., 'MIA', 'JFK', 'LAX')" },
          destination: { type: "string", description: "IATA destination airport code" },
          departure_date: { type: "string", description: "Departure date (YYYY-MM-DD)" },
          return_date: { type: "string", description: "Return date for round-trip (YYYY-MM-DD). Omit for one-way." },
          passengers: { type: "number", description: "Number of passengers (1-9, default: 1)" },
          cabin_class: {
            type: "string",
            enum: ["economy", "premium_economy", "business", "first"],
            description: "Cabin class (default: economy)",
          },
          max_price_usd: { type: "number", description: "Maximum total price in USD" },
          nonstop_only: { type: "boolean", description: "Only show nonstop flights (default: false)" },
        },
        required: ["origin", "destination", "departure_date"],
      },
    },
  • Handler for 'search_flights' tool execution. Calls apiCall for POST /v1/flights/search with user args, then trims the response via trimFlightResponse.
    case "search_flights": {
      const result = await apiCall("POST", "/v1/flights/search", args);
      const trimmed = trimFlightResponse(result);
      return { content: [{ type: "text", text: JSON.stringify(trimmed, null, 2) }] };
    }
  • trimFlightResponse helper function that slices raw flight data to 25 results and maps fields (offer_id, airline, cabin_class, price, stops, outbound/inbound segments, etc.) for LLM consumption.
    function trimFlightResponse(raw: any, limit = 25): any {
      const data = Array.isArray(raw?.data) ? raw.data : [];
      const trimmed = data.slice(0, limit).map((f: any) => ({
        offer_id: f.offer_id || f.id,
        duffel_offer_id: f.duffel_offer_id,
        airline_name: f.airline_name || f.airline,
        airline_code: f.airline_code,
        flight_number: f.outbound?.[0]?.flight_number || f.flight_number,
        cabin_class: f.cabin_class,
        fare_brand: f.fare_brand,
        price_usd: f.price_usd,
        stops: f.stops,
        total_duration_minutes: f.total_duration_minutes,
        refundable: f.refundable,
        baggage: f.baggage,
        outbound: (f.outbound || []).map((s: any) => ({
          origin: s.origin,
          destination: s.destination,
          airline_code: s.airline_code,
          flight_number: s.flight_number,
          departure_time: s.departure_time,
          arrival_time: s.arrival_time,
          duration_minutes: s.duration_minutes,
          cabin_class: s.cabin_class,
        })),
        inbound: f.inbound ? (f.inbound || []).map((s: any) => ({
          origin: s.origin,
          destination: s.destination,
          airline_code: s.airline_code,
          flight_number: s.flight_number,
          departure_time: s.departure_time,
          arrival_time: s.arrival_time,
          duration_minutes: s.duration_minutes,
          cabin_class: s.cabin_class,
        })) : null,
        cancel_policy: (f.cancel_policy || "").slice(0, 200),
      }));
      return {
        data: trimmed,
        meta: { count: trimmed.length, total_returned: data.length, trimmed_for_llm: data.length > limit },
      };
    }
  • Input schema for search_flights defining properties: origin (required), destination (required), departure_date (required), return_date, passengers (1-9), cabin_class (economy/premium_economy/business/first), max_price_usd, nonstop_only.
    inputSchema: {
      type: "object" as const,
      properties: {
        origin: { type: "string", description: "IATA origin airport code (e.g., 'MIA', 'JFK', 'LAX')" },
        destination: { type: "string", description: "IATA destination airport code" },
        departure_date: { type: "string", description: "Departure date (YYYY-MM-DD)" },
        return_date: { type: "string", description: "Return date for round-trip (YYYY-MM-DD). Omit for one-way." },
        passengers: { type: "number", description: "Number of passengers (1-9, default: 1)" },
        cabin_class: {
          type: "string",
          enum: ["economy", "premium_economy", "business", "first"],
          description: "Cabin class (default: economy)",
        },
        max_price_usd: { type: "number", description: "Maximum total price in USD" },
        nonstop_only: { type: "boolean", description: "Only show nonstop flights (default: false)" },
      },
      required: ["origin", "destination", "departure_date"],
    },
Behavior4/5

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

Annotations already declare readOnlyHint, destructiveHint, idempotentHint, openWorldHint. The description adds behavioral context: 'Returns available flights from 800+ airlines (Duffel) with real-time pricing, schedules, and stops,' which goes beyond the annotations by specifying data source and scope.

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?

Two sentences, front-loaded with the core action ('Search airline flights / airfares...'), followed by key details and usage context. Every sentence is essential and concise.

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

Completeness4/5

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

Given 8 parameters and no output schema, the description covers purpose, parameters, data source, and usage. It mentions real-time pricing and stops, but lacks explicit return format details, which is acceptable without output schema.

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

Parameters4/5

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

Schema description coverage is 100%, baseline 3. The description adds value by explicitly listing cabin class options ('economy / premium economy / business / first') and giving IATA code examples (MIA, JFK, LAX, LHR), reinforcing parameter meaning beyond schema.

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?

The description clearly states it searches airline flights/airfares between two cities with specific parameters (date, cabin class, passengers) and explicitly states when to use it ('when the user wants to book a flight, fly somewhere, find airfare, or compare airlines'), distinguishing it from sibling search tools.

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

Usage Guidelines4/5

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

The description provides explicit when-to-use guidance ('Use this when the user wants to book a flight...') and context, but does not include explicit when-not-to-use or alternative tools, though the sibling list implies differentiation.

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/Autonomad1/autonomad-travel'

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