Skip to main content
Glama

get_electricity_tariff

Retrieve Swiss electricity tariffs by municipality with price breakdowns for energy, grid, and taxes from 2011 to 2026.

Instructions

Get Swiss electricity tariff (price in Rappen/kWh) for a municipality from ElCom (Swiss Federal Electricity Commission). Returns total price and price breakdown by component (energy, grid, taxes). Valid years: 2011–2026.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
municipalityYesMunicipality BFS number (e.g. '261' for Zürich, '351' for Bern, '6621' for Genève). Use search_municipality_energy to find the ID.
categoryNoElectricity category. Household: H1–H8 (H4 is default, ~4500 kWh/year). Commercial: C1–C7. Default: H4.
yearNoTariff year (2011–2026). Default: current year (2026).

Implementation Reference

  • The implementation of the get_electricity_tariff tool handler, which processes the input arguments, fetches data from the ElCom GraphQL API, and formats the response.
    switch (name) {
      case "get_electricity_tariff": {
        const municipality = args.municipality as string;
        const category = (args.category as string | undefined) ?? "H4";
        const year = (args.year as string | undefined) ?? CURRENT_YEAR;
    
        if (!municipality?.trim()) {
          throw new Error("municipality is required. Use search_municipality_energy to find the BFS number.");
        }
    
        const raw = await getTariffWithComponents(municipality, category, year);
        const observations = raw.observations as Array<Record<string, unknown>>;
    
        if (!observations.length) {
          return JSON.stringify({
            error: "No tariff data found",
            municipality,
            category,
            year,
            hint: "Check the municipality BFS number with search_municipality_energy. Not all municipalities have tariff data for every year.",
            source: "https://www.strompreis.elcom.admin.ch",
          }, null, 2);
        }
    
        // If multiple operators, return all (some municipalities served by multiple operators)
        const result = observations.map((obs) => ({
          municipality: obs.municipalityLabel,
          municipalityId: obs.municipality,
          canton: obs.cantonLabel,
          operator: obs.operatorLabel,
          category,
          categoryDescription: CATEGORY_DESCRIPTIONS[category] ?? category,
          year,
          tariff: {
            total_rp_per_kwh: obs.total,
            components: {
              energy_rp_per_kwh: obs.energy,
              grid_usage_rp_per_kwh: obs.gridusage,
              municipality_charge_rp_per_kwh: obs.charge,
              federal_levy_rp_per_kwh: obs.aidfee,
              fixed_costs_rp_per_kwh: obs.fixcosts,
              metering_rate_rp_per_kwh: obs.meteringrate,
              annual_metering_cost_rp_per_kwh: obs.annualmeteringcost,
            },
          },
          coverageRatio: obs.coverageRatio,
          note: "Prices in Rappen per kWh (1 CHF = 100 Rappen)",
          source: `https://www.strompreis.elcom.admin.ch/municipality/${municipality}`,
        }));
    
        return JSON.stringify(result.length === 1 ? result[0] : result, null, 2);
      }
  • Tool definition and input schema for get_electricity_tariff.
    export const energyTools = [
      {
        name: "get_electricity_tariff",
        description:
          "Get Swiss electricity tariff (price in Rappen/kWh) for a municipality from ElCom (Swiss Federal Electricity Commission). Returns total price and price breakdown by component (energy, grid, taxes). Valid years: 2011–2026.",
        inputSchema: {
          type: "object",
          required: ["municipality"],
          properties: {
            municipality: {
              type: "string",
              description:
                "Municipality BFS number (e.g. '261' for Zürich, '351' for Bern, '6621' for Genève). Use search_municipality_energy to find the ID.",
            },
            category: {
              type: "string",
              description:
                "Electricity category. Household: H1–H8 (H4 is default, ~4500 kWh/year). Commercial: C1–C7. Default: H4.",
              enum: ["H1","H2","H3","H4","H5","H6","H7","H8","C1","C2","C3","C4","C5","C6","C7"],
            },
            year: {
              type: "string",
              description: "Tariff year (2011–2026). Default: current year (2026).",
            },
          },
        },
      },
  • Helper function getTariffWithComponents that encapsulates the GraphQL query logic for fetching electricity tariffs.
    async function getTariffWithComponents(municipality: string, category: string, year: string): Promise<Record<string, unknown>> {
      // Fetch all price components via aliased query
      const query = `
        query ObservationsWithAllPriceComponents($locale: String!, $filters: ObservationFilters!) {
          observations(locale: $locale, filters: $filters) {
            period
            municipality
            municipalityLabel
            operator
            operatorLabel
            canton
            cantonLabel
            category
            total: value(priceComponent: total)
            energy: value(priceComponent: energy)
            gridusage: value(priceComponent: gridusage)
            charge: value(priceComponent: charge)
            aidfee: value(priceComponent: aidfee)
            fixcosts: value(priceComponent: fixcosts)
            meteringrate: value(priceComponent: meteringrate)
            annualmeteringcost: value(priceComponent: annualmeteringcost)
          }
        }
      `;
    
      const data = await gql<{ observations: Array<Record<string, unknown>> }>(query, {
        locale: "de",
        filters: {
          period: [year],
          municipality: [municipality],
          category: [category],
        },
      });
    
      return { observations: data.observations ?? [] };
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: the data source (ElCom), valid year range (2011-2026), and return format (total price and breakdown by component). It doesn't mention rate limits or authentication requirements, but covers the essential operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with two sentences that are front-loaded with essential information. Every word earns its place, providing maximum information density without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only data retrieval tool with no output schema, the description provides good context about what data is returned (price breakdown) and constraints (year range). It could be more complete by specifying the exact format of the breakdown or mentioning data freshness, but covers the essential operational needs.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds some context about valid years and price breakdown, but doesn't provide additional parameter semantics beyond what's already well-documented in the schema descriptions for municipality, category, and year.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get'), resource ('Swiss electricity tariff'), and specific scope ('for a municipality from ElCom'). It distinguishes from siblings by focusing on electricity tariffs rather than other data types like weather, traffic, or population.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use it (for Swiss electricity tariffs from ElCom) and mentions a sibling tool ('search_municipality_energy') for finding municipality IDs. However, it doesn't explicitly state when NOT to use it or compare with 'compare_electricity_tariffs'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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