Skip to main content

MCP Server for Swiss commercial register (Zefix/Handelsregister) and UID register

Project description

๐Ÿ‡จ๐Ÿ‡ญ Part of the Swiss Public Data MCP Portfolio

๐Ÿ›๏ธ register-mcp

Version License: MIT Python 3.11+ MCP No Auth Required CI

MCP Server for the Swiss Federal Commercial Register (Zefix/Handelsregister) and supporting reference data

๐Ÿ‡ฉ๐Ÿ‡ช Deutsche Version


Overview

register-mcp provides AI-native access to the Swiss Federal Commercial Register via the Zefix REST API, all without authentication:

Source Data API
Zefix (Handelsregister) Swiss companies, legal forms, SHAB mutations ZefixREST v1
SHAB Official Gazette of Commerce โ€” mutation publications Embedded in Zefix

Designed for Swiss public administration use cases: vendor verification, contract partner due diligence, procurement screening, and supplier onboarding โ€” all via natural language queries.

Anchor demo query: "We want to sign a framework agreement with Lehrmittelverlag Zรผrich AG. Is the company active in the commercial register, what is its stated corporate purpose, and have there been any SHAB mutations in the past two years?"


Features

  • ๐Ÿ›๏ธ 6 tools for company search, verification, and reference data
  • ๐Ÿ” zefix_verify_company โ€” quick active/dissolved status check
  • ๐ŸŒ Bilingual output (Markdown / JSON)
  • ๐Ÿ”“ No API key required โ€” open data from zefix.admin.ch
  • โ˜๏ธ Dual transport โ€” stdio (Claude Desktop) + SSE (cloud)

Prerequisites

  • Python 3.11+
  • uv (recommended) or pip

Installation

# Clone the repository
git clone https://github.com/malkreide/register-mcp.git
cd register-mcp

# Install
pip install -e .
# or with uv:
uv pip install -e .

Or with uvx (no permanent installation):

uvx register-mcp

Quickstart

# stdio (for Claude Desktop)
python -m register_mcp.server

# SSE (cloud deployment) โ€” MCP_API_KEY is REQUIRED
MCP_API_KEY=$(openssl rand -hex 32) MCP_TRANSPORT=sse PORT=8000 \
  python -m register_mcp.server

SSE / Cloud Deployment

When running with MCP_TRANSPORT=sse, the server enforces:

  • Bearer-token auth โ€” set MCP_API_KEY to a secret string. Clients must send Authorization: Bearer <key> on every request. Missing or wrong โ†’ HTTP 401. The server refuses to start without MCP_API_KEY set.
  • Rate limiting โ€” sliding window per bearer-token hash. Defaults: 60 req / 60 s. Tunable via MCP_RATE_LIMIT and MCP_RATE_WINDOW. Exceeding the limit returns HTTP 429 with Retry-After.
  • Structured JSON logging โ€” every tool call emits one line to stderr with tool, status, latency_ms. Auth failures and rate-limit events are logged at WARNING level. Configure verbosity with LOG_LEVEL (default INFO).
  • Reference-data cache โ€” Zefix legal-forms are cached for 24h (LEGAL_FORMS_TTL seconds) to avoid an extra upstream call per tool invocation.
  • Egress allow-list โ€” outbound HTTP is restricted to www.zefix.admin.ch via an httpx request hook that also fires on redirects. A Location header pointing elsewhere raises EgressDenied and is never followed. Override with MCP_ALLOWED_HOSTS=host1,host2 (comma-separated, lower-case).
  • Optional OpenTelemetry tracing โ€” install with pip install register-mcp[otel] and set OTEL_EXPORTER_OTLP_ENDPOINT (e.g. http://otel-collector:4318/v1/traces). Without the extra or without the env var the server stays silent โ€” no hard dependency on the OTel SDK.

For multi-instance deployments, place a real gateway (Cloudflare, Railway internal networking, an API-Gateway with Redis-backed rate limiting) in front of the in-memory limiter, which is per-process by design.

Container deployment

A minimal multi-stage Dockerfile ships with the repo. The image runs as a non-root mcp user; dependencies are resolved from uv.lock (uv sync --frozen), so the build is reproducible.

docker build -t register-mcp:local .

docker run --rm -p 8000:8000 \
  -e MCP_TRANSPORT=sse \
  -e MCP_API_KEY="$(openssl rand -hex 32)" \
  register-mcp:local

For local iteration there is a compose.yaml with read_only, cap_drop: ALL and no-new-privileges:

MCP_API_KEY=$(openssl rand -hex 32) docker compose up --build

See SECURITY.md for hardening notes (egress restriction, key rotation, SIEM forwarding).

Try it immediately in Claude Desktop:

"Is Lehrmittelverlag Zรผrich AG active in the commercial register?" "Look up the company with UID CHE-108.954.978" "List all Swiss legal forms"


Configuration

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "register": {
      "command": "python",
      "args": ["-m", "register_mcp.server"]
    }
  }
}

