get_snow_conditions
Retrieve current snow depth and 24-hour snowfall data for Swiss mountain stations to assess skiing, hiking, or avalanche conditions. Filter by canton or altitude for targeted information.
Instructions
Get current snow conditions across Switzerland from SLF (WSL Institute for Snow and Avalanche Research). Returns snow depth and new snow (24h) for IMIS stations, sorted by snow depth. Filter by canton or minimum altitude. Data updated daily.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| canton | No | Filter by canton abbreviation (e.g. GR, VS, BE, UR, TI). Optional. | |
| min_altitude | No | Minimum station altitude in metres (e.g. 2000). Optional. | |
| limit | No | Maximum number of stations to return (default: 20, max: 100). |
Implementation Reference
- src/modules/snow.ts:157-209 (handler)The logic that fetches, filters, and processes snow condition data.
async function handleGetSnowConditions( args: Record<string, unknown> ): Promise<string> { const canton = typeof args.canton === "string" ? args.canton.trim().toUpperCase() : undefined; const minAlt = typeof args.min_altitude === "number" ? args.min_altitude : undefined; const limit = Math.min(Math.max(Number(args.limit) || 20, 1), 100); // Fetch snow data and station metadata in parallel const [dailySnow, stations] = await Promise.all([ fetchJSON<DailySnow[]>(`${BASE}/imis/daily-snow`), fetchJSON<ImisStation[]>(`${BASE}/imis/stations`), ]); // Build station lookup const stationMap = new Map<string, ImisStation>(); for (const s of stations) { stationMap.set(s.code, s); } // Join, filter, sort const joined = dailySnow .map((d) => { const s = stationMap.get(d.station_code); if (!s) return null; return { station: s.label, code: s.code, altitude_m: s.elevation, canton: s.canton_code, snow_depth_cm: d.HS, new_snow_24h_cm: d.HN_1D, date: d.measure_date?.slice(0, 10) ?? null, }; }) .filter((r): r is NonNullable<typeof r> => { if (!r) return false; if (canton && r.canton !== canton) return false; if (minAlt !== undefined && r.altitude_m < minAlt) return false; return true; }) .sort((a, b) => (b.snow_depth_cm ?? 0) - (a.snow_depth_cm ?? 0)) .slice(0, limit); return JSON.stringify({ count: joined.length, filters: { ...(canton ? { canton } : {}), ...(minAlt !== undefined ? { min_altitude_m: minAlt } : {}), }, stations: joined, source: "WSL Institute for Snow and Avalanche Research SLF (CC BY 4.0)", }); } - src/modules/snow.ts:75-96 (registration)The registration of the 'get_snow_conditions' tool within the 'snowTools' array.
export const snowTools = [ { name: "get_snow_conditions", description: "Get current snow conditions across Switzerland from SLF (WSL Institute for Snow and Avalanche Research). " + "Returns snow depth and new snow (24h) for IMIS stations, sorted by snow depth. " + "Filter by canton or minimum altitude. Data updated daily.", inputSchema: { type: "object", properties: { canton: { type: "string", description: "Filter by canton abbreviation (e.g. GR, VS, BE, UR, TI). Optional.", }, min_altitude: { type: "number", description: "Minimum station altitude in metres (e.g. 2000). Optional.", }, limit: { type: "number", - src/modules/snow.ts:82-96 (schema)The JSON schema definition for the 'get_snow_conditions' input parameters.
inputSchema: { type: "object", properties: { canton: { type: "string", description: "Filter by canton abbreviation (e.g. GR, VS, BE, UR, TI). Optional.", }, min_altitude: { type: "number", description: "Minimum station altitude in metres (e.g. 2000). Optional.", }, limit: { type: "number",