Skip to main content
Glama
swiss-housing-mcp

swiss-housing-mcp

by malkreide

swiss-housing-mcp

Swiss Public Data MCP Portfolio의 일부 — AI 에이전트를 스위스 공공 데이터에 연결하는 오픈소스 MCP 서버. 개인 프로젝트로, 고용주나 기관과 무관합니다.

Version License: MIT Python MCP

스위스 연방 건축물·주거등록부(GWR/RegBL)용 MCP 서버 — 건축물, 주거, 건설 파이프라인

🇩🇪 독일어 버전


🎯 앵커 데모 쿼리

«2020년 이후 취리히 시에 새로 지어진 주거는 몇 채이며, 그중 4개 이상의 방을 가진 주거는 몇 채인가 — 그리고 현재 공사 중인 주거는 몇 채인가?»

2026-07-24 라이브 덤프 기준 검증 완료: 2020년 이후 신규 주거 16,164채(그중 27.4%가 4개 이상의 방 — 가족용 주거 대리 지표), 현재 공사 중인 주거 7,287채. 오늘 공사 중인 주거는 1~3년 후의 가구 수를 의미합니다: 학교 공간 계획을 위한 조기 지표입니다.

데모

데모: new_construction 및 construction_pipeline을 사용하는 Claude


Related MCP server: swiss-apis-mcp

개요

GWR/RegBL은 건축물에 있어 Zefix가 기업에 해당하는 존재입니다: 많은 데이터 소스 중 하나가 아니라, 그 식별자(건축물은 EGID, 주거는 EWID)가 스위스 행정 데이터 전반의 조인 키로 사용되는 연방 등록부입니다. 이 서버는 등록부의 공개 추출본을 MCP 도구로 제공합니다 — 건축물 조회, 주소 지오코딩, 지자체별 건설 통계, 지자체 내 경계상자 분석, 계획·건설 파이프라인.

address_to_egid는 다른 데이터 소스를 EGID 호환으로 만드는 플러그입니다: 주소 입력, 연방 식별자와 LV95 좌표 출력.

아키텍처 결정

이 서버는 아키텍처 B(하이브리드: 덤프 우선, API 폴백) 를 사용합니다.

근거(2026-07-24 라이브 검증):

  • 공개 칸톤 덤프(public.madd.bfs.admin.ch/{canton}.zip)는 매일(~05:30 CET) 갱신되며, building(ZH 기준 399,830행), entrance, dwelling(ZH 기준 894,631행), code 테이블이 포함된 준비된 data.sqlite를 제공합니다. CSV 파싱도, 인증도 필요 없습니다.

  • api3.geo.admin.ch(find / identify / SearchServer)는 단일 개체 조회와 지오코딩에 인증 없이 안정적으로 작동하지만, 광역 집계에는 확장되지 않습니다(결과 제한).

  • /api/buildings/{egid}에서 프로브한 MADD REST 엔드포인트는 404를 반환했습니다. 경로와 인증 상태가 명확해질 때까지 제외됩니다 — 1단계 도구가 모두 이 엔드포인트 없이 작동하므로 차단 요인은 아닙니다.

결과:

  • 칸톤 덤프는 24시간 TTL(SWISS_HOUSING_DUMP_TTL_HOURS로 설정 가능)로 디스크에 캐시됩니다.

  • 집계와 공간 쿼리는 캐시된 SQLite에 대한 읽기 전용 SQL로 실행되며, 단일 조회와 지오코딩은 라이브 API를 사용합니다.

  • 모든 응답에는 source(출처)와 provenance(daily_dump | live_api | cached)가 포함됩니다.

라이브 프로브 결과(2026-07-24)

엔드포인트

HTTP

상태

비고

api3.geo.admin.ch …/find (EGID 조회)

200

✅ 작동

전체 속성 세트, 인증 불필요

api3.geo.admin.ch …/identify (좌표)

200

✅ 작동

EGID/EWID 포함 77개 속성

…/SearchServer (주소 → EGID)

200

✅ 작동

featureId = {EGID}_{EDID}; 축 교환: y=동, x=북

public.madd.bfs.admin.ch/zh.zip

200

✅ 작동

121MB, 매일 갱신, data.sqlite 포함

madd.bfs.admin.ch/api/buildings/{egid}

404

❌ 제외

경로/인증 불명확

find의 잘못된 EGID

200

⚠️ 소프트 오류

빈 results 배열 — HTTP 오류가 아님

기능

  • lookup_building(egid) — 연방 식별자로 단일 건축물 조회(라이브 API)

  • address_to_egid(address) — 모든 스위스 주소를 EGID/EDID + LV95로 지오코딩

  • lookup_dwellings(egid) — 건축물의 모든 주거 조회(방 수, 면적, 층 포함)

  • new_construction(municipality_bfs, since_year) — 연도별 신규 건설(4개 이상 방의 가족용 주거 비율 포함)

  • construction_pipeline(municipality_bfs) — 계획 / 승인 / 공사 중

  • buildings_in_bbox(e_min, n_min, e_max, n_max) — 지자체 내 분석(예: 학군)

  • municipality_housing_stats(municipality_bfs) — 주거 재고 및 방 크기 구성

  • explain_code(attribute, code) — 공식 DE/FR/IT 코드 테이블로 GWR 코드 해독

  • dump_status() — 캐시 신선도, 우아한 성능 저하 진입점

