Fedlex-mcp

by loicvuilliomenet-boop

Not rated
GitHub

About

Swiss Fedlex DB Browse Fedlex MCP Server for Claude, Cursor, VS Code, and other AI agents.

Details

Author
loicvuilliomenet-boop
Categories
Database, Other

Setup

Install Fedlex-mcp in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/loicvuilliomenet-boop/fedlex-mcp

Follow the installation instructions in the repository README, then restart your MCP client.

Provides two complementary layers of access:

- Live SPARQL tools— query the Fedlex SPARQL endpoint in real-time (no local setup beyondnpm run build)
- SQLite-backed tools— fast, offline-capable tools that work against a local database built bynpm run ingest

Experimental project. Not legal advice. Always verify against the official Fedlex source.

These queryhttps://fedlex.data.admin.ch/sparqlendpointdirectly and require no local database.

These work against a local SQLite database built bynpm run ingest. They are faster, work offline, and provide capabilities not available via SPARQL alone.

get_article_citationsis more precise thanget_citations: instead of "Law A cites Law B", it returns "Art. 12 of the Criminal Code cites Art. 3 of the Data Protection Act".

Every tool that takes anidentifieraccepts either:

- AnSR number— e.g."101"(Federal Constitution),"210"(Civil Code),"311.0"(Criminal Code),"220"(Code of Obligations)
- A fullELI URI— e.g."https://fedlex.data.admin.ch/eli/cc/1999/404"

All tools supportlanguage: "fr" | "de" | "it" | "rm"(default:"fr").

2. (Optional) Build the local SQLite database

Required for the SQLite-backed tools. Downloads and parses all HTML legislation from Fedlex (~7,000 laws, typically 15–30 minutes depending on connection):

You can also setFEDLEX_DB_PATHas an environment variable to point the server at an existing database.
- Fetches allConsolidationAbstractentries from SPARQL
- Resolves the latest consolidation and download URLs per law
- Fetches and parses HTML documents to extract article provisions
- Extracts legal definitions and EU cross-references per article
- Rebuilds the FTS5 full-text index
- Fetches article-level citation edges from SPARQL and stores them
- Writes a JSON summary report alongside the database file

Claude Desktop config(~/.claude/claude_desktop_config.json):

{ "mcpServers": { "fedlex": { "command": "node", "args": ["/path/to/fedlex-mcp/dist/index.js"] } } }

To use a pre-built database, addFEDLEX_DB_PATHto the env:

{ "mcpServers": { "fedlex": { "command": "node", "args": ["/path/to/fedlex-mcp/dist/index.js"], "env": { "FEDLEX_DB_PATH": "/path/to/fedlex.sqlite" } } } }
node dist/index.js --http # custom port: PORT=8080 node dist/index.js --http

- GET /sse— SSE stream for MCP clients
- POST /messages?sessionId=<id>— message relay

docker build -t fedlex-mcp . docker run -p 3000:3000 fedlex-mcp

Set the start command tonode dist/index.js --httpand expose port3000(or setPORTenv var).

All tools are also available as plain HTTP GET endpoints under/api/. Useful for browser clients or non-MCP integrations.

GET /api/search?q=<query>&lang=fr&limit=20&in_force=true GET /api/list?lang=fr&limit=50&offset=0&in_force=true GET /api/legislation/:id?lang=fr GET /api/text/:id?lang=fr&format=html&version=2024-01-01 GET /api/versions/:id GET /api/citations/:id?direction=both&lang=fr&limit=50
GET /api/db/search?q=<query>&limit=20&sr=235.1 GET /api/db/definitions?term=<term>&limit=20 GET /api/db/eu-refs?id=2016/679&type=Directive&limit=30 GET /api/db/article-citations?sr=311.0&article=art_1&direction=both&limit=50 GET /api/db/stats

Parameters for/api/db/article-citations:

search_legislation("protection des données") → finds LPD (SR 235.1) and related ordinances get_legislation("235.1") → metadata for the Loi fédérale sur la protection des données get_legislation_text("311.0", language="fr") → full text of the Code pénal suisse get_versions("220") → all historical versions of the Code des obligations get_citations("101", direction="from", language="fr") → all laws that cite the Constitution fédérale search_legislation("Datenschutz", language="de") → same search in German
search_provisions("données personnelles sensibles", sr_number="235.1") → FTS5 search within the LPD for that phrase lookup_definition("personne concernée") → all formal definitions of that term across Swiss federal law find_eu_references(eu_identifier="2016/679") → Swiss laws referencing the GDPR get_article_citations("311.0", article_id="art_12", direction="both") → articles that Art. 12 CP cites, and articles in other laws that cite Art. 12 CP get_db_stats() → total counts of laws, provisions, definitions, EU references, article citations

All data comes from the Swiss Federal Chancellery'sFedlex platformvia:

- SPARQL endpoint:https://fedlex.data.admin.ch/sparqlendpoint
- Ontology:
JOLux(based on FRBR, ELI)
- Formats available: PDF, HTML, XML (Akoma Ntoso, since 2022), DOCX
- Coverage: All Classified Compilation (RS/SR) texts — acts, ordinances, regulations, treaties

This project is an independent, experimental MCP server for accessing information derived from the Swiss Federal Chancellery's Fedlex platform. It is provided for technical and informational purposes only.

- No legal advice.Nothing produced by this project constitutes legal advice, legal opinion, or a substitute for professional counsel.
- No warranty.This software is provided"as is", without warranty of any kind. Outputs may be incomplete, inaccurate, unavailable, improperly parsed, or out of date.
- Verify with official sources.Users must independently verify all legal texts, references, metadata, and conclusions against the official Fedlex source before relying on them.
- Use at your own risk.The author assumes no responsibility or liability for errors, omissions, downtime, misinterpretation of legal materials, or any direct or indirect consequences arising from use of this project.
- Third-party source dependency.Availability and correctness depend in part on upstream Fedlex services, data formats, and network conditions, which may change without notice.

By using this project, you accept that it is a best-effort tool and not an authoritative legal system of record.

A Centralized MCP Server for Fetching Data from Many Countries' Govs

Free regulatory intelligence. Search 27,000+ government changes in ORCA format. No API key.

MCP server providing access to official records of activities of the Polish Parliament, including information on members, voting records, committees, and proceedings.

Query records of Korean independence activists from the Ministry of Patriots and Veterans Affairs.

Structured iGaming reference data — slot specs, RTP variants, providers, regulators, news and jobs.

Slingshot MCP introduces Slingshot Aerospace’s space data platform in your AI chat—explore satellites, orbits, and Portal insights through Slingshot’s hosted server.

Access and interact with Allen Institute for Neural Dynamics (AIND) metadata directly within your IDE.

A high-performance JavaScript server for the Alliance of Genome Resources (AGR) MCP.

Access the AlphaFold Protein Structure Database for protein structure prediction and analysis.

A modular server providing unified access to multiple astronomical datasets, including astroquery services and DESI data sources.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.