Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

searchFlightsByDepArr

Search for flights between airports or cities using IATA codes and specific dates to find available travel options.

Instructions

Search for flights between airports or cities by date. For cities with multiple airports, use depcity and arrcity parameters; otherwise use dep and arr parameters. Date must be in YYYY-MM-DD format. For today's date, use the getTodayDate tool. All airport/city codes must be valid IATA 3-letter codes (e.g.BJS for city of Beijing, PEK for Beijing Capital Airport).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
depNoDeparture airport IATA 3-letter code (e.g. PEK for Beijing, CAN for Guangzhou)
depcityNoDeparture city IATA 3-letter code (e.g. BJS for Beijing, CAN for Guangzhou)
arrNoArrival airport IATA 3-letter code (e.g. SHA for Shanghai, HFE for Hefei)
arrcityNoArrival city IATA 3-letter code (e.g. SHA for Shanghai, BJS for Beijing)
dateYesFlight date in YYYY-MM-DD format. IMPORTANT: If user input only cotains month and date, you should use getTodayDate tool to get the year. For today's date, use getTodayDate tool instead of hardcoding

Implementation Reference

  • The MCP tool handler function that invokes the flight service's getFlightsByDepArr method, handles errors, and returns the flight data as formatted text content.
    }, async ({ dep, depcity, arr, arrcity, date }) => { try { const flights = await flightService.getFlightsByDepArr(dep, depcity, arr, arrcity, date); return { content: [ { type: "text", text: JSON.stringify(flights, null, 2) } ] }; } catch (error) { console.error('Error searching flights by dep/arr:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } });
  • Zod schema defining the input parameters for the tool: dep, depcity, arr, arrcity, date with validation rules.
    dep: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Departure airport IATA 3-letter code (e.g. PEK for Beijing, CAN for Guangzhou)") .optional(), depcity: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Departure city IATA 3-letter code (e.g. BJS for Beijing, CAN for Guangzhou)") .optional(), arr: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Arrival airport IATA 3-letter code (e.g. SHA for Shanghai, HFE for Hefei)") .optional(), arrcity: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Arrival city IATA 3-letter code (e.g. SHA for Shanghai, BJS for Beijing)") .optional(), date: z.string() .regex(/^\d{4}-\d{2}-\d{2}$/) .describe("Flight date in YYYY-MM-DD format. IMPORTANT: If user input only cotains month and date, you should use getTodayDate tool to get the year. For today's date, use getTodayDate tool instead of hardcoding")
  • dist/index.js:13-13 (registration)
    Registration of the 'searchFlightsByDepArr' tool with name, description, schema, and handler on the MCP server.
    server.tool("searchFlightsByDepArr", "Search for flights between airports or cities by date. For cities with multiple airports, use depcity and arrcity parameters; otherwise use dep and arr parameters. Date must be in YYYY-MM-DD format. For today's date, use the getTodayDate tool. All airport/city codes must be valid IATA 3-letter codes (e.g.BJS for city of Beijing, PEK for Beijing Capital Airport).", {
  • Helper method in OpenAlService that performs the API request to fetch flights by departure and arrival details.
    async getFlightsByDepArr(dep, depcity, arr, arrcity, date) { return this.makeRequest('flights', { dep, depcity, arr, arrcity, date, }); }
  • Core helper method for making HTTP POST requests to the external flight API, used by getFlightsByDepArr.
    async makeRequest(endpoint, params) { const url = new URL(config.api.baseUrl); const request_body = { endpoint: endpoint, params: params }; const response = await fetch(url.toString(), { method: 'post', headers: { 'X-VARIFLIGHT-KEY': config.api.apiKey || '', 'Content-Type': 'application/json', }, body: JSON.stringify(request_body), }); if (!response.ok) { throw new Error(`API request failed: ${response.status} ${response.statusText}`); } return response.json(); }

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/variflight/tripmatch-mcp'

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