사전 요구 사항

  • Python 3.10+

  • 칸톤 덤프 1개당 디스크 약 130MB(ZH 기준)

  • API 키 불필요 — 1단계는 인증 없음

설치

uvx swiss-housing-mcp        # once published on PyPI

# or from source
pip install -e .

사용법 / 빠른 시작

Claude Desktop(claude_desktop_config.json):

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

클라우드(Render/Railway):

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

구성

변수

기본값

용도

SWISS_HOUSING_TRANSPORT

stdio

stdio | streamable-http | sse

SWISS_HOUSING_CACHE

~/.cache/swiss-housing-mcp

덤프 캐시 디렉터리

SWISS_HOUSING_DUMP_TTL_HOURS

24

덤프 신선도 창

MCP 프로토콜 버전

이 서버는 동일한 엔드포인트에서 두 프로토콜 시대를 지원합니다. 연결 시 클라이언트의 첫 요청이 어느 시대가 적용될지 결정하며, 다른 시대의 이후 주장은 거부됩니다.

시대

개정판

도달 대상

initialize 핸드셰이크

2024-11-05 … 2025-11-25

오늘날 클라이언트가 사용하는 버전. 서버는 요청된 개정판으로 응답하거나, 요청이 더 새로운 것을 요구할 경우 2025-11-25 상한선으로 응답합니다.

요청별 봉투

2026-07-28

2026-07-28 _meta 봉투를 담은 요청은 최신 연결을 엽니다.

두 개정판 모두 tests/test_protocol_version.py에 고정되어 있으며 설치된 SDK에 대해 검증되므로, mcp의 Dependabot 업데이트가 둘 중 하나를 조용히 이동시킬 수 없습니다. 이 서버는 initialize를 보낼 ASGI 앱을 구축하지 않으므로, 게이트는 측정된 응답이 아닌 SDK 상수를 검증합니다 — 더 약한 형태이지만, 언급되지 않은 채로 두는 것보다는 낫습니다.

SDK의 LATEST_PROTOCOL_VERSION은 최신 시대의 별칭이지 핸드셰이크 시대의 별칭이 아님에 유의하십시오 — 이에만 고정하면 현재 클라이언트가 실제로 협상하는 시대가 자유롭게 표류할 수 있습니다.

업데이트 정책. 게이트가 실패하면 상수를 맹목적으로 편집하지 마십시오: 두 개정판 사이의 사양 변경 로그를 읽고, 서버가 여전히 올바르게 작동하는지 확인한 다음, 상수, 이 섹션, README.de.md, CHANGELOG.md를 함께 이동하십시오.

테스트

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

프로젝트 구조

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

알려진 제한 사항

  • 공개 추출본은 전체 GWR의 개인 관련 및 일부 민감 속성을 생략합니다. 당국에 대한 공식 데이터 전달은 BFS/MADD 채널을 통해 이루어집니다.

  • 좌표는 건축물 기준점(LV95)이며, 건물 외곽선 폴리곤이 아닙니다 — 폴리곤 조인(예: 정확한 학군 경계)에는 외부 지오메트리가 필요합니다. buildings_in_bbox는 직사각형 근사치를 다룹니다.

  • GBAUJ(건축 연도)는 오래된 건축물의 일부에서 누락되어 있습니다. 기간 코드(GBAUP)가 폴백으로 존재하지만 아직 노출되지 않았습니다.

  • 지자체→칸톤 해석은 일반적인 경우에 대해 시드되어 있습니다. 다른 경우에는 canton을 명시적으로 전달하십시오.

  • 주택 시장 지수(IMPI, 건설 가격 지수, 공실률)는 의도적으로 swiss-statistics-mcp에 있습니다 — 이 서버는 등록부 계층이지 통계 계층이 아닙니다.

변경 로그

CHANGELOG.md 참조

기여

기여를 환영합니다 — CONTRIBUTING.md(독일어) 참조.

보안

읽기 전용, 개인 식별 정보 없음, 인증 없음 — 고정된 엔드포인트 세트를 통해 접근하는 공개 연방 등록부입니다. 전체 보안 태세와 취약점 신고 방법은 SECURITY.md(독일어)를 참조하십시오.

라이선스

MIT 라이선스 — LICENSE 참조. 데이터: GWR/RegBL, 스위스 연방 통계청(BFS), 출처 표시가 있는 오픈 정부 데이터.

저자

Hayal Oezkan · github.com/malkreide

크레딧 및 관련 프로젝트

Available Tools

9 tools
address_to_egidA
Read-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_bboxA
Read-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_pipelineB
Read-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_statusA
Read-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_codeA
Read-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_buildingA
Read-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_dwellingsA
Read-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_statsC
Read-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_constructionB
Read-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

    A3.5/5.0

    Scored across 9 tools

    Disambiguation5/5

    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.

    Naming Consistency3/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Provides AI-native access to Swiss Federal Statistical Office datasets through 9 tools for querying education, population, and cross-cantonal comparisons without authentication.
      15
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      MCP 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.
      13
      25 PyPI
      MIT