Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

searchFlightsByNumber

Find flight details using flight number and date. Enter airline code with flight number (like MU2157) and departure date to get departure/arrival airports, times, and status.

Instructions

Search flights by flight number and date. Flight number should include airline code (e.g. MU2157, CZ3969). dep and arr are optional, keep empty if you don't know them. Date format: YYYY-MM-DD. IMPORTANT: For today's date, you MUST use getTodayDate tool instead of hardcoding any date. Airport codes (optional) should be IATA 3-letter codes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fnumYesFlight number including airline code (e.g. MU2157, CZ3969)
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. HFE for Hefei)
arrNoArrival airport IATA 3-letter code (e.g. CAN for Guangzhou)

Implementation Reference

  • Tool handler function that calls the OpenAlService to search flights by number and formats the response.
    }, async ({ fnum, date, dep, arr }) => { try { const flights = await flightService.getFlightByNumber(fnum, date, dep, arr); return { content: [ { type: "text", text: JSON.stringify(flights, null, 2) } ] }; } catch (error) { console.error('Error searching flights by number:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } });
  • Zod input schema defining parameters fnum (required), date (required), dep and arr (optional).
    fnum: z.string() .regex(/^[A-Z0-9]{2,3}[0-9]{1,4}$/) .describe("Flight number including airline code (e.g. MU2157, CZ3969)"), 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"), dep: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Departure airport IATA 3-letter code (e.g. HFE for Hefei)") .optional(), arr: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Arrival airport IATA 3-letter code (e.g. CAN for Guangzhou)") .optional(), }, async ({ fnum, date, dep, arr }) => {
  • dist/index.js:58-58 (registration)
    Registration of the searchFlightsByNumber tool using server.tool, including description and linking to schema and handler.
    server.tool("searchFlightsByNumber", "Search flights by flight number and date. Flight number should include airline code (e.g. MU2157, CZ3969). dep and arr are optional, keep empty if you don't know them. Date format: YYYY-MM-DD. IMPORTANT: For today's date, you MUST use getTodayDate tool instead of hardcoding any date. Airport codes (optional) should be IATA 3-letter codes. ", {
  • Helper method in OpenAlService that constructs parameters conditionally and calls makeRequest to the 'flight' API endpoint.
    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); }
  • Core helper method that makes POST request to the configured API baseUrl with endpoint and params, using API key from config.
    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