Or with uvx:

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

Config file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Cloud Deployment (SSE for browser access)

For use via claude.ai in the browser (e.g. on managed workstations without local software):

Render.com (recommended):

  1. Push/fork the repository to GitHub
  2. On render.com: New Web Service โ†’ connect GitHub repo
  3. Set start command: python -m register_mcp.server --http --port 8000
  4. In claude.ai under Settings โ†’ MCP Servers, add: https://your-app.onrender.com/sse

๐Ÿ’ก "stdio for the developer laptop, SSE for the browser."


Available Tools

Tool Description
zefix_search_companies Search companies by name, canton, legal form
zefix_get_company Full company profile by internal EHRAID
zefix_get_company_by_uid Company lookup by UID (CHE-xxx.xxx.xxx)
zefix_verify_company Quick active/dissolved status check
zefix_list_legal_forms All Swiss legal forms with IDs
zefix_list_municipalities Swiss municipalities with BFS IDs

Example Use Cases

Query Tool
"Is Lehrmittelverlag Zรผrich AG active?" zefix_verify_company
"Look up CHE-108.954.978" zefix_get_company_by_uid
"Find companies named Migros in canton ZH" zefix_search_companies
"List all Swiss legal forms" zefix_list_legal_forms
"Show municipalities in canton Bern" zefix_list_municipalities

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Claude / AI   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚       register-mcp            โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  Zefix (Handelsregister)  โ”‚
โ”‚   (MCP Host)    โ”‚โ—€โ”€โ”€โ”€โ”€โ”‚       (MCP Server)            โ”‚โ—€โ”€โ”€โ”€โ”€โ”‚  ZefixREST/api/v1        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚                              โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚  6 Tools                     โ”‚
                        โ”‚  Stdio | SSE                 โ”‚
                        โ”‚  No authentication required  โ”‚
                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Data Source Characteristics

Source Protocol Coverage Auth
Zefix (Phase 1) REST/JSON Swiss companies, legal forms, SHAB None
ZefixPublicREST (Phase 2) REST/JSON Signatories, capital, full history Basic Auth (free)
UID Register (Phase 3) SOAP MwSt, NOGA codes, cross-validation Public (20 req/min)

Phased Implementation

Phase API Auth Status
Phase 1 ZefixREST/api/v1 None Current
Phase 2 ZefixPublicREST/api/v1 Basic Auth (free, email zefix@bj.admin.ch) Planned
Phase 3 UID-Register SOAP Public (20 req/min) Planned

Phase 2 will add: signatory details, share capital, full historical entries. Phase 3 will add: MwSt status, NOGA industry codes, cross-register validation.


Project Structure

register-mcp/
โ”œโ”€โ”€ src/register_mcp/
โ”‚   โ”œโ”€โ”€ __init__.py              # Package
โ”‚   โ””โ”€โ”€ server.py                # 6 tools (Zefix + reference data)
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_server.py           # Unit + integration tests (mocked HTTP)
โ”œโ”€โ”€ docs/demo/
โ”‚   โ”œโ”€โ”€ demo.tape                # vhs recording script โ†’ demo.gif
โ”‚   โ”œโ”€โ”€ demo.py                  # Standalone CLI demo (live Zefix API)
โ”‚   โ””โ”€โ”€ README.md                # How to generate the demo GIF
โ”œโ”€โ”€ .github/workflows/ci.yml     # GitHub Actions (Python 3.11/3.12/3.13)
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md                    # This file (English)
โ””โ”€โ”€ README.de.md                 # German version

