get_current_weather
Retrieve current weather conditions including temperature, humidity, wind, precipitation, and conditions using latitude/longitude coordinates or US ZIP codes from NOAA and GFS data sources.
Instructions
Get current weather conditions for a location. Provide latitude/longitude or a US ZIP code. Returns temperature, humidity, wind, precipitation, and conditions from the nearest weather station and latest model run. Source: NOAA ISD + GFS. Note: This dataset is coming soon.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | No | Latitude (-90 to 90). Required if ZIP is not provided. | |
| lon | No | Longitude (-180 to 180). Required if ZIP is not provided. | |
| zip | No | US 5-digit ZIP code. Alternative to lat/lon. Maps to nearest station. |
Implementation Reference
- src/tools/weather.ts:62-108 (handler)The handler function that executes the logic for the "get_current_weather" tool by calling the weather API.
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/current", { 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) }, ], }; }, - src/tools/weather.ts:41-60 (schema)Input schema definition for the "get_current_weather" tool using Zod.
inputSchema: { lat: z .number() .min(-90) .max(90) .optional() .describe("Latitude (-90 to 90). Required if ZIP is not provided."), lon: z .number() .min(-180) .max(180) .optional() .describe("Longitude (-180 to 180). Required if ZIP is not provided."), zip: z .string() .optional() .describe( "US 5-digit ZIP code. Alternative to lat/lon. Maps to nearest station.", ), }, - src/tools/weather.ts:32-33 (registration)Registration of the "get_current_weather" tool within the MCP server.
server.registerTool( "get_current_weather",