search_cantonal_affairs
Search political affairs across all 26 Swiss cantonal parliaments using OpenParlData. Find parliamentary discussions by canton and topic.
Instructions
Search political affairs across Swiss cantonal parliaments (Kantonsräte). Covers all 26 cantons via OpenParlData.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| canton | Yes | Canton abbreviation: ZH, BE, LU, UR, SZ, OW, NW, GL, ZG, FR, SO, BS, BL, SH, AR, AI, SG, GR, AG, TG, TI, VD, VS, NE, GE, JU | |
| query | No | Search term (optional, e.g. 'Bildung', 'Verkehr') | |
| limit | No | Max results (default: 5, max: 20) |
Implementation Reference
- src/modules/parliament.ts:543-584 (handler)The searchCantonalAffairs function handles the logic for searching cantonal parliamentary affairs using the OpenParlData API.
async function searchCantonalAffairs(args: { canton: string; query?: string; limit?: number; }): Promise<string> { const limit = Math.min(args.limit ?? 5, 20); const params: Record<string, string | number | boolean | undefined> = { body_key: args.canton.toUpperCase(), lang: "de", lang_format: "flat", sort_by: "-begin_date", limit, }; if (args.query) { params.search = args.query; } const url = buildUrl("/affairs/", params); const resp = await apiFetch<AffairRecord>(url); const affairs = resp.data.map((a) => ({ id: a.id, number: a.number, title: a.title_de, type: a.type_name_de, typeCategory: a.type_harmonized_de, status: a.state_name_de, date: a.begin_date ? a.begin_date.split("T")[0] : null, canton: a.body_key, url: a.url_external_de, })); return truncate( JSON.stringify({ count: affairs.length, total: resp.meta.total_records, canton: args.canton.toUpperCase(), query: args.query || null, affairs, }) ); } - src/modules/parliament.ts:169-192 (schema)The input schema definition for the search_cantonal_affairs tool.
{ name: "search_cantonal_affairs", description: "Search political affairs across Swiss cantonal parliaments (Kantonsräte). Covers all 26 cantons via OpenParlData.", inputSchema: { type: "object" as const, required: ["canton"], properties: { canton: { type: "string", description: "Canton abbreviation: ZH, BE, LU, UR, SZ, OW, NW, GL, ZG, FR, SO, BS, BL, SH, AR, AI, SG, GR, AG, TG, TI, VD, VS, NE, GE, JU", }, query: { type: "string", description: "Search term (optional, e.g. 'Bildung', 'Verkehr')", }, limit: { type: "number", description: "Max results (default: 5, max: 20)", }, }, }, }, - src/modules/parliament.ts:694-697 (registration)The tool registration and invocation dispatcher in handleParliament.
case "search_cantonal_affairs": return searchCantonalAffairs( args as { canton: string; query?: string; limit?: number } );