Look up · Federal + cantonal

Swiss federal and cantonal legislation

5,000+ Swiss federal laws (~133,468 articles in three official languages, full amendment history) from the Fedlex SPARQL endpoint, mirrored locally each month. 15,722 cantonal and intercantonal acts locally mirrored from LexFind, monthly refresh. Stateless MCP calls for article lookup, full-text search, version history and amendments.

§01 Federal

Federal laws — Fedlex SPARQL mirror

The Fedlex SPARQL endpoint (fedlex.data.admin.ch/sparqlendpoint) is queried monthly and the ~5,500 federal laws are mirrored locally as a SQLite FTS5 index. Article lookups run in under 1 ms, full-text search uses BM25 ranking.

~5'000federal laws
125'000+articles
3official languages (DE/FR/IT)
<1 msarticle lookup

Covered abbreviations (excerpt):

ORZGBStGBStPOZPOBV SchKGBGGDBGIPRGAIGBVG KVGAsylGBGFAATSGDSGUVG AHVGIVGAVIGStHGMWSTGGSchG

Full list available via search_laws.

Article lookup

get_law(abbreviation="OR", article="41", language="de")

Returns Art. 41 CO (non-contractual liability) with paragraphs, cross-references and metadata from the local FTS5 index. The language parameter accepts de, fr, it.

§02 Cantonal

Cantonal acts — direct portal mirror + LexFind fallback

Cantonal legislation comes from two layers. Primary: 22 cantons are scraped directly from their official Gesetzessammlungen — via the LexWork and SIL platforms the cantons themselves operate. Content is parsed as native HTML (no PDF extraction, no OCR), producing clean article-level data. Fallback: for the remaining 4 cantons — JU, SZ, UR, VD — (and any act not in the direct mirror), OpenCaseLaw extracts PDFs from lexfind.ch with PyMuPDF. Both feed cantonal_laws.db (15’722 acts / 353’437 articles), federated via SQLite FTS5 with the federal statute table.

15’722acts
22 + 4directly mirrored + LexFind fallback
DE/FR/ITincl. bilingual cantons
monthlyrefreshed

For queries against acts not yet in the local mirror — e.g. versions published between two refresh cycles — the MCP tools transparently fall back to the live LexFind API and persist the response (SQLite cache, tiered TTLs: search 24 h, SR resolution 30 d, full text 7 d). The search_legislation tool also uses the LexFind catalog (33’000+ texts including ordinances and intercantonal agreements).

Full-text search (federated)

search_laws(query="Mietrecht", canton="ZH")

search_laws queries the local mirror at both the federal and cantonal level and interleaves the hits. Without a canton filter, federal and cantonal matches are returned in alternation; with a filter, the search is restricted to that scope.

Cantonal article lookup

get_law(canton="ZH", sr_number="554.5", article="1")

Returns Art. 1 of the Zurich dog act from cantonal_laws.db. The canton parameter accepts all 26 canton codes (ZH, BE, LU, …, GE, JU).

Natural-language query in a single call

search_legislation(query="Hundegesetz", canton="BE", fetch_top_n_texts=2)

With fetch_top_n_texts=N, the top N results are enriched inline with full text and segmented articles — LLMs can answer questions like "What does the Bernese dog act say about keeping bans?" in a single tool call.

§03 Changes

Recent changes

For each jurisdiction, the most recent legislative changes can be queried — new acts, revisions and repeals with date, type and link to the official publication.

browse_legislation_changes

browse_legislation_changes(canton="CH")

§04 Background

Technical background

Fedlex exposes two machine-readable interfaces: a SPARQL endpoint (RDF, ELI URIs) and XML downloads of individual acts. Both require substantial preparation before a query like "Art. 41 CO in German" becomes possible. The local mirror materialises ~5,500 federal laws (~133,468 articles) in an FTS5 table over (law, article, language), bringing article lookups down to sub-millisecond latency.

LexFind provides a JSON API for live discovery across all 26 cantonal collections plus the federal one (33,000+ texts including ordinances and intercantonal agreements). OpenCaseLaw uses LexFind in two roles: (1) as a PDF fallback source for the 4 cantons (JU, SZ, UR, VD) whose portals we do not yet scrape directly — the PDFs are extracted with PyMuPDF and segmented into articles; (2) as a discovery catalog for the search_legislation tool family. For the other 22 cantons we go directly to the official portals (LexWork + SIL).

The citation graph stores 11.3M references to statute articles; every reference can be resolved against the current consolidated text. A decision that cites Art. 12 LSLaw leads via get_law("BGFA", article="12") directly to the article in all three official languages.