Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

getFlightPriceByCities

Retrieve flight prices between cities using IATA codes and departure date to compare travel costs and plan trips.

Instructions

Get flight price information by departure city, arrival city, and departure date. All city codes must be valid IATA 3-letter codes (e.g. HFE for Hefei, CAN for Guangzhou). Date must be in YYYY-MM-DD format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dep_cityYesDeparture city IATA 3-letter code (e.g. HFE for Hefei)
arr_cityYesArrival city IATA 3-letter code (e.g. CAN for Guangzhou)
dep_dateYesDeparture 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 handler function that executes the core logic of the 'getFlightPriceByCities' tool. It invokes the flight service method, formats the response as MCP content (JSON stringified), and handles errors by returning an error message.
    }, async ({ dep_city, arr_city, dep_date }) => { try { const flightPrices = await flightService.getFlightPriceByCities(dep_city, arr_city, dep_date); return { content: [ { type: "text", text: JSON.stringify(flightPrices, null, 2) } ] }; } catch (error) { console.error('Error getting flight prices by cities:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; }
  • Zod schema for validating the tool's input parameters: departure city code, arrival city code (both IATA 3-letter uppercase), and departure date in YYYY-MM-DD format.
    dep_city: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Departure city IATA 3-letter code (e.g. HFE for Hefei)"), arr_city: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Arrival city IATA 3-letter code (e.g. CAN for Guangzhou)"), dep_date: z.string() .regex(/^\d{4}-\d{2}-\d{2}$/) .describe("Departure 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:238-269 (registration)
    The server.tool registration for 'getFlightPriceByCities', including the tool name, description, input schema, and handler function.
    server.tool("getFlightPriceByCities", "Get flight price information by departure city, arrival city, and departure date. All city codes must be valid IATA 3-letter codes (e.g. HFE for Hefei, CAN for Guangzhou). Date must be in YYYY-MM-DD format.", { dep_city: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Departure city IATA 3-letter code (e.g. HFE for Hefei)"), arr_city: z.string() .length(3) .regex(/^[A-Z]{3}$/) .describe("Arrival city IATA 3-letter code (e.g. CAN for Guangzhou)"), dep_date: z.string() .regex(/^\d{4}-\d{2}-\d{2}$/) .describe("Departure 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_city, arr_city, dep_date }) => { try { const flightPrices = await flightService.getFlightPriceByCities(dep_city, arr_city, dep_date); return { content: [ { type: "text", text: JSON.stringify(flightPrices, null, 2) } ] }; } catch (error) { console.error('Error getting flight prices by cities:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } });
  • Helper method in OpenAlService class that performs the actual API request to the backend endpoint 'getFlightPriceByCities' by calling makeRequest with the parameters.
    async getFlightPriceByCities(dep_city, arr_city, dep_date) { return this.makeRequest('getFlightPriceByCities', { dep_city, arr_city, dep_date }); }

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