swiss-housing-mcp
This server provides MCP tools to query the Swiss Federal Register of Buildings and Dwellings (GWR/RegBL), covering building lookups, geocoding, dwelling details, and municipal construction statistics.
Look up a building by its EGID (federal building identifier) with address, status, coordinates, and construction year.
Geocode a Swiss address to EGID/EDID and LV95 coordinates, enabling other data sources to join on federal identifiers.
List all dwellings (EWID) of a building, including rooms, floor area, floor, and status.
Get yearly new residential construction per municipality, including total dwellings and the 4+ room family-housing share.
View the construction pipeline by status: projected, approved, and under construction — an early indicator for school-space planning.
Analyze buildings and dwellings within an LV95 bounding box for sub-municipal areas such as school districts.
Get a municipality housing overview: total/residential buildings, dwellings, and room-size mix.
Decode GWR code values (e.g., GSTAT, GKAT) into official German/French/Italian labels.
Check dump cache freshness and data provenance via
dump_status.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@swiss-housing-mcp How many new dwellings in Zurich since 2020?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
MCP server for the Swiss Federal Register of Buildings and Dwellings (GWR/RegBL) — buildings, dwellings, and the construction pipeline
🎯 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
Related MCP server: swiss-apis-mcp
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-madedata.sqlitewith tablesbuilding(399'830 rows for ZH),entrance,dwelling(894'631 rows for ZH), andcode. 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) andprovenance(daily_dump|live_api|cached).
Live probe findings (2026-07-24)
Endpoint | HTTP | Status | Note |
| 200 | ✅ works | full attribute set, no auth |
| 200 | ✅ works | 77 attributes incl. EGID/EWID |
| 200 | ✅ works |
|
| 200 | ✅ works | 121 MB, daily refresh, contains |
| 404 | ❌ excluded | path/auth unclear |
Invalid EGID on find | 200 | ⚠️ soft error | empty |
Features
lookup_building(egid)— single building by federal identifier (live API)address_to_egid(address)— geocode any Swiss address to EGID/EDID + LV95lookup_dwellings(egid)— all dwellings of a building with rooms, area, floornew_construction(municipality_bfs, since_year)— yearly new construction incl. 4+ room family-housing shareconstruction_pipeline(municipality_bfs)— projected / approved / under constructionbuildings_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 mixexplain_code(attribute, code)— decode GWR codes via the official DE/FR/IT code tabledump_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-mcpConfiguration
Variable | Default | Purpose |
|
|
|
|
| Dump cache directory |
|
| Dump 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.
Era | Revision | Who reaches it |
|
| What today's clients speak. The server answers with the revision asked for, or with the |
Per-request envelope |
| A request carrying the |
Both eras are measured, not inferred:
tests/test_modern_era.py drives real requests of
each era through this server's own ASGI app — the one __main__.py serves
under SWISS_HOUSING_TRANSPORT=streamable-http — and reads the negotiated
revision off the response body. Alongside it,
tests/test_protocol_version.py pins both
revisions against the installed SDK, so a Dependabot bump of mcp breaks the
build before anyone reads the measurement.
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.
Identity on the modern era. The 2026-07-28 era has no initialize
handshake: a connection is a single request carrying a _meta envelope. So
server/discover is the only channel through which a modern client learns
anything about this server, and the serverInfo block the SDK stamps into
every result is the only place its identity appears. This server therefore
declares version, title, description, websiteUrl and instructions.
description and websiteUrl are read from the package metadata rather than
repeated as literals — the SDK fills none of them in, and an unversioned server
announces an empty version on every single response.
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 upstreamProject 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 publishKnown 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_bboxcovers 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
cantonexplicitly 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
Portfolio siblings:
swiss-statistics-mcp(indices, STAT-TAB),zurich-opendata-mcp(city-level data)
Available Tools
9 toolsaddress_to_egidARead-only
Geocode a Swiss address to EGID/EDID and LV95 coordinates.
This is the bridge that makes other data sources EGID-capable: address in → federal building identifier out.
Inputs: address (required), limit. Returns: query, source, matches, provenance
buildings_in_bboxARead-only
Aggregate buildings/dwellings inside an LV95 bounding box.
Enables sub-municipal analysis, e.g. school districts: pass the bounding box of a Schulkreis to count new construction within it. LV95 (EPSG:2056): east ~2'480'000-2'840'000, north ~1'070'000-1'300'000.
Inputs: e_max (required), e_min (required), n_max (required), n_min (required), +2 more. Returns: source, bbox_lv95, buildings, dwellings, +3 more
construction_pipelineBRead-only
Buildings and dwellings in the planning/construction pipeline of a municipality.
Breaks down by status: projected (GSTAT 1001), approved (1002), under construction (1003). Dwellings under construction today are households in 1-3 years — the early indicator for school-space planning.
Inputs: municipality_bfs (required), canton. Returns: note, source, pipeline, provenance, +2 more
dump_statusARead-only
Cache status of the cantonal GWR dumps (graceful-degradation entry point).
Always returns an evaluable status — never silently empty records. If a source is unreachable, this tool tells you when data was last refreshed.
Inputs: no named parameters. Returns: note, dumps, source, ttl_hours, +1 more
explain_codeARead-only
Decode a GWR code value (e.g. GSTAT=1004, GKAT=1020) into human-readable labels.
Uses the official code table shipped with the dump (DE/FR/IT).
Inputs: code (required), attribute (required), canton. Returns: source, provenance, explanations
lookup_buildingARead-only
Look up a single building by its EGID (federal building identifier).
Uses the live geo.admin.ch API — always current, no dump download needed. The EGID is the join key used across Swiss administrative data.
Inputs: egid (required). Returns: found, source, building, provenance
lookup_dwellingsARead-only
List all dwellings (EWID) of a building from the daily cantonal dump.
Includes rooms, floor area, floor and status per dwelling.
Inputs: egid (required), canton. Returns: egid, count, source, dwellings, +1 more
municipality_housing_statsCRead-only
Housing stock overview of a municipality: buildings, dwellings, room-size mix.
Inputs: municipality_bfs (required), canton. Returns: source, provenance, municipality, buildings_total, +4 more
new_constructionBRead-only
New residential construction per year for a municipality (existing buildings).
Returns buildings, dwellings and 4+ room dwellings per year — the 4+ room share is a proxy for family housing and thus for future pupil numbers. Municipality is identified by its BFS number (e.g. 261 = City of Zurich).
Inputs: municipality_bfs (required), canton, since_year. Returns: source, per_year, provenance, since_year, +5 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a distinct resource or action: building lookup, dwelling lookup, address geocoding, bbox aggregation, municipal stock, pipeline, code decoding, and cache status. The closest pair, municipality_housing_stats and new_construction, is still clearly differentiated as stock overview vs. time-series construction.
All names are lowercase snake_case and readable, but conventions are mixed: some follow verb_noun (lookup_building, explain_code, dump_status), while others are noun phrases (buildings_in_bbox, municipality_housing_stats, construction_pipeline). There is no single consistent prefix or verb pattern across the set.
Nine tools is well-scoped for a Swiss housing/GWR data server. Each tool covers a meaningful query or utility function without redundancy or bloat.
The tool surface covers key workflows: address-to-EGID resolution, building and dwelling lookup, bounding-box aggregation, municipal stock, pipeline, historical construction, and code explanation. Minor gaps exist, such as no municipality-by-BFS-number search tool and no bulk code-table listing, but agents can work around these.
Maintenance
Related MCP Connectors
Geocoding, routing, isochrones, traffic, weather, and place search for AI agents. 19 MCP tools.
CompanyLens is a remote MCP server giving AI agents instant access to official company registry data across 19 jurisdictions in Europe, the Americas, and Asia-Pacific. Eighteen read-only tools let you search companies and people, look up officers and beneficial owners, map corporate networks through shared directors, screen names against the UK disqualified directors register, find every company at a registered address, and pull filing history — all from a single connector. Visit our website: https://companylens.io
Flat-rate US property/parcel search & CSV export for AI agents via MCP.
Agent-native MCP server over 49M+ US public and government records, privacy-first, always current.
Related MCP Servers
- AlicenseAqualityBmaintenanceProvides AI-native access to Swiss Federal Statistical Office datasets through 9 tools for querying education, population, and cross-cantonal comparisons without authentication.15214 PyPI2MIT
- AlicenseBqualityDmaintenanceMCP server exposing all major Swiss official public APIs as native tools for any MCP-compatible AI agent.3412 npmMIT
- AlicenseAqualityBmaintenanceMCP server for Switzerland's national metadata catalogue, enabling AI agents to discover datasets, APIs, public services, and publishers through free-text search and structured queries.1357 PyPIMIT
- AlicenseAqualityFmaintenanceMCP server that connects AI models to Swiss federal geodata, offering tools for spatial queries like layer discovery, coordinate identification, building zones, and terrain heights.9MIT