is_holiday_today
Check if today is a Swiss public holiday, optionally by canton, and get the holiday name if applicable.
Instructions
Check whether today is a Swiss public holiday, optionally for a specific canton. Returns the holiday name if it is one.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| canton | No | Two-letter canton code (e.g. ZH, BE, GE). If omitted, checks nationwide holidays only. |
Implementation Reference
- src/modules/holidays.ts:175-211 (handler)The handler implementation for the `is_holiday_today` tool. It queries the OpenHolidays API for the current date, optionally filtering by canton, and returns whether it's a holiday.
case "is_holiday_today": { const canton = args.canton as string | undefined; const today = new Date().toISOString().slice(0, 10); // YYYY-MM-DD const params: Record<string, string> = { countryIsoCode: "CH", languageIsoCode: "EN", validFrom: today, validTo: today, }; if (canton) { params.subdivisionCode = toSubdivisionCode(canton); } const url = buildUrl(`${BASE}/PublicHolidays`, params); const data = await fetchJSON<Holiday[]>(url); if (data.length === 0) { return JSON.stringify({ date: today, is_holiday: false, canton: canton ?? "all", }); } // Return the first (or nationwide) match const nationwide = data.find((h) => h.nationwide); const match = nationwide ?? data[0]; return JSON.stringify({ date: today, is_holiday: true, holiday: extractName(match.name), type: match.type, nationwide: match.nationwide, canton: canton ?? "all", }); } - src/modules/holidays.ts:67-80 (schema)The tool registration and schema definition for `is_holiday_today`.
name: "is_holiday_today", description: "Check whether today is a Swiss public holiday, optionally for a specific canton. Returns the holiday name if it is one.", inputSchema: { type: "object", properties: { canton: { type: "string", description: "Two-letter canton code (e.g. ZH, BE, GE). If omitted, checks nationwide holidays only.", }, }, }, },