Skip to main content
Glama

get_rent_index

Retrieve Swiss Consumer Price Index data to track residential rent costs and cost of living trends, using monthly BFS publications with historical data from 1983 onward.

Instructions

Get the Swiss Consumer Price Index (CPI/LIK), which tracks cost of living including residential rents. Baseline December 1982 = 100. Published monthly by BFS. For property purchase prices, use get_property_price_index instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNoFilter to a specific year (1983–2025). Omit for latest 24 months.
limitNoNumber of recent monthly data points to return (1–60, default 24). Ignored if year is set.

Implementation Reference

  • The handleGetRentIndex function performs the logic of fetching and formatting the Swiss Consumer Price Index data.
    async function handleGetRentIndex(args: Record<string, unknown>): Promise<string> {
      const rawYear = typeof args.year === "number" ? args.year : undefined;
      const rawLimit = Math.min(60, Math.max(1, typeof args.limit === "number" ? args.limit : 24));
    
      // Fetch CPI (LIK) data from Canton Zug open data - monthly index (base Dec 1982 = 100)
      // This is the Swiss national CPI (Landesindex der Konsumentenpreise) which includes
      // the residential rent component
      const totalRecords = 515; // approximate total
    
      let url: string;
      if (rawYear !== undefined) {
        // Fetch specific year - estimate offset
        // Data starts from Dec 1982 (record 0) ~ month 0
        // Each year has 12 records. 1982 has 1 record (Dec only).
        const yearsFromStart = rawYear - 1982;
        const estOffset = Math.max(0, 1 + (yearsFromStart - 1) * 12);
        url = buildUrl(CPI_RENT_URL, { _limit: 12, _offset: estOffset });
      } else {
        // Latest data - fetch last N months
        const offset = Math.max(0, totalRecords - rawLimit);
        url = buildUrl(CPI_RENT_URL, { _limit: rawLimit, _offset: offset });
      }
    
      const data = await fetchJSON<ZgCpiResponse>(url, {
        headers: { "User-Agent": "mcp-swiss" },
      });
    
      // Filter by year if specified
      let rows = data.results;
      if (rawYear !== undefined) {
        rows = rows.filter((r) => r.jahr === String(rawYear));
      }
    
      if (rows.length === 0 && rawYear !== undefined) {
        throw new Error(
          `No CPI data found for year ${rawYear}. Available data: 1982–2025.`
        );
      }
    
      const series = rows.map((r) => ({
        year: parseInt(r.jahr, 10),
        month: r.monat,
        index: parseFloat(r.index),
      }));
    
      const latestRow = series[series.length - 1];
      const firstRow = series[0];
    
      // YoY change (if we have 12+ months)
      let yoyChange: number | null = null;
      if (series.length >= 13) {
        const prev = series[series.length - 13];
        if (prev) {
          yoyChange = parseFloat(
            (((latestRow.index - prev.index) / prev.index) * 100).toFixed(2)
          );
        }
      }
    
      const period =
        series.length > 0
          ? `${firstRow.month} ${firstRow.year} – ${latestRow.month} ${latestRow.year}`
          : "N/A";
    
      return JSON.stringify({
        index_name: "Swiss Consumer Price Index (LIK / IPC)",
        baseline: "December 1982 = 100",
        note:
          "The Swiss CPI (Landesindex der Konsumentenpreise) tracks the cost of living including residential rents. " +
          "This is the official Swiss national index published by BFS/FSO. " +
          "For the residential property price index (buying/ownership), use get_property_price_index.",
        period,
        latest: latestRow ?? null,
        data_points: series.length,
        series,
        yoy_change_percent: yoyChange,
        source: "Federal Statistical Office (BFS) via Canton Zug Open Data",
        source_url: "https://data.zg.ch/store/1/resource/334",
        ckan_dataset: "https://opendata.swiss/en/dataset/landesindex-der-konsumentenpreise",
      });
    }
  • The definition of get_rent_index containing the name, description, and inputSchema.
      name: "get_rent_index",
      description:
        "Get the Swiss Consumer Price Index (CPI/LIK), which tracks cost of living including " +
        "residential rents. Baseline December 1982 = 100. Published monthly by BFS. " +
        "For property purchase prices, use get_property_price_index instead.",
      inputSchema: {
        type: "object",
        properties: {
          year: {
            type: "number",
            description:
              "Filter to a specific year (1983–2025). Omit for latest 24 months.",
          },
          limit: {
            type: "number",
            description:
              "Number of recent monthly data points to return (1–60, default 24). Ignored if year is set.",
          },
        },
      },
    },
  • Registration of the get_rent_index tool in the main dispatcher within handleRealEstate function.
    case "get_rent_index":
      return handleGetRentIndex(args);
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: the tool retrieves published monthly data from BFS, provides historical context (baseline December 1982 = 100), and clarifies scope (cost of living including residential rents). However, it doesn't mention potential limitations like data availability or update frequency.

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 efficiently structured in two sentences with zero waste. The first sentence states the core purpose and scope, while the second provides crucial differentiation from sibling tools. Every element serves a clear purpose without redundancy.

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 annotations and no output schema, the description provides strong contextual completeness. It explains what the index measures, its baseline, publication frequency, and source. The main gap is lack of information about return format or data structure, which would be helpful given no output schema.

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?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description doesn't add any parameter-specific information beyond what's in the schema, but it does provide context about the data (monthly publication, baseline) that helps interpret parameter usage. This meets the baseline expectation when schema coverage is complete.

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 tool's purpose with specific verbs ('Get') and resources ('Swiss Consumer Price Index (CPI/LIK)'), explicitly distinguishing it from sibling tools by mentioning 'For property purchase prices, use get_property_price_index instead.' This provides clear differentiation and avoids redundancy with the tool name.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance by specifying when to use this tool (for residential rent tracking) and when to use an alternative ('For property purchase prices, use get_property_price_index instead'). It also includes context about the data source and baseline, which helps the agent understand appropriate use cases.

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