Back to Browse

Swiss Housing MCP Server

Developer ToolsLow Risk10.0MCP RegistryLocal
Free

Server data from the Official MCP Registry

Swiss Register of Buildings and Dwellings (GWR/RegBL): EGID/EWID lookup, geocoding, housing stats

About

Swiss Register of Buildings and Dwellings (GWR/RegBL): EGID/EWID lookup, geocoding, housing stats

Security Report

10.0
Low Risk10.0Low Risk

Valid MCP server (2 strong, 4 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry. Trust signals: trusted author (41/42 approved).

8 files analyzed Β· 1 issue found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

file_system

Check that this permission is expected for this type of plugin.

HTTP Network Access

Connects to external APIs or services over the internet.

env_vars

Check that this permission is expected for this type of plugin.

database

Check that this permission is expected for this type of plugin.

What You'll Need

Set these up before or after installing:

stdioOptional

Environment variable: SWISS_HOUSING_TRANSPORT

~/.cache/swiss-housing-mcpOptional

Environment variable: SWISS_HOUSING_CACHE

24Optional

Environment variable: SWISS_HOUSING_DUMP_TTL_HOURS

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "io-github-malkreide-swiss-housing-mcp": {
      "args": [
        "swiss-housing-mcp"
      ],
      "command": "uvx"
    }
  }
}

Documentation

View on GitHub

From the project's GitHub README.

swiss-housing-mcp

Part of the Swiss Public Data MCP Portfolio β€” open-source MCP servers connecting AI agents to Swiss public data. Private project, independent of any employer or institutional affiliation.

Version License: MIT Python MCP

MCP server for the Swiss Federal Register of Buildings and Dwellings (GWR/RegBL) β€” buildings, dwellings, and the construction pipeline

πŸ‡©πŸ‡ͺ Deutsche Version


🎯 Anchor Demo Query

Β«How many dwellings were newly built in the City of Zurich since 2020, how many with 4+ rooms β€” and how many are currently under construction?Β»

Verified against the live dump on 2026-07-24: 16'164 new dwellings since 2020 (27.4% with 4+ rooms β€” the family-housing proxy), and 7'287 dwellings currently under construction. Dwellings under construction today are households in 1–3 years: the early indicator for school-space planning.

Demo

Demo: Claude using new_construction and construction_pipeline


Overview

The GWR/RegBL is to buildings what Zefix is to companies: not one data source among many, but the federal register whose identifiers (EGID for buildings, EWID for dwellings) serve as join keys across Swiss administrative data. This server exposes the register's public extract through MCP tools β€” building lookups, address geocoding, per-municipality construction statistics, sub-municipal bounding-box analysis, and the planning/construction pipeline.

address_to_egid is the plug that makes other data sources EGID-capable: address in, federal identifier and LV95 coordinates out.

Architecture decision

This server uses Architecture B (Hybrid: Dump-first, API-fallback).

Rationale (verified live on 2026-07-24):

  • The public cantonal dump (public.madd.bfs.admin.ch/{canton}.zip) is refreshed daily (~05:30 CET) and ships a ready-made data.sqlite with tables building (399'830 rows for ZH), entrance, dwelling (894'631 rows for ZH), and code. No CSV parsing, no auth.
  • api3.geo.admin.ch (find / identify / SearchServer) works reliably without authentication for single-entity lookups and geocoding, but does not scale to area-wide aggregations (result limits).
  • A MADD REST endpoint probed at /api/buildings/{egid} returned 404; it is excluded until path and auth status are clarified β€” no blocker, since all Phase-1 tools work without it.

Consequences:

  • Cantonal dumps are cached on disk with a 24 h TTL (configurable via SWISS_HOUSING_DUMP_TTL_HOURS).
  • Aggregations and spatial queries run as read-only SQL against the cached SQLite; single lookups and geocoding hit the live API.
  • Every response carries source (attribution) and provenance (daily_dump | live_api | cached).

Live probe findings (2026-07-24)

EndpointHTTPStatusNote
api3.geo.admin.ch …/find (EGID lookup)200βœ… worksfull attribute set, no auth
api3.geo.admin.ch …/identify (coordinates)200βœ… works77 attributes incl. EGID/EWID
…/SearchServer (address β†’ EGID)200βœ… worksfeatureId = {EGID}_{EDID}; axis swap: y=east, x=north
public.madd.bfs.admin.ch/zh.zip200βœ… works121 MB, daily refresh, contains data.sqlite
madd.bfs.admin.ch/api/buildings/{egid}404❌ excludedpath/auth unclear
Invalid EGID on find200⚠️ soft errorempty results array β€” not an HTTP error

