get_weather_forecast
Retrieve weather forecasts for any location with hourly or daily data including temperature, humidity, wind, and precipitation probability up to 16 days ahead.
Instructions
Get weather forecast for a location, up to 16 days ahead. Returns hourly or daily forecast data including temperature, humidity, wind, and precipitation probability. Source: NOAA GFS model. Note: This dataset is coming soon.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | No | Latitude | |
| lon | No | Longitude | |
| zip | No | US 5-digit ZIP code |
Implementation Reference
- src/tools/weather.ts:193-254 (handler)The tool "get_weather_forecast" is registered and handled directly in this block within `src/tools/weather.ts`. It takes lat/lon or zip as input, calls an API endpoint, and returns the weather forecast data.
server.registerTool( "get_weather_forecast", { title: "Get Weather Forecast", description: "Get weather forecast for a location, up to 16 days ahead. Returns hourly " + "or daily forecast data including temperature, humidity, wind, and precipitation " + "probability. Source: NOAA GFS model. Note: This dataset is coming soon.", inputSchema: { lat: z.number().min(-90).max(90).optional().describe("Latitude"), lon: z.number().min(-180).max(180).optional().describe("Longitude"), zip: z.string().optional().describe("US 5-digit ZIP code"), }, }, async ({ lat, lon, zip }) => { if (!zip && (lat === undefined || lon === undefined)) { return { content: [ { type: "text" as const, text: "Please provide either lat+lon or a ZIP code.", }, ], isError: true, }; } const res = await apiGet<WeatherResponse>("/api/v1/weather/forecast", { lat, lon, zip, }); if (!res.ok) { if (res.status === 404) { return { content: [ { type: "text" as const, text: "Weather dataset is not yet available. This data source is coming soon.", }, ], }; } return { content: [ { type: "text" as const, text: `API error (${res.status}): ${JSON.stringify(res.data)}`, }, ], isError: true, }; } return { content: [ { type: "text" as const, text: JSON.stringify(res.data, null, 2) }, ], }; }, );