search_municipality_energy
Find Swiss municipality IDs (BFS numbers) to look up electricity tariffs. Use these IDs with get_electricity_tariff and compare_electricity_tariffs tools.
Instructions
Search for Swiss municipality IDs needed for electricity tariff lookup. Returns BFS municipality numbers for use with get_electricity_tariff and compare_electricity_tariffs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Municipality name to search (e.g. 'Zürich', 'Bern', 'Basel', 'Lausanne', 'Luzern'). |
Implementation Reference
- src/modules/energy.ts:365-405 (handler)The handler implementation for 'search_municipality_energy' which performs a GraphQL query to fetch municipality IDs.
case "search_municipality_energy": { const nameQuery = args.name as string; if (!nameQuery?.trim()) { throw new Error("name is required"); } const query = ` query Municipalities($locale: String!, $query: String) { municipalities: searchMunicipalities(locale: $locale, query: $query) { id name } } `; const data = await gql<{ municipalities: MunicipalityResult[] }>(query, { locale: "de", query: nameQuery, }); const municipalities = data.municipalities ?? []; if (!municipalities.length) { return JSON.stringify({ results: [], message: `No municipalities found matching "${nameQuery}". Try a shorter or alternate spelling.`, }, null, 2); } return JSON.stringify({ results: municipalities.map((m) => ({ id: m.id, name: m.name, usage: `Use id "${m.id}" with get_electricity_tariff or compare_electricity_tariffs`, })), count: municipalities.length, note: "Use the 'id' field as the 'municipality' parameter in tariff queries.", source: "https://www.strompreis.elcom.admin.ch", }, null, 2); } - src/modules/energy.ts:140-154 (schema)The registration and input schema definition for 'search_municipality_energy'.
{ name: "search_municipality_energy", description: "Search for Swiss municipality IDs needed for electricity tariff lookup. Returns BFS municipality numbers for use with get_electricity_tariff and compare_electricity_tariffs.", inputSchema: { type: "object", required: ["name"], properties: { name: { type: "string", description: "Municipality name to search (e.g. 'Zürich', 'Bern', 'Basel', 'Lausanne', 'Luzern').", }, }, }, },