Swiss court decisions and statutes wired as LLM tools via OpenCaseLaw
beniauer added a grounding layer for Swiss legal questions: five LLM tool calls that hit the OpenCaseLaw public API instead of relying on model recall, with explicit instructions in the system prompt to never invent BGE docket numbers or SR statute references. Worth a look if you have any Swiss-law use case.
backend/src/lib/swissCaselaw.ts is a thin REST client for mcp.opencaselaw.ch/api (base URL overridable via OPENCASELAW_BASE_URL). It covers three sources: ~956k court decisions across federal and cantonal courts, statutes from Fedlex and 26 cantonal collections, and OnlineKommentar.ch commentaries. No auth required. Each call uses a 15-second abort timeout; error handling is defensive but there's no retry.
Five tool definitions land in chatTools.ts: search_swiss_caselaw, read_swiss_decision, search_swiss_laws, read_swiss_law, search_swiss_commentaries. search_swiss_caselaw supports FTS5 syntax - keywords, quoted phrases, AND/OR/NOT, prefix wildcards - and filters on court code, canton, language, date range, chamber, and decision type. Both search and fetch return citation_string_de/fr/it and canonical_url for inline citation.
The system prompt gains a SWISS LAW LOOKUP section that instructs the model to prefer these tools over training-data recall for any Swiss question, to quote citation_string and canonical_url verbatim, and to report no-result rather than fabricating. The <CITATIONS> block stays reserved for user-attached documents; OpenCaseLaw quotes go inline.
The frontend adds a /caselaw search page with three tabs (decisions, laws, commentaries) and a normalized caselawRouter on the backend. One split to be aware of: the /caselaw Express route isn't mounted in index.ts until a separate commit in the rebrand topic, so pulling this commit alone gives you the chat tools but not the standalone search page backend.
Spotted something wrong? Or know the PR text has fresher detail than the writeup above?