flightHappinessIndex
Compare flights for punctuality, amenities, and cabin specs, verify baggage allowances, assess environmental impacts, and plan comfortable trips with seat dimensions, entertainment, and food options.
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
| Name | Required | Description | Default |
|---|---|---|---|
| arr | No | Arrival airport IATA 3-letter code (e.g. CAN for Guangzhou) | |
| 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) | |
| fnum | Yes | Flight number including airline code (e.g. MU2157, CZ3969) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"arr": {
"description": "Arrival airport IATA 3-letter code (e.g. CAN for Guangzhou)",
"maxLength": 3,
"minLength": 3,
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"date": {
"description": "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",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
"type": "string"
},
"dep": {
"description": "Departure airport IATA 3-letter code (e.g. HFE for Hefei)",
"maxLength": 3,
"minLength": 3,
"pattern": "^[A-Z]{3}$",
"type": "string"
},
"fnum": {
"description": "Flight number including airline code (e.g. MU2157, CZ3969)",
"pattern": "^[A-Z0-9]{2,3}[0-9]{1,4}$",
"type": "string"
}
},
"required": [
"fnum",
"date"
],
"type": "object"
}
Implementation Reference
- dist/index.js:129-165 (registration)Registers the 'flightHappinessIndex' tool with the MCP server, including description, Zod input schema, and inline handler that calls the service.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/index.js:130-145 (schema)Zod schema defining input parameters: required flight number (fnum) and date, optional departure (dep) and arrival (arr) IATA codes.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:146-165 (handler)The MCP tool handler function: calls flightService.getFlightHappinessIndex, returns result as JSON-formatted text content or error.}, 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:61-71 (helper)Service method that constructs parameters and invokes makeRequest with 'happiness' endpoint to retrieve 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); }
- dist/services/openalService.d.ts:8-8 (schema)TypeScript interface definition for the getFlightHappinessIndex service method.getFlightHappinessIndex(fnum: string, date: string, dep?: string, arr?: string): Promise<any>;