getFutureWeatherByAirport
Retrieve 3-day weather forecasts for airports using IATA codes to plan travel and anticipate conditions at destinations.
Instructions
Get airport future weather for 3days (today、tomorrow、the day after tomorrow) by airport IATA 3-letter code. Airport codes should be IATA 3-letter codes (e.g. PEK for Beijing, SHA for Shanghai, CAN for Guangzhou, HFE for Hefei).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| airport | Yes | Airport IATA 3-letter code (e.g. PEK for Beijing, SHA for Shanghai, CAN for Guangzhou, HFE for Hefei) |
Implementation Reference
- dist/index.js:186-209 (registration)Registration of the 'getFutureWeatherByAirport' MCP tool, including description, Zod input schema, and inline handler function that delegates to flightService.getAirportWeather.server.tool('getFutureWeatherByAirport', 'Get airport future weather for 3days (today、tomorrow、the day after tomorrow) by airport IATA 3-letter code. Airport codes should be IATA 3-letter codes (e.g. PEK for Beijing, SHA for Shanghai, CAN for Guangzhou, HFE for Hefei).', { airport: z.string() .regex(/^[A-Z]{3}$/) .describe("Airport IATA 3-letter code (e.g. PEK for Beijing, SHA for Shanghai, CAN for Guangzhou, HFE for Hefei)") }, async ({ airport }) => { try { const weather = await flightService.getAirportWeather(airport); return { content: [ { type: "text", text: JSON.stringify(weather, null, 2) } ] }; } catch (error) { console.error('Error getting airport weather:', error); return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; } });
- dist/services/openalService.js:56-61 (helper)Helper method in OpenAlService that calls the 'futureAirportWeather' API endpoint with the airport code and type=1.async getAirportWeather(airport) { return this.makeRequest('futureAirportWeather', { "code": airport, "type": "1" }); }
- dist/services/openalService.js:3-21 (helper)Core helper method in OpenAlService that performs POST requests to the configured API base URL with endpoint and params.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(); }
- dist/index.js:187-189 (schema)Zod schema definition for the 'airport' input parameter validating IATA 3-letter code.airport: z.string() .regex(/^[A-Z]{3}$/) .describe("Airport IATA 3-letter code (e.g. PEK for Beijing, SHA for Shanghai, CAN for Guangzhou, HFE for Hefei)")