Get Weather Forecast
get_weather_forecastRetrieve weather forecasts up to 16 days ahead using latitude/longitude or US ZIP code. Get hourly or daily data including temperature, humidity, wind, and precipitation probability from the NOAA GFS model.
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
| Name | Required | Description | Default |
|---|---|---|---|
| lat | No | Latitude | |
| lon | No | Longitude | |
| zip | No | US 5-digit ZIP code |
Implementation Reference
- src/tools/weather.ts:207-253 (handler)The async handler function for the get_weather_forecast tool. Validates input (requires lat+lon or zip), calls the Verilex API at /api/v1/weather/forecast via apiGet, handles 404/error responses, and returns the forecast data as JSON.
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) }, ], }; }, - src/tools/weather.ts:195-206 (schema)Input schema for get_weather_forecast: lat (optional number -90 to 90), lon (optional number -180 to 180), zip (optional string). Title and description metadata for the tool.
{ 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"), }, }, - src/tools/weather.ts:193-254 (registration)Registration of get_weather_forecast via server.registerTool() within the registerWeatherTools function (called from src/index.ts line 42).
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) }, ], }; }, ); - src/index.ts:33-61 (registration)The createMcpServer function that instantiates McpServer and calls registerWeatherTools(server) on line 42, which registers the get_weather_forecast tool.
function createMcpServer() { const server = new McpServer({ name: "verilex-data", version: "0.3.3", }); registerNpiTools(server); registerSecTools(server); registerPacerTools(server); registerWeatherTools(server); registerOtcTools(server); registerTrademarkTools(server); registerPatentTools(server); registerCompanyTools(server); registerCryptoTools(server); registerSanctionsTools(server); registerWhaleTools(server); registerLabelTools(server); registerHolderTools(server); registerDexTools(server); registerContractTools(server); registerPmTools(server); registerPmArbTools(server); registerPmResolutionTools(server); registerEconTools(server); registerPmMicroTools(server); return server; } - src/client.ts:44-76 (helper)The apiGet helper function used by the handler to make the HTTP GET request 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, }; }