Canton and City of Zurich education data: schools, statistics, infrastructure
π¨π Part of the Swiss Public Data MCP Portfolio
MCP server for education statistics of the Canton and City of Zurich (BISTA)
zh-education-mcp connects AI assistants to the Bildungsstatistik Kanton ZΓΌrich (BISTA) β the official education statistics of the Canton of Zurich. It provides structured access to pupil numbers, school district trends, secondary school profiles, nationality breakdowns, and gymnasium graduation rates.
| Source | Data | API |
|---|---|---|
| BISTA Kanton ZΓΌrich | Learner statistics (Volksschule, Mittelschulen, MaturitΓ€t) | REST/CSV |
All data is fetched from the BISTA public API (bista.zh.ch/basicapi/ogd/) β no API key required. Data is updated annually on 15 September (reference date).
Anchor demo query: "How has the number of pupils in school district Letzi developed over the last 5 years?"
# Clone the repository
git clone https://github.com/malkreide/zh-education-mcp.git
cd zh-education-mcp
# Install
pip install -e .
# or with uv:
uv pip install -e .
Or with uvx (no permanent installation):
uvx zh-education-mcp
# stdio (for Claude Desktop)
python -m zh_education_mcp.server
# Streamable HTTP (port 8000)
python -m zh_education_mcp.server --http --port 8000
Try it immediately in Claude Desktop:
"Wie hat sich die Lernendenzahl im Schulkreis Letzi entwickelt?" "Zeige die MaturitΓ€tsquote der Stadt ZΓΌrich" "Welche NationalitΓ€ten sind in Adliswil am hΓ€ufigsten?"
β More use cases by audience β
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"zh-education": {
"command": "python",
"args": ["-m", "zh_education_mcp.server"]
}
}
}
Or with uvx:
{
"mcpServers": {
"zh-education": {
"command": "uvx",
"args": ["zh-education-mcp"]
}
}
}
Config file locations:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonFor use via claude.ai in the browser (e.g. on managed workstations without local software):
Render.com (recommended):
Dockerfile)MCP_TRANSPORT=streamable-http, MCP_HOST=0.0.0.0, MCP_PORT=8000, and MCP_CORS_ORIGINS=https://claude.aihttps://your-app.onrender.com/mcpπ‘ "stdio for the developer laptop, Streamable HTTP for the browser."
Health probe: GET /health. Full deployment guide (container, load balancing, CORS,
resource limits): docs/deployment.md.
| Tool | Description |
|---|---|
zh_edu_list_schulgemeinden | List all school communities / Schulkreise in Canton Zurich |
zh_edu_schulkreis_trend | Pupil trend by Schulkreis (2000βpresent) |
zh_edu_overview | Canton-wide learner overview by school level |
zh_edu_sek1_profil | Secondary I profile (Sek A/B/C breakdown) |
zh_edu_staatsangehoerigkeiten | Nationality structure of pupils per school community |
zh_edu_maturitaetsquote | Gymnasium graduation rates by municipality / district |
zh_edu_wohnort_trend | Residence-based learner trend (Bezirk / Gemeinde) |
zh_edu_mittelschulen | Secondary school statistics (Gymnasium, FMS, HMS) |
| Query | Tool |
|---|---|
| "List all Schulkreise in Zurich" | zh_edu_list_schulgemeinden |
| "Pupil trend in Letzi over 5 years" | zh_edu_schulkreis_trend |
| "How many Sek A vs Sek B in Winterthur?" | zh_edu_sek1_profil |
| "Top nationalities in ZΓΌrich-Letzi" | zh_edu_staatsangehoerigkeiten |
| "MaturitΓ€tsquote of Stadt ZΓΌrich" | zh_edu_maturitaetsquote |
βββββββββββββββββββ ββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ
β Claude / AI ββββββΆβ zh-education-mcp ββββββΆβ BISTA Kanton ZΓΌrich β
β (MCP Host) βββββββ (MCP Server) βββββββ REST/CSV (Public API) β
βββββββββββββββββββ β β ββββββββββββββββββββββββββββ
β 8 Tools β
β Stdio | Streamable HTTP β
β 24h Cache β
β No authentication required β
ββββββββββββββββββββββββββββββββ
| Source | Protocol | Coverage | Auth | Update |
|---|---|---|---|---|
| BISTA Kanton ZH | REST/CSV | Learner statistics 2000βpresent | None | Annual (15 Sep) |
zh-education-mcp/
βββ src/zh_education_mcp/
β βββ __init__.py # Package
β βββ config.py # ENV settings (MCP_*)
β βββ constants.py # API base, endpoints, timeouts
β βββ logging_setup.py # structured stderr logging
β βββ identity.py # server identity for `_meta` / `server/discover`
β βββ provenance.py # response envelope, license attribution
β βββ http_client.py # egress guard, connection pool, lifespan
β βββ data.py # cache, CSV fetch, filters, error handling
β βββ models.py # Pydantic input models
β βββ tools.py # FastMCP instance, 8 tools, 2 resources
β βββ server.py # thin composition layer + entrypoint
βββ tests/
β βββ test_server.py # Unit tests (mocked HTTP with respx)
βββ docs/ # deployment, security, egress, roadmap, β¦
βββ Dockerfile # multi-stage, non-root, healthcheck
βββ docker-compose.yml # resource limits, read-only rootfs
βββ .github/workflows/ci.yml # GitHub Actions (Python 3.11/3.12/3.13)
βββ .github/dependabot.yml # monthly dependency updates
βββ pyproject.toml
βββ CHANGELOG.md
βββ CONTRIBUTING.md # + CONTRIBUTING.de.md
βββ SECURITY.md # + SECURITY.de.md
βββ LICENSE
βββ README.md # This file (English)
βββ README.de.md # German version
zh_edu_list_schulgemeinden to find valid names).| Topic | Details |
|---|---|
| No personal data | BISTA statistics are aggregated β no individual pupil data is exposed or accessible. All figures are anonymized at the school community level. |
| Read-only | All tools are read-only (readOnlyHint: true). The server cannot modify, delete, or write any data. |
| No authentication | The BISTA API is fully public. No API keys, tokens, or credentials are stored or transmitted. |
| Rate limits | The BISTA API has no documented rate limit, but the server uses a 24h in-memory cache to minimize requests. Please use responsibly. |
| Data license | All data is published under CC BY 4.0 by the Canton of Zurich. Attribution: Bildungsstatistik Kanton ZΓΌrich (BISTA). |
| Terms of Service | Usage is subject to the BISTA terms of use. The MCP server is an independent open-source project and is not affiliated with the Canton of Zurich. |
| AI output disclaimer | Statistics are passed through as-is from the BISTA API. AI-generated interpretations or summaries should be verified against the official BISTA portal. |
# Unit tests (no API calls)
PYTHONPATH=src pytest tests/ -m "not live"
# Integration tests (live API calls)
pytest tests/ -m "live"
The live suite also runs on a schedule: every Monday 05:23 UTC, plus on
demand (live-tests.yml). A red run opens
an upstream-labelled issue; a green one closes it. -m "not live" is not a
place where tests run, and these three are the only tests here that can
contradict a wrong assumption about BISTA β see
CONTRIBUTING.
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 |
|---|---|---|
initialize handshake | 2024-11-05 β¦ 2025-11-25 | What 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 envelope | 2026-07-28 | A 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. The handshake ceiling is measured against a live initialize through
the assembled ASGI stack, not read off a constant name.
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.
Speaking the revision is the SDK's job. What a server has to supply is listed
here, and measured in
tests/test_modern_protocol.py against real
requests through the assembled ASGI stack rather than against constants:
What 2026-07-28 requires | How this server supplies it |
|---|---|
serverInfo stamp on every result (spec #3002) | Name, title, version, description and website β from the package metadata, see identity.py |
server/discover ("Servers MUST implement") | Answers with supportedVersions, capabilities and instructions |
instructions for the model | Reference date, suppressed small counts, attribution duty, read-only scope β deliberately the things no tool description carries |
resultType on every result | Set by the SDK, asserted here against the wire |
Envelope and header validation (Mcp-Method, Mcp-Name, Mcp-Protocol-Version) | A contradicting header is rejected with -32020, a missing envelope with -32602 |
| Freshness hints (SEP-2549) | Every cacheable listing method carries ttlMs 300,000 / cacheScope public; resources/read deliberately does not |
The identity is not maintained in src/: version, description and website
come from the distribution metadata and therefore from pyproject.toml β the
one source check_version_sync.py permits.
Before this revision the server stamped version: "" onto every modern-era
result.
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.
Project phase: Phase 1 β read-only (all tools readOnlyHint: true). See
docs/roadmap.md.
Publishing is driven by a GitHub release (release: published β
publish.yml): build β gate β PyPI β MCP Registry.
The gate (check_release_artifacts.py) runs
before the upload and inspects the built wheel, not the sources:
mcp-name: marker (an HTML comment, see the bottom of this file)
in the wheel METADATA β the MCP Registry proves PyPI ownership with it β and it
must match server.json nameserver.json description at most 100 characters; the Registry answers 422,
and only after the PyPI upload has already succeededserver.json version equal to pyproject.toml version, and the git tag equal
to the version actually builtIt sits ahead of the upload because nothing is correctable behind it: a PyPI version is immutable, so a fix costs a version bump.
If you edit this README: the marker at the very bottom is shipped as part of
the package description (readme = "README.md" in pyproject.toml), and removing
it fails the gate. README.de.md carries no marker and is not published. The
version badge above is checked on every pull request by
check_version_sync.py against pyproject.toml
and server.json.
See CHANGELOG.md
See CONTRIBUTING.md Β· π©πͺ Beitragen
See SECURITY.md Β· π©πͺ Sicherheit
MIT License β see LICENSE
Hayal Oezkan Β· malkreide
Run via uv's uvx β no clone or manual install needed. Add to your MCP client config (mcpServers for Claude Desktop, Cursor and Windsurf; use a top-level servers key for VS Code in .vscode/mcp.json):
{
"mcpServers": {
"zh-education-mcp": {
"command": "uvx",
"args": [
"zh-education-mcp"
]
}
}
}
Source-derived launch command. Check the maintainerβs required arguments and credentials before running:
uvx zh-education-mcpMerge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.
{
"mcpServers": {
"io-github-malkreide-zh-education-mcp": {
"command": "uvx",
"args": [
"zh-education-mcp"
]
}
}
}Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the clientβs tool list, then try a read-only example from its documentation.
Claude Desktop setup referencezh-education-mcppypiio.github.malkreide/zh-education-mcp works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.
~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.~/.cursor/mcp.jsonRestart Cursor for changes to take effect..vscode/mcp.jsonReload VS Code window for changes to take effect.~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect..mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.