Skip to main content
Glama
variflight

Variflight Tripmatch MCP Server

Official
by variflight

getFutureWeatherByAirport

Retrieve 3-day weather forecasts for airports using IATA 3-letter codes (e.g., PEK, SHA) to plan travel or operations efficiently.

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

NameRequiredDescriptionDefault
airportYesAirport IATA 3-letter code (e.g. PEK for Beijing, SHA for Shanghai, CAN for Guangzhou, HFE for Hefei)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "airport": { "description": "Airport IATA 3-letter code (e.g. PEK for Beijing, SHA for Shanghai, CAN for Guangzhou, HFE for Hefei)", "pattern": "^[A-Z]{3}$", "type": "string" } }, "required": [ "airport" ], "type": "object" }

Implementation Reference

  • dist/index.js:186-209 (registration)
    Registration of the 'getFutureWeatherByAirport' tool, including description, input schema using Zod, and the 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 }; } });
  • Input schema validating the 'airport' parameter as a 3-letter IATA code using Zod
    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)")
  • MCP tool handler function that invokes the service method and formats the response
    }, 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 }; } });
  • Core implementation of the weather retrieval: calls the 'futureAirportWeather' API endpoint with airport code
    async getAirportWeather(airport) { return this.makeRequest('futureAirportWeather', { "code": airport, "type": "1" }); }
  • Generic helper method for making POST requests to the backend API 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(); }

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