Get Current Weather
get_current_weatherRetrieve current weather conditions for any US location. Provide latitude/longitude or ZIP code to get temperature, humidity, wind, and precipitation from the nearest station.
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
| 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 async handler function for 'get_current_weather'. Validates that lat+lon or zip is provided, calls the API at /api/v1/weather/current, and returns formatted text content or an error.
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 for 'get_current_weather' using Zod. Defines optional lat (number -90 to 90), lon (number -180 to 180), and zip (string) parameters.
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-109 (registration)Registration of 'get_current_weather' tool via server.registerTool() with its schema and handler.
server.registerTool( "get_current_weather", { title: "Get Current Weather", description: "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.", 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.", ), }, }, 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/index.ts:42-42 (registration)Registration of the weather module by calling registerWeatherTools(server) in the main server setup.
registerWeatherTools(server); - src/client.ts:44-76 (helper)The apiGet helper function used by the handler to make HTTP GET requests to the Verilex API.
export async function apiGet<T = unknown>( path: string, params?: Record<string, string | number | undefined>, ): Promise<ApiResponse<T>> { const url = buildUrl(path, params); const headers: Record<string, string> = { Accept: "application/json", "User-Agent": "verilex-mcp-server/0.1.0", }; // Forward x402 payment token if present in env (for paid endpoints) const paymentToken = process.env.VERILEX_PAYMENT_TOKEN; if (paymentToken) { headers["X-Payment-Token"] = paymentToken; } const res = await fetch(url, { headers }); const data = (await res.json()) as T; const stale = res.headers.get("X-Data-Stale"); const lastUpdated = res.headers.get("X-Data-Last-Updated"); const ageSeconds = res.headers.get("X-Data-Age-Seconds"); return { ok: res.ok, status: res.status, data, stale: stale === "true", lastUpdated: lastUpdated ?? undefined, ageSeconds: ageSeconds ? Number(ageSeconds) : undefined, }; }