Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

searchFlightsByDepArr

Search for flights between airports or cities using IATA codes. Specify departure and arrival locations along with the date in YYYY-MM-DD format to retrieve flight 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
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
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)

Implementation Reference

  • dist/index.js:13-56 (registration)
    Registration of the 'searchFlightsByDepArr' tool, including description, input schema using Zod, and inline handler function that delegates to flightService.getFlightsByDepArr.
    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).", { 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") }, 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 }; } });
  • The core handler logic in OpenAlService.getFlightsByDepArr that makes the API request to the 'flights' endpoint.
    async getFlightsByDepArr(dep, depcity, arr, arrcity, date) { return this.makeRequest('flights', { dep, depcity, arr, arrcity, date, }); } async getFlightByNumber(fnum, date, dep, arr) { const params = { fnum, date, }; if (dep) params.dep = dep; if (arr) params.arr = arr; return this.makeRequest('flight', params); } // 获取航班中转信息 async getTransferInfo(depcity, arrcity, depdate) { return this.makeRequest('transfer', { depcity, arrcity, depdate, "fromMCP": 1 }); } async getRealtimeLocationByAnum(anum) { return this.makeRequest('realtimeLocation', { anum }); }
  • Method in OpenAlService that implements the flight search by dep/arr by calling makeRequest with endpoint 'flights'.
    async getFlightsByDepArr(dep, depcity, arr, arrcity, date) { return this.makeRequest('flights', { dep, depcity, arr, arrcity, date, }); }
  • Generic helper method used to make POST requests to the Variflight API.
    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(); }
  • Input schema validation using Zod for the tool parameters.
    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")

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