get_weather_history
Retrieve historical weather data for analysis by accessing hourly temperature, humidity, wind, precipitation, and pressure records from NOAA ISD for specific locations and date ranges.
Instructions
Get historical weather data for a location and date range. Returns hourly observations including temperature, humidity, wind, precipitation, and pressure. Source: NOAA ISD. Note: This dataset is coming soon.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| zip | No | US 5-digit ZIP code | |
| lat | No | Latitude | |
| lon | No | Longitude | |
| date_from | Yes | Start date (YYYY-MM-DD). Required. | |
| date_to | Yes | End date (YYYY-MM-DD). Required. |
Implementation Reference
- src/tools/weather.ts:133-189 (handler)The asynchronous handler function for get_weather_history, which validates input and calls the /api/v1/weather/history endpoint.
async ({ zip, lat, lon, date_from, date_to }) => { 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/history", { zip, lat, lon, date_from, date_to, }); 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, }; } const data = res.data; const count = Array.isArray(data.data) ? data.data.length : 1; const summary = `Retrieved ${count} weather observation(s).`; return { content: [ { type: "text" as const, text: `${summary}\n\n${JSON.stringify(data, null, 2)}`, }, ], }; }, ); - src/tools/weather.ts:113-132 (registration)The registration block for get_weather_history, including the input schema definitions.
server.registerTool( "get_weather_history", { title: "Get Weather History", description: "Get historical weather data for a location and date range. Returns hourly " + "observations including temperature, humidity, wind, precipitation, and " + "pressure. Source: NOAA ISD. Note: This dataset is coming soon.", inputSchema: { zip: z.string().optional().describe("US 5-digit ZIP code"), lat: z.number().min(-90).max(90).optional().describe("Latitude"), lon: z.number().min(-180).max(180).optional().describe("Longitude"), date_from: z .string() .describe("Start date (YYYY-MM-DD). Required."), date_to: z .string() .describe("End date (YYYY-MM-DD). Required."), }, },