Skip to main content
Glama
AkekaratP

Flight + Stay Search MCP

by AkekaratP

search_flights

Search for flights by specifying origin, destination, dates, cabin class, and passenger count to find available travel options.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYesType of flight
originYesOrigin airport or city IATA code (e.g., SFO, NYC)
destinationYesDestination airport or city IATA code (e.g., LAX, LHR)
departureDateYesDeparture date in YYYY-MM-DD format
returnDateNoReturn date in YYYY-MM-DD format (required for round-trip)
departureTimeNoPreferred departure time window
arrivalTimeNoPreferred arrival time window
cabinClassYesCabin class
adultsNoNumber of adult passengers
maxConnectionsNoMaximum number of connections
additionalStopsNoAdditional stops for multi-city flights

Implementation Reference

  • The asynchronous handler function that executes the search_flights tool logic. Constructs flight slices depending on trip type (one-way, round-trip, or multi-city) and sends an offer request to the Duffel flight client.
    async (params: FlightSearch) => {
      try {
        const slices = [];
        
        // Build slices based on flight type
        if (params.type === 'one_way') {
          slices.push(flightClient.createSlice(
            params.origin, 
            params.destination, 
            params.departureDate,
            params.departureTime,
            params.arrivalTime
          ));
        } else if (params.type === 'round_trip') {
          if (!params.returnDate) {
            throw new Error('Return date required for round-trip flights');
          }
          
          slices.push(flightClient.createSlice(
            params.origin,
            params.destination,
            params.departureDate,
            params.departureTime,
            params.arrivalTime
          ));
          
          slices.push(flightClient.createSlice(
            params.destination,
            params.origin,
            params.returnDate,
            params.departureTime,
            params.arrivalTime
          ));
        } else if (params.type === 'multi_city') {
          if (!params.additionalStops || params.additionalStops.length === 0) {
            throw new Error('Additional stops required for multi-city flights');
          }
          
          // First leg
          slices.push(flightClient.createSlice(
            params.origin,
            params.destination,
            params.departureDate
          ));
          
          // Additional legs
          for (const stop of params.additionalStops) {
            slices.push(flightClient.createSlice(
              stop.origin,
              stop.destination,
              stop.departureDate
            ));
          }
        }
        
        // Create the offer request
        const response = await flightClient.createOfferRequest({
          slices,
          cabin_class: params.cabinClass,
          adult_count: params.adults,
          max_connections: params.maxConnections,
          return_offers: true,
          supplier_timeout: 15000 // 15 seconds
        });
        
        // Return formatted response
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response, null, 2)
            }
          ]
        };
        
      } catch (error) {
        console.error(`Error searching flights: ${error}`);
        throw error;
      }
    }
  • Zod schema defining the input parameters for the search_flights tool, validated before passing to the handler.
    export const flightSearchSchema = z.object({
      type: z.enum(['one_way', 'round_trip', 'multi_city']).describe('Type of flight'),
      origin: z.string().describe('Origin airport or city IATA code (e.g., SFO, NYC)'),
      destination: z.string().describe('Destination airport or city IATA code (e.g., LAX, LHR)'),
      departureDate: z.string().describe('Departure date in YYYY-MM-DD format'),
      returnDate: z.string().optional().describe('Return date in YYYY-MM-DD format (required for round-trip)'),
      departureTime: timeSpecSchema.optional().describe('Preferred departure time window'),
      arrivalTime: timeSpecSchema.optional().describe('Preferred arrival time window'),
      cabinClass: z.enum(['economy', 'premium_economy', 'business', 'first']).describe('Cabin class'),
      adults: z.number().min(1).default(1).describe('Number of adult passengers'),
      maxConnections: z.number().optional().describe('Maximum number of connections'),
      additionalStops: z.array(flightSegmentSchema).optional().describe('Additional stops for multi-city flights')
    });
  • src/server.ts:30-113 (registration)
    Registers the search_flights tool with the MCP server, associating the tool name, input schema, and handler function.
    server.tool(
      'search_flights',
      flightSearchSchema.shape,
      async (params: FlightSearch) => {
        try {
          const slices = [];
          
          // Build slices based on flight type
          if (params.type === 'one_way') {
            slices.push(flightClient.createSlice(
              params.origin, 
              params.destination, 
              params.departureDate,
              params.departureTime,
              params.arrivalTime
            ));
          } else if (params.type === 'round_trip') {
            if (!params.returnDate) {
              throw new Error('Return date required for round-trip flights');
            }
            
            slices.push(flightClient.createSlice(
              params.origin,
              params.destination,
              params.departureDate,
              params.departureTime,
              params.arrivalTime
            ));
            
            slices.push(flightClient.createSlice(
              params.destination,
              params.origin,
              params.returnDate,
              params.departureTime,
              params.arrivalTime
            ));
          } else if (params.type === 'multi_city') {
            if (!params.additionalStops || params.additionalStops.length === 0) {
              throw new Error('Additional stops required for multi-city flights');
            }
            
            // First leg
            slices.push(flightClient.createSlice(
              params.origin,
              params.destination,
              params.departureDate
            ));
            
            // Additional legs
            for (const stop of params.additionalStops) {
              slices.push(flightClient.createSlice(
                stop.origin,
                stop.destination,
                stop.departureDate
              ));
            }
          }
          
          // Create the offer request
          const response = await flightClient.createOfferRequest({
            slices,
            cabin_class: params.cabinClass,
            adult_count: params.adults,
            max_connections: params.maxConnections,
            return_offers: true,
            supplier_timeout: 15000 // 15 seconds
          });
          
          // Return formatted response
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(response, null, 2)
              }
            ]
          };
          
        } catch (error) {
          console.error(`Error searching flights: ${error}`);
          throw error;
        }
      }
    );
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/AkekaratP/flights-mcp-ts'

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