Weather Dataset Statistics
weather_statsRetrieve statistics about the Weather dataset: stations covered, date range, data sources, and last update timestamp.
Instructions
Get statistics about the Weather dataset: stations covered, date range, data sources, and last updated timestamp. Free endpoint.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/weather.ts:258-298 (handler)The weather_stats tool handler - calls /api/v1/weather/stats, returns JSON-formatted dataset statistics including stations covered, date range, data sources, and last updated timestamp. Free endpoint with no input parameters.
server.registerTool( "weather_stats", { title: "Weather Dataset Statistics", description: "Get statistics about the Weather dataset: stations covered, date range, " + "data sources, and last updated timestamp. Free endpoint.", inputSchema: {}, }, async () => { const res = await apiGet<WeatherStatsResponse>("/api/v1/weather/stats"); 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 weather tools (including weather_stats) via registerWeatherTools(server) call in the main MCP server setup.
registerWeatherTools(server); - src/tools/weather.ts:22-27 (schema)WeatherStatsResponse interface defining the response type: dataset, source, update_frequency, and stats fields.
interface WeatherStatsResponse { dataset: string; source: string; update_frequency: string; stats: Record<string, unknown>; } - src/tools/weather.ts:258-299 (registration)Tool registration with empty inputSchema (no parameters required), title 'Weather Dataset Statistics', and handler that fetches stats from the API.
server.registerTool( "weather_stats", { title: "Weather Dataset Statistics", description: "Get statistics about the Weather dataset: stations covered, date range, " + "data sources, and last updated timestamp. Free endpoint.", inputSchema: {}, }, async () => { const res = await apiGet<WeatherStatsResponse>("/api/v1/weather/stats"); 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/client.ts:44-76 (helper)apiGet helper used by the handler to make the HTTP GET request to /api/v1/weather/stats.
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, }; }