Skip to main content
Glama

Fedlex MCP Server — Swiss Federal Law for Claude

An MCP server that gives Claude access to Swiss federal law via the Fedlex platform.

What it does

The server exposes 5 tools:

Tool

What it does

Data source

search_laws

Find laws by keyword in their title

SPARQL → metadata

get_law_metadata

Get detailed info about a specific law

SPARQL → metadata

get_law_text

Fetch the actual text (or a specific article)

SPARQL → URL → HTTP fetch HTML

list_amendments

Show version history of a law

SPARQL → metadata

browse_taxonomy

Navigate the SR classification tree

SPARQL → vocabulary

How the Fedlex API works (the two layers)

┌─────────────────────────────────────────────────────────────┐
│  Layer 1: SPARQL endpoint                                    │
│  https://fedlex.data.admin.ch/sparqlendpoint                 │
│                                                              │
│  Contains: METADATA                                          │
│  - Which laws exist (ConsolidationAbstract)                  │
│  - Titles, SR numbers, dates, taxonomy                       │
│  - Links between acts (amendments, basic acts)               │
│  - Version history (Consolidation entries)                   │
│  - FRBR chain → URLs to actual documents                     │
│                                                              │
│  Does NOT contain: the actual law text                        │
└──────────────────────┬──────────────────────────────────────┘
                       │ follow URL from metadata
                       ▼
┌─────────────────────────────────────────────────────────────┐
│  Layer 2: Document files                                     │
│  https://www.fedlex.admin.ch/eli/cc/...                      │
│                                                              │
│  Contains: ACTUAL TEXT                                        │
│  - HTML, PDF, XML (Akoma Ntoso) versions                     │
│  - The real law content                                      │
└─────────────────────────────────────────────────────────────┘

The search_laws and get_law_metadata tools only use Layer 1. The get_law_text tool uses both: first SPARQL to find the URL, then HTTP to fetch the text.

Related MCP server: Swiss Case Law Open Dataset MCP

Setup

1. Install dependencies

cd fedlex-mcp
pip install -r requirements.txt

2. Test it works

python -c "
from fedlex_client import search_laws
results = search_laws('Raumplanung')
for r in results:
    print(f\"{r['title']} — {r['url']}\")
"

3. Add to Claude Desktop

Edit your claude_desktop_config.json:

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

{
  "mcpServers": {
    "fedlex": {
      "command": "python3",
      "args": ["/ABSOLUTE/PATH/TO/fedlex-mcp/server.py"]
    }
  }
}

Replace /ABSOLUTE/PATH/TO/ with the actual path on your machine.

Restart Claude Desktop. You should see the Fedlex tools in the connector menu.

4. (Optional) Run as remote server for Cowork

If you want to share this with your team or use it via Cowork as a remote connector:

python server.py --transport sse

Then add the URL (e.g. http://localhost:8000/sse) in Claude Desktop under Settings → Connectors → Add custom connector.

Note: For remote/Cowork, you'll want to deploy this behind HTTPS (e.g. on Cloud Run, Fly.io, or a simple VPS with nginx + Let's Encrypt).

Example conversations

Once connected, you can ask Claude things like:

  • "Welche Gesetze gibt es zur Raumplanung?"

  • "Was sagt Art. 22 des Raumplanungsgesetzes?"

  • "Wann wurde das Umweltschutzgesetz zuletzt geändert?"

  • "Zeig mir die SR-Klassifikation für Baurecht"

  • "What does the Swiss federal constitution say about property rights?"

Architecture

Claude ←→ MCP Protocol ←→ server.py ←→ fedlex_client.py
                                            │
                                            ├→ SPARQL queries → fedlex.data.admin.ch
                                            └→ HTTP fetch     → www.fedlex.admin.ch

The MCP server (server.py) defines the tools. The client (fedlex_client.py) handles the actual SPARQL queries and HTML fetching. This separation makes it easy to test the client independently or reuse it in other contexts.

Data model (JOLux ontology)

The SPARQL data follows the JOLux ontology with FRBR abstraction levels:

ConsolidationAbstract  (= a law in the SR, e.g. "RPG")
    │
    ├── Expression (title in DE/FR/IT/EN)
    │
    └── Consolidation (= a specific version at a point in time)
            │
            ├── Expression (text in DE/FR/IT/EN)
            │       │
            │       └── Manifestation (HTML / PDF / XML format)
            │               │
            │               └── URL (the actual file)
            │
            └── dateApplicability (when this version applies)

Full documentation: https://swiss.github.io/fedlex-jolux/

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables LLMs to search and analyze Swiss case law, legislation, and citation networks with 43 tools for decision search, statute lookup, citation graphs, legislative history, and exam question generation.
      81
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      A connector that gives Claude direct access to the official text of Swiss federal legislation on Fedlex, covering all acts in the Classified Compilation in German, French, and Italian.
      4
      8
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Provides read-only access to Swiss legislation and multi-tier court decisions, enabling searches, full-text retrieval as Markdown, court hierarchy listing, and statutory or case-law citation verification across official registries.
      6
      MIT