Known Limitations

  • Search by canton without a name filter may return API errors (Zefix API limitation)
  • SHAB publication message text contains XML-style markup (<FT TYPE="F">...)
  • Phase 1 API may be rate-limited under heavy load; retry after a short delay
  • ZefixPublicREST (new API) requires registration: email zefix@bj.admin.ch

Safety & Limits

Rate Limits

API Limit Notes
ZefixREST (Phase 1) Not officially documented Throttling possible under heavy load โ€” retry after 1โ€“2 s
ZefixPublicREST (Phase 2) Not officially documented Requires prior registration (free)
UID-Register SOAP (Phase 3) 20 req/min Hard limit, publicly documented

Data Privacy

  • Read-only access โ€” all tools carry readOnlyHint: True; the server performs no write, delete, or mutation operations against any API
  • No data storage โ€” the server acts as a stateless proxy; no company data is persisted, cached, or logged beyond the current request
  • Public register data only โ€” the Zefix Handelsregister is a public federal register (HRegV); data returned is legally public information, not personal data in the sense of DSG/GDPR
  • No personal tracking โ€” the server does not transmit user identity, query history, or session data to zefix.admin.ch

Terms of Service & Data Sources

  • Zefix API ToS: Usage of the Zefix REST API is governed by the zefix.admin.ch terms of use. The data is published under the Open Government Data (OGD) Switzerland principles.
  • SHAB: Swiss Official Gazette of Commerce โ€” published by the Federal Chancellery (BK). Public by law.
  • Institutional use: This server is designed for read-only queries in public administration workflows. Not suitable for mass harvesting or automated surveillance use cases.

Security

  • No credentials are stored or transmitted (Phase 1)
  • Phase 2 credentials (ZEFIX_USER, ZEFIX_PASSWORD) are passed via environment variables only โ€” never hardcoded
  • All HTTP calls use HTTPS exclusively
  • Tool inputs are validated via Pydantic v2 before any API call is made

Demo

register-mcp demo

๐Ÿ“ฝ๏ธ Terminal GIF coming soon โ€” see docs/demo/ to generate it locally with vhs

Example interaction:

User:  "Is Lehrmittelverlag Zรผrich AG active in the commercial register?"

โ†’ Tool: zefix_verify_company(name="Lehrmittelverlag Zรผrich AG")

Claude: โœ… Lehrmittelverlag Zรผrich AG is ACTIVE in the Handelsregister.
        UID: CHE-109.741.634 | Canton: ZH | Legal form: AG
        Last SHAB mutation: 2024-06-15

โ†’ More use cases by audience โ†’

To generate the demo GIF locally:

# Install vhs (macOS/Linux)
brew install vhs        # macOS
# or: go install github.com/charmbracelet/vhs@latest

# Generate
vhs docs/demo/demo.tape
# โ†’ outputs docs/demo/demo.gif

Testing

# Unit tests (no API key required)
PYTHONPATH=src pytest tests/ -m "not live"

# Integration tests (live API calls)
pytest tests/ -m "live"

Changelog

See CHANGELOG.md


Contributing

See CONTRIBUTING.md


License

MIT License โ€” see LICENSE


Author

Hayal Oezkan ยท malkreide


Credits & Related Projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

register_mcp-0.2.0.tar.gz (275.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

register_mcp-0.2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file register_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: register_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 275.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for register_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 989e7576277c6bd3527954c77c3531bff789a45b2afd5e062064f7f5b49aafc2
MD5 a78fdc788eef79731429272e909a1043
BLAKE2b-256 23babfa42dacf0c4ec81074dd93507ec23cefeaeaac6bd629eda95d4ebfee860

See more details on using hashes here.

Provenance

The following attestation bundles were made for register_mcp-0.2.0.tar.gz:

Publisher: publish.yml on malkreide/register-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file register_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: register_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for register_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1921032551d845a580ff2b01c9f319fbe41a2cd29f77ae42b91730ce18f5bc7e
MD5 d56d03e48b4843b3dcd3f118ac46a5ed
BLAKE2b-256 0af317fc3026c36f160a67c02cc128e260d98074a622fd85278ca46952844bed

See more details on using hashes here.

Provenance

The following attestation bundles were made for register_mcp-0.2.0-py3-none-any.whl:

Publisher: publish.yml on malkreide/register-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page