flightHappinessIndex
Analyze flight comfort and amenities by comparing punctuality, seat dimensions, baggage allowances, and health protocols for informed travel planning.
Instructions
using this tool when you need information related to following topics: Detailed flight comparisons (punctuality, amenities, cabin specs),Health safety protocols for air travel,Baggage allowance verification,Environmental impact assessments,Aircraft configuration visualization,Comfort-focused trip planning (seat dimensions, entertainment, food). etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fnum | Yes | Flight number including airline code (e.g. MU2157, CZ3969) | |
| date | Yes | 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 | No | Departure airport IATA 3-letter code (e.g. HFE for Hefei) | |
| arr | No | Arrival airport IATA 3-letter code (e.g. CAN for Guangzhou) |
Implementation Reference
- dist/index.js:145-164 (handler)The MCP tool handler function for 'flightHappinessIndex'. It receives input parameters, calls the flightService.getFlightHappinessIndex method, formats the response as JSON text content, and handles errors.}, async ({ fnum, date, dep, arr }) => { try { const flights = await flightService.getFlightHappinessIndex(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 }; } });
- dist/index.js:129-144 (schema)Zod-based input schema defining parameters fnum (flight number), date (YYYY-MM-DD), optional dep and arr (IATA codes) with validation rules and descriptions.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(),
- dist/index.js:128-164 (registration)Registration of the 'flightHappinessIndex' MCP tool, including name, description, input schema, and handler function.server.tool("flightHappinessIndex", "using this tool when you need information related to following topics: Detailed flight comparisons (punctuality, amenities, cabin specs),Health safety protocols for air travel,Baggage allowance verification,Environmental impact assessments,Aircraft configuration visualization,Comfort-focused trip planning (seat dimensions, entertainment, food). etc.", { 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 }) => { try { const flights = await flightService.getFlightHappinessIndex(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 }; } });
- dist/services/openalService.js:62-72 (helper)Helper method in OpenAlService class that constructs API parameters and calls the 'happiness' endpoint via makeRequest to retrieve the flight happiness index data.async getFlightHappinessIndex(fnum, date, dep, arr) { const params = { fnum, date, }; if (dep) params.dep = dep; if (arr) params.arr = arr; return this.makeRequest('happiness', params); }