Features

  • lookup_building(egid) β€” single building by federal identifier (live API)
  • address_to_egid(address) β€” geocode any Swiss address to EGID/EDID + LV95
  • lookup_dwellings(egid) β€” all dwellings of a building with rooms, area, floor
  • new_construction(municipality_bfs, since_year) β€” yearly new construction incl. 4+ room family-housing share
  • construction_pipeline(municipality_bfs) β€” projected / approved / under construction
  • buildings_in_bbox(e_min, n_min, e_max, n_max) β€” sub-municipal analysis (e.g. school districts)
  • municipality_housing_stats(municipality_bfs) β€” housing stock and room-size mix
  • explain_code(attribute, code) β€” decode GWR codes via the official DE/FR/IT code table
  • dump_status() β€” cache freshness, graceful-degradation entry point

Prerequisites

  • Python 3.10+
  • ~130 MB disk per cached cantonal dump (ZH)
  • No API keys β€” Phase 1 is authentication-free

Installation

uvx swiss-housing-mcp        # once published on PyPI

# or from source
pip install -e .

Usage / Quickstart

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "swiss-housing": {
      "command": "uvx",
      "args": ["swiss-housing-mcp"]
    }
  }
}

Cloud (Render/Railway):

SWISS_HOUSING_TRANSPORT=streamable-http PORT=8000 swiss-housing-mcp

Configuration

VariableDefaultPurpose
SWISS_HOUSING_TRANSPORTstdiostdio | streamable-http | sse
SWISS_HOUSING_CACHE~/.cache/swiss-housing-mcpDump cache directory
SWISS_HOUSING_DUMP_TTL_HOURS24Dump freshness window

MCP Protocol Version

This server speaks two protocol eras over the same endpoint. The client's first request on a connection decides which one applies; a later claim from the other era is refused.

EraRevisionWho reaches it
initialize handshake2024-11-05 … 2025-11-25What today's clients speak. The server answers with the revision asked for, or with the 2025-11-25 ceiling when the request asks for something newer.
Per-request envelope2026-07-28A request carrying the 2026-07-28 _meta envelope opens a modern connection.

Both revisions are pinned in tests/test_protocol_version.py and asserted against the installed SDK, so a Dependabot bump of mcp cannot move either one silently. This server builds no ASGI app to send an initialize through, so the gate asserts the SDK constants rather than a measured response β€” the weaker form, named rather than left unsaid.

Note that the SDK's LATEST_PROTOCOL_VERSION is an alias for the modern era, not for the handshake era β€” pinning against it alone would leave the era that current clients actually negotiate free to drift.

Update policy. When the gate fails, do not edit the constant blindly: read the spec changelog between the two revisions, verify the server still behaves, then move the constant, this section, README.de.md and CHANGELOG.md together.

Testing

PYTHONPATH=src pytest tests/ -m "not live"   # CI-safe
PYTHONPATH=src pytest tests/ -m live         # against real upstream

Project Structure

swiss-housing-mcp/
β”œβ”€β”€ src/swiss_housing_mcp/
β”‚   β”œβ”€β”€ server.py      # FastMCP tools (9)
β”‚   β”œβ”€β”€ gwr.py         # Dump store + geo.admin.ch client + retry
β”‚   β”œβ”€β”€ models.py      # Pydantic v2 envelopes (source + provenance)
β”‚   └── __main__.py    # Dual-transport entry point
β”œβ”€β”€ tests/             # respx-mocked + @pytest.mark.live
└── .github/workflows/ # CI + OIDC PyPI publish

Known Limitations

  • The public extract omits person-related and some sensitive attributes of the full GWR; official data deliveries to authorities go through the BFS/MADD channel.
  • Coordinates are building reference points (LV95), not footprint polygons β€” polygon joins (e.g. exact school-district boundaries) need external geometries; buildings_in_bbox covers the rectangular approximation.
  • GBAUJ (construction year) is missing for a share of older buildings; period codes (GBAUP) exist as fallback but are not yet exposed.
  • Municipalityβ†’canton resolution is seeded for common cases; pass canton explicitly for others.
  • Housing-market indices (IMPI, construction price index, vacancy rate) deliberately live in swiss-statistics-mcp β€” this server is the register layer, not the statistics layer.

Changelog

See CHANGELOG.md

Contributing

Contributions are welcome β€” see CONTRIBUTING.md (Deutsch).

Security

Read-only, no PII, no authentication β€” a public federal register accessed through a fixed set of endpoints. See SECURITY.md (Deutsch) for the full posture and how to report a vulnerability.

License

MIT License β€” see LICENSE. Data: GWR/RegBL, Swiss Federal Statistical Office (BFS), open government data with attribution.

Author

Hayal Oezkan Β· github.com/malkreide

Credits & Related Projects

Reviews

No reviews yet

Be the first to review this server!