Part of the Swiss Public Data MCP Portfolio — a collection of open-source MCP servers connecting AI agents to Swiss public and open data. This is a private project. It is not affiliated with, endorsed by, or operated on behalf of any employer or public authority.
lindas-mcp
MCP server for LINDAS — the linked-data knowledge graph of the Swiss administration.
What LINDAS is
LINDAS (Linked Data Service) is the Swiss Confederation's SPARQL knowledge graph, run by the Federal Archives. Instead of tables, it publishes data as RDF triples: around 2000 statistical data cubes (cube.link) from federal offices, plus the geo-linked data that powers visualize.admin.ch.
Mnemonic: «I14Y is the library catalogue, LINDAS is the library itself.» i14y-mcp tells you a dataset exists. LINDAS holds the data and lets you query across all of it at once.
This server wraps LINDAS in guarded tools rather than exposing raw SPARQL, because the store rewards precise queries and times out on broad ones.
🎯 Anchor Demo Query
«Which forest-fire danger level currently applies, who publishes it, and under which licence?»
search_cubes(query="waldbrand")
→ «Waldbrandgefahr» — BAFU, published
get_cube_structure(cube_uri=...)
→ dimensions: Warnregion (key), Gefahrenstufe (measure)
→ licence: fedlex.data.admin.ch/eli/cc/1984/... (a Fedlex URI!)
query_cube_observations(cube_uri=...)
→ Warnregion: "Dorneck / Thierstein (SO)", Gefahrenstufe: "grosse Gefahr"
The codes come back as labels — «grosse Gefahr», not 4. And the licence is a
Fedlex URI you can resolve with fedlex-mcp.
Demo
The two-phase access pattern
LINDAS cubes are self-describing but coded, and the server does two steps to read them:
- Structure — the cube's SHACL shape: its dimensions (filterable axes), its measures (the numbers), and which dimensions carry code lists.
- Data — the observations, with coded values resolved to human labels using that structure.
Mnemonic: «LINDAS speaks in postcodes, not place names.» An observation says region
1805; the server turns that into «Alpennordhang» for you.
Both steps happen inside query_cube_observations. It fetches the
structure itself, so a caller does not have to call get_cube_structure
first to get readable rows — doing so only repeats the cube-metadata and
dimension queries. get_cube_structure is the tool for finding out what a
cube contains (dimension names, key vs. measure, licence) and for writing a
run_sparql query against it. It reports only whether a dimension has a code
list, not the entries, so it is not a decoding aid either.
Architecture
┌──────────────────────────────┐
│ MCP Host (Claude) │
└───────────────┬──────────────┘
│ stdio | streamable-http
┌───────────────▼──────────────┐
│ lindas-mcp │
│ ┌────────────────────────┐ │
│ │ server.py (7 tools) │ │ talks only to cube.py
│ ├────────────────────────┤ │
│ │ lindas/cube.py │ │ ← vocabulary guardrail,
│ │ │ │ two-phase access,
│ │ │ │ code→label resolution
│ ├────────────────────────┤ │
│ │ lindas/queries.py │ │ SPARQL templates,
│ │ │ │ all anchored on a class
│ ├────────────────────────┤ │
│ │ lindas/client.py │ │ raw SPARQL over HTTP,
│ │ │ │ knows nothing of cubes
│ └────────────────────────┘ │
└───────────────┬──────────────┘
│ HTTPS, no auth
┌───────────────▼──────────────┐
│ lindas.admin.ch/query │
│ SPARQL 1.1 · ~2000 cubes │
└──────────────────────────────┘
The lindas/ package is deliberately layered so it can be lifted into other
LINDAS-backed servers unchanged. client.py knows only HTTP and SPARQL;
cube.py knows the cube.link vocabulary; the tools know only cube.py. Raw
SPARQL never reaches the agent except through the guarded run_sparql escape
hatch.
Architecture decision
Architecture A (live SPARQL only), with a strict vocabulary guardrail.
Verified live on 2026-07-21:
- The endpoint is stable, needs no authentication, and returns a clean HTTP 400 with a diagnostic on malformed queries.
- Blind scans (
SELECT *,COUNT(*)over the whole store) time out at 60–90 s; the same question anchored on?x a cube:Cubeanswers in ~2 s.
Consequences, baked into the tools:
- Every query template is anchored on a known class. No unbounded scans.
- Two-phase access is enforced; the agent never sees raw codes.
run_sparqlis capped at 500 rows and 30 s and marked as advanced.- The client timeout sits at 45 s, in front of the store's own 60–90 s abort.
Full probe report: docs/probe-lindas.md.
Tools
| Tool | Purpose |
|---|---|
search_cubes |
Find cubes by topic. Entry point. Deduplicates versions. |
get_cube_structure |
Phase 1: dimensions, measures, licence. |
query_cube_observations |
Phase 2: data points with codes resolved to labels. |
list_publishers |
Federal bodies publishing cubes, with counts. |
resolve_municipality |
Name ↔ URI ↔ BFS number — the portfolio join key. |
run_sparql |
Advanced escape hatch. Capped, guarded. |
api_status |
Reachability check with cube count. |
All tools are annotated readOnlyHint: true.
Installation
uvx lindas-mcp
Claude Desktop
{
"mcpServers": {
"lindas": {
"command": "uvx",
"args": ["lindas-mcp"]
}
}
}
Remote deployment
LINDAS_MCP_TRANSPORT=sse PORT=8000 lindas-mcp
LINDAS_MCP_TRANSPORT accepts stdio (default), sse or streamable-http.
The SSE / streamable-http transport binds to HOST, default 127.0.0.1;
set HOST=0.0.0.0 explicitly to expose it (only behind a reverse proxy). For a
hosted HTTP deployment, set ALLOWED_ORIGINS to a comma-separated list of
browser origins — unset means no browser client is permitted at all, which
is the default. * is still accepted and logs a warning. LOG_LEVEL tunes the
JSON stderr logs.
Docker
docker compose up --build # binds 0.0.0.0 inside the container, publishes :8000
The image runs as a non-root user, read-only, with resource limits and a
TCP health check (see Dockerfile and compose.yaml).
Join keys
LINDAS is a connector layer, and two of its identifiers make it composable with the rest of the portfolio:
| Key | Where | Joins to |
|---|---|---|
| BFS commune number | resolve_municipality → bfs_number |
swiss-statistics-mcp, zurich-opendata-mcp |
| Fedlex URI | cube licence field |
fedlex-mcp |
The Fedlex link is the quiet surprise: many cubes declare their licence as a
legal-basis URI (fedlex.data.admin.ch/eli/cc/...), so you can go from a data
point straight to the law that governs it.
Known limitations
Verified live on 2026-07-21.
- Broad SPARQL times out. The store aborts unanchored scans at 60–90 s.
The guarded tools avoid this;
run_sparqlwarns about it and caps runtime. - Observations are coded. Dimension values are URIs, not labels. The server
resolves them via each dimension's code list, but resolution costs one extra
query per coded dimension. Set
resolve_labels=Falseto skip it. - No server-side observation filtering by arbitrary value. LINDAS has no
cheap way to filter observations by a dimension value inside a cube, so
query_cube_observationsreads the first N observations. Analytical slicing belongs inrun_sparql. - Licences vary per cube and are declared as
dcterms:license, frequently a Fedlex URI rather than a plain name. Always surface thelicencefield. - Version handling is heuristic.
search_cubesdeduplicates by stripping the version suffix from the cube URI and keeping the highestschema:versionamong published cubes. Unusual URI shapes may not collapse cleanly; uselatest_only=Falseto inspect every version.
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 |
|---|---|---|
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.
What 2026-07-28 changes here
The modern era has no initialize handshake, and therefore no handshake result
in which a client learns who it is talking to. Three consequences are served
explicitly rather than left at the SDK's defaults:
| Surface | Behaviour |
|---|---|
serverInfo |
Stamped into _meta on every response and into server/discover. Name, title, version, description and website URL are resolved from the installed distribution's metadata, never written by hand. MCPServer defaults version to "" and substitutes nothing, so an unset version is a required field that says nothing. |
instructions |
Returned by server/discover — the only orientation channel a modern client has. It names the entry point, says that query_cube_observations resolves labels on its own, and says what get_cube_structure is actually for. |
| Log delivery | logging/setLevel is gone (SEP-2577); a client opts in per request via the reserved _meta key io.modelcontextprotocol/logLevel. Without it the server sends nothing; with debug it sends one notifications/message per tool call on that request's stream. |
tools/list, server/discover |
Carry ttlMs 300000 and cacheScope public (SEP-2549). |
All of it is measured through the assembled stack in
tests/test_spec_2026_07_28.py — both eras,
both transports, and both branches of the log opt-in. The tool contract itself
is guarded independently by tool-definitions.lock.json (SEC-022), and the
modern era is asserted to serve exactly the tools listed there, so the two eras
cannot drift into two different servers behind one address.
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. SDK upgrades are a reviewed change for
the same reason: any protocol-affecting bump is called out in
CHANGELOG.md.
Testing
PYTHONPATH=src pytest tests/ -m "not live" # offline, used in CI
PYTHONPATH=src pytest tests/ -m "live" # hits the real endpoint
python -m ruff check src tests
The live tests earn their place: the observationSet indirection (a cube's
observations hang off cube:observationSet, never directly off the cube) is a
structural assumption that a mock cannot validate. It is covered by a live test.
Contributing
See CONTRIBUTING.md for the ground rules (read-only, one
egress host, anchored queries) and the local dev loop. Further reading:
EXAMPLES.md for use cases by audience with the tool-selection
table, docs/roadmap.md for the project phase, and
PUBLISHING.md for the PyPI / MCP Registry release process.
Security
See SECURITY.md for the security posture and how to report a
vulnerability.
License
MIT License — see LICENSE. The LINDAS data remains subject to the licence each publisher declares on the cube.
Author
Hayal Oezkan · github.com/malkreide
Credits & related projects
- Data: LINDAS Linked Data Service, Swiss Federal Archives
- Vocabulary: cube.link
- Visualisation frontend on the same cubes: visualize.admin.ch
- Source discovery inspired by rnckp/awesome-ogd-switzerland
- Portfolio: swiss-public-data-mcp
Licence: MIT. The cube data remains subject to the licence each publisher declares.
MCP Registry
Ownership marker used by the MCP Registry to link this PyPI package to the GitHub namespace:
mcp-name: io.github.malkreide/lindas-mcp
Metadata
Release files for lindas-mcp 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lindas_mcp-0.3.0.tar.gz | 156.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lindas_mcp-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 192.4 kB
Release files / lindas_mcp-0.3.0.tar.gz
| Download URL | lindas_mcp-0.3.0.tar.gz |
|---|---|
| Size | 156.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
719264487607448b6fb0eef663352c7349b134de84acc135181c47d6b08f5e78
|
|
BLAKE2b-256 checksum How to use checksums |
e63065afdae1e8d8d813dda3260c7c33796ff239e6e819058f01adc25c23c643
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency logRelease files / lindas_mcp-0.3.0-py3-none-any.whl
| Download URL | lindas_mcp-0.3.0-py3-none-any.whl |
|---|---|
| Size | 35.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d3818f63ba7392e22283a04549fc0825bad497223a4498fb84a854bec812936
|
|
BLAKE2b-256 checksum How to use checksums |
ec4336eee5a9b811844bc173e124bbcb19a357935bbcca2f46dd8dd081428704
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.
Transparency log