MCP server for amtsblattportal.ch (SHAB + cantonal gazettes) โ procurement and official notices, person-data rubrics excluded by design
Project description
๐จ๐ญ Part of the Swiss Public Data MCP Portfolio
๐ฐ amtsblatt-mcp
MCP server for amtsblattportal.ch โ the Swiss official gazette portal (SHAB + 27 cantonal gazettes). Public procurement and official notices, person-data rubrics excluded by design.
Overview
The Amtsblattportal publishes roughly 2.79 million official notices: public procurement, cantonal and communal announcements, enactments, spatial planning โ and also bankruptcies, debt collection, inheritance calls and civil-status records naming natural persons.
This server exposes only the first group. Rubrics carrying systematic natural-person data are not queryable, and no tool accepts a person's name, birth date or address. That is a deliberate data-protection decision, explained in Data Protection & Scope.
Anchor demo query: "Which public IT tenders were published in canton
Basel-Stadt in the last three months?"
โ search_procurement(canton="BS", keyword="Informatik") โ get_publication(id=โฆ)
Features
- Fail-closed green allow-list โ 49 released rubrics out of 152; everything else is blocked by default, including rubrics the upstream adds later
- Explanatory refusals โ a blocked rubric returns why, never a silent empty result and never a workaround hint
- Procurement-aware โ knows that only AR, BS, TI, ZG publish tenders here and that ZH routes them through simap.ch, so it explains instead of returning nothing
- Deadline arithmetic in Europe/Zurich, the legally relevant timezone
- Language deduplication โ a notice published in de/fr/it counts once
- Defensive XML parsing โ the schema is per-sub-rubric; no rubric-specific path is hard-coded, and entity-escaped HTML bodies are unescaped and stripped
- Egress allow-list, retry with backoff, structured JSON logging
- Markdown or JSON output with per-response attribution +
provenance
Prerequisites
- Python 3.11+
- No API key. The read API of amtsblattportal.ch is freely accessible.
Installation
pip install amtsblatt-mcp
# or, without installing:
uvx amtsblatt-mcp
From source:
git clone https://github.com/malkreide/amtsblatt-mcp
cd amtsblatt-mcp
pip install -e ".[dev]"
Configuration
Claude Desktop
{
"mcpServers": {
"amtsblatt": {
"command": "uvx",
"args": ["amtsblatt-mcp"]
}
}
}
Cloud deployment (SSE)
export MCP_TRANSPORT=sse
export MCP_API_KEY="$(openssl rand -hex 32)" # mandatory โ fails loud if unset
export PORT=8000
amtsblatt-mcp
| Variable | Default | Purpose |
|---|---|---|
MCP_TRANSPORT |
stdio |
stdio or sse |
MCP_HOST |
127.0.0.1 |
SSE bind address. Defaults to loopback; set 0.0.0.0 to expose on all interfaces (the Docker image does this deliberately). |
MCP_API_KEY |
โ | Bearer token; required for SSE |
MCP_RATE_LIMIT / MCP_RATE_WINDOW |
60 / 60 |
Sliding-window rate limit |
MCP_ALLOWED_HOSTS |
amtsblattportal.ch,www.amtsblattportal.ch |
Egress allow-list. An override replaces the default entirely. |
RUBRICS_TTL |
86400 |
Taxonomy cache TTL (seconds) |
LOG_LEVEL |
INFO |
Structured JSON logs to stderr |
Available Tools
| Tool | Signature | Notes |
|---|---|---|
search_publications |
(keyword?, rubric?, sub_rubric?, canton?, date_start?, date_end?, limit=20, page=0, language='de') |
Green rubrics enforced. Without rubric, all green rubrics are injected โ a keyword-only query can never reach a blocked one. |
search_procurement |
(keyword?, canton?, date_start?, date_end?, include_inactive=False, limit=20, page=0) |
OB-* only. A canton without an OB-* rubric gets a simap.ch explainer and no HTTP call. No CPV โ the source has none. |
get_publication |
(id, response_format='markdown') |
Full official text from XML. Re-checks the rubric after fetching; content from a blocked rubric is discarded. |
list_rubrics |
(language='de', rubric_class='green', response_format='markdown') |
rubric_class='all' shows the full taxonomy with traffic-light classes and reasons โ listed โ queryable. |
source_status |
(response_format='markdown') |
Reachability, latency, cache age, scope metrics. |
All tools are readOnlyHint=True.
Example use cases
| Question | Tool chain |
|---|---|
| IT tenders in Basel-Stadt this quarter | search_procurement(canton="BS", keyword="Informatik") |
| What is even queryable here? | list_rubrics() |
| Why can't I search bankruptcies? | list_rubrics(rubric_class="all") |
| Zoning changes in Zurich | search_publications(rubric="RP-ZH") |
| Full text of a notice | get_publication(id="fbf0ff9e-โฆ") |
| Everything published about one company | โ use register-mcp |
Data Protection & Scope
The Amtsblattportal systematically publishes personal data of natural persons. Those publications are public โ but making them systematically queryable by name through an AI agent is a repurposing the publication never intended, and a profiling instrument under the revised Swiss FADP (revDSG).
Four rules follow, and they are enforced in code, not in documentation:
- Allow-list, never block-list. Not explicitly green โ not queryable. New upstream rubrics are closed by default.
- No person-based search entry in any tool signature.
- No persistence. Publications have statutory deletion periods; a cache outliving them would actively undermine them. Only the taxonomy is cached.
- Blocked โ explained. Never a silent empty result, never a hint at circumvention.
What is excluded
๐ด Konkurse (KK), Schuldbetreibungen (SB), Schuldenrufe (LS, SR),
Nachlass (NA), Erbschaft/Testament/Ableben (ES, TE-*, VA-*),
Familie & Zivilstand (FZ-*, BV-*, BU-*), gerichtliche Vorladungen
(UV, GB-*, GE-*, SJ-BE), Baugesuche (BP-*), Grundbuch (GR-*),
Meldungskatalog GR (AA-GR).
๐ก Deferred: Steuerwesen, Anzeigen, Bewilligungen, Bildungs- und Kirchenwesen and the general catch-all rubrics.
The full audit trail โ including three documented extensions to the source
specification โ is in docs/rubric-classification.md.
The boundary with register-mcp
For publications about a specific company, use
register-mcp. It keeps full
rubric access โ including a firm's own bankruptcy โ but only ever keyed on a
company UID. A firm's insolvency is corporate data, not natural-person
profiling, and UID scoping makes name-based enumeration impossible.
amtsblatt-mcp has the opposite shape: broad search, narrow rubrics. It does
not expose the upstream uids parameter at all.
Architecture
Claude / MCP client
โ
amtsblatt-mcp
โ
โโโโโโโโโโดโโโโโโโโโ
โ green gate โ โ rubrics.py: fail-closed allow-list
โโโโโโโโโโฌโโโโโโโโโ (checked at the tool AND at the query builder)
โ
โโโโโโโโโโดโโโโโโโโโ
โ param allow- โ โ Silent Ignore guard
โ list + quirks โ โ Silent Empty guard (taxonomy validation)
โโโโโโโโโโฌโโโโโโโโโ โ plausibility guard (corpus-size check)
โ
โโโโโโโโโโดโโโโโโโโโ
โ egress allow- โ
โ list (httpx) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
amtsblattportal.ch/api/v1
/publications ยท /publications/{id}/xml ยท /rubrics ยท /tenants
Architecture A (live-API-only). The endpoints answer stably without authentication, so no bulk dump is maintained.
Verified upstream quirks (live-checked 2026-07-20)
| Quirk | Behaviour | Defence |
|---|---|---|
| Silent Ignore | An unknown parameter name returns HTTP 200 and the full corpus. canton=ZH (singular typo) silently drops the filter. |
Query params built exclusively from ALLOWED_GAZETTE_PARAMS; plausibility guard rejects results > 2 000 000. |
| Silent Empty | An unknown rubric value returns HTTP 200 with total: 0 โ indistinguishable from a real no-hit. |
Every code validated against the taxonomy before the call. |
| Metadata only | The list endpoint and GET /publications/{id} both return content: null. |
Full text only via /publications/{id}/xml. |
| Sorting ignored | pageRequest.sortOrders is accepted with 200 but has no effect; sortOrders comes back []. |
Sorted client-side. |
Missing publicationStates |
Returns 401, not 400 โ it does not mean credentials are required. | Always injected; the 401 message says so. |
| No page-size cap | pageRequest.size=2000 returns 2000 items. |
Client-side cap of 100. |
| Inconsistent plurals | rubrics/cantons/subRubrics are plural, keyword/tenant singular. |
Exact spellings encoded, not a pluralisation rule. |
Known Limitations
- Uneven cantonal coverage. Only 16 of 29 mandates expose their own rubric taxonomy; AG, FR, GE, GL, JU, LU, NE, UR are still incomplete.
- Deletion periods. Publications drop out of the API over time โ hence pass-through only.
- Procurement boundary. Most cantons, including Zรผrich, route tenders
through simap.ch, outside this portal. There is no
OB-ZH, and no CPV classification exists here. - No push. Polling only; no subscription or webhook mechanism.
- Legally binding text is the signed PDF, not this API.
Testing
pip install -e ".[dev]"
PYTHONPATH=src pytest tests/ -m "not live" # 75 tests, no network
PYTHONPATH=src pytest tests/ -m live # hits the real API
ruff check src/ tests/
The suite covers the mandatory portfolio set: green-rubric search with source URL, blocked rubric โ explanation with zero HTTP calls, canton filtering, Europe/Zurich deadline arithmetic against a fixed "today", pagination across a page boundary, language deduplication, boolean normalisation, and API-unreachable handling. Fixtures are shortened real responses, consistently anonymised โ no real personal data.
Project Structure
amtsblatt-mcp/
โโโ src/amtsblatt_mcp/
โ โโโ rubrics.py # Fail-closed green allow-list โ the scope decision
โ โโโ server.py # FastMCP server, 5 tools, quirk guards, XML parsing
โ โโโ _log.py # Structured JSON logging + per-tool call events
โ โโโ _middleware.py # Bearer auth + sliding-window rate limit (SSE only)
โ โโโ _otel.py # Optional OpenTelemetry wiring
โโโ tests/
โ โโโ test_allowlist.py # Data-protection invariants (own CI job)
โ โโโ test_search.py # Search, procurement, pagination, dedup, errors
โ โโโ test_publication.py # XML parsing, deadlines, egress allow-list
โ โโโ fixtures.py # Anonymised real responses
โโโ docs/
โ โโโ rubric-classification.md # Why each of the 152 rubrics is open/closed
โโโ Dockerfile ยท compose.yaml # Hardened, non-root, read-only container
โโโ server.json # MCP registry manifest
Changelog
See CHANGELOG.md.
Contributing
See CONTRIBUTING.md. Changes to
src/amtsblatt_mcp/rubrics.py require an
explicit rationale in the PR description: releasing a rubric is a
data-protection decision, not a feature.
Security
See SECURITY.md for reporting and operator hardening notes.
License
MIT โ see LICENSE.
Data source: amtsblattportal.ch, operated by SECO / State Secretariat for Economic Affairs on behalf of the Swiss Confederation. Freely usable, but without warranty of completeness or accuracy. Only the signed PDF of a publication is legally binding.
Author
Hayal Oezkan ยท malkreide
Credits & Related Projects
Part of the Swiss Public Data MCP Portfolio:
register-mcpโ Zefix commercial register with a company-UID join to the gazettes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amtsblatt_mcp-0.1.1.tar.gz.
File metadata
- Download URL: amtsblatt_mcp-0.1.1.tar.gz
- Upload date:
- Size: 73.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68c06ed792350897feeab5eb92f5159ea02cf9d77112eb773c90d807377066f8
|
|
| MD5 |
46b6a445048d0f98e96ce11398d5377e
|
|
| BLAKE2b-256 |
caa49bb853d5e14e421f7f6bd5650afceb0ddec5d63aedd31b6e9604fe3daa7f
|
Provenance
The following attestation bundles were made for amtsblatt_mcp-0.1.1.tar.gz:
Publisher:
publish.yml on malkreide/amtsblatt-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
amtsblatt_mcp-0.1.1.tar.gz -
Subject digest:
68c06ed792350897feeab5eb92f5159ea02cf9d77112eb773c90d807377066f8 - Sigstore transparency entry: 2212252655
- Sigstore integration time:
-
Permalink:
malkreide/amtsblatt-mcp@dd8c8633861427b8e8557b3efe7506a75008a9f7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/malkreide
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd8c8633861427b8e8557b3efe7506a75008a9f7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file amtsblatt_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: amtsblatt_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4abaa11d38cf866d02a4c1d8911b81434ea79626600c785263740d444bb82582
|
|
| MD5 |
2a90c1806a0828869f0cb1058c9d4c03
|
|
| BLAKE2b-256 |
1ae681db6a958b155be463e98a5ea5dcdf46bfcde2eb884bc6e7705381b9f811
|
Provenance
The following attestation bundles were made for amtsblatt_mcp-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on malkreide/amtsblatt-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
amtsblatt_mcp-0.1.1-py3-none-any.whl -
Subject digest:
4abaa11d38cf866d02a4c1d8911b81434ea79626600c785263740d444bb82582 - Sigstore transparency entry: 2212252669
- Sigstore integration time:
-
Permalink:
malkreide/amtsblatt-mcp@dd8c8633861427b8e8557b3efe7506a75008a9f7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/malkreide
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dd8c8633861427b8e8557b3efe7506a75008a9f7 -
Trigger Event:
release
-
Statement type: