Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameYesMunicipality name to search (e.g. 'Zürich', 'Bern', 'Basel', 'Lausanne', 'Luzern').

Implementation Reference

  • 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);
    }
  • 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').",
          },
        },
      },
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vikramgorla/mcp-swiss'

If you have feedback or need assistance with the MCP directory API, please join our Discord server