lex.

open · self-hosted · model context protocol · 12 jurisdictions

The law,
as a graph
you can ask.

lex is an open-source MCP server that puts a country's laws and subordinate legislation at the fingertips of an AI assistant — searchable in plain language, retrievable with its as-of date, and linked as a knowledge graph. Runs locally. Ukraine is live; the architecture is country-agnostic across 12 jurisdictions.

Ask in plain language

Real questions, the exact article.

Morphology-aware full-text search over the actual article text — not just titles. These are real results from the Ukrainian corpus (2,941 acts), asked in the nominative; the stemmer matches every inflection.

як оформити спадщину
Цивільний кодекс України — Глава 89. Оформлення права на спадщину eli/ua/kodeks/2003/435-15 · as of 2026-01 · in force
кримінальна відповідальність
Кримінальний кодекс України — ст. 3. Законодавство про кримінальну відповідальність eli/ua/kodeks/2001/2341-14
реєстрація шлюбу
Закон про державну реєстрацію актів цивільного стану — ст. 14. Державна реєстрація шлюбу "шлюбу" matched "шлюб" — case & number folded
оренда землі
Закон «Про оренду землі» — ст. 33, переважне право орендаря "оренда землі" → indexed "оренду землі"

How it works

Ingestion is separated from serving.

Each country ships Go scrapers that pull its official open data and emit RDF in a shared ELI ontology. One country-agnostic server indexes that graph and answers over MCP. Adding a country is writing a scraper — the server never changes.

Official open datazakon.rada, e-Gov, Sejm, BOE, Finlex, Legifrance…
Scraper → RDFELI / FRBR triples, per country
Graph + indexBadger · SPARQL · FTS5 + per-language stemmer
lex serverMCP tools → Claude Code

MCP tools

Five ways to interrogate a corpus.

search_laws

Stemmed full-text search over titles and article text. Ranked hits with snippets.

get_act

Metadata, in-force status, source, and articles — always with the as-of date.

get_article

A single article of an act, by number.

list_amendments

What this act amends, is amended by, or repeals.

find_related

What this act cites or consolidates — the reference web.

one country / instance

Each dataset is one jurisdiction, so answers are never silently mixed.

Quick start

Don't scrape anything.

First run downloads a prebuilt dataset (graph + full-text index) from GitHub Releases. No account, no cloud, no re-scraping.

# pull a prebuilt dataset and serve it over MCP
go build -o lex ./cmd/lex
./lex -data ua/data
# → downloads lex-ua.tar.gz, then: serving country "ua" (search lang "uk")

# or build it yourself from the official source:
go run ./ua/scripts/import -out ua/data -articles -relations

# then register `lex` as a stdio MCP server in Claude Code and ask:
"What does Article 1 of the Civil Code say, and is it in force?"

Coverage

Ukraine first. The world next.

🇺🇦 Ukrainezakon.rada · CC BY 4.0 · articles + amend/repeal/cite edges live · 2941 acts

Country-agnostic by design — 11 more jurisdictions are scaffolded (importer + golden tests), with prebuilt datasets rolling out on Releases:

🇯🇵
Japan
🇵🇱
Poland
🇬🇧
UK
🇺🇸
USA
🇫🇷
France
🇪🇸
Spain
🇮🇪
Ireland
🇨🇭
Switzerland
🇫🇮
Finland
🇱🇺
Luxembourg
🇦🇺
Australia
yours

Principles

Built to be trusted with the law.

01

Honest by date

Every answer carries the as-of date and in-force status. A legal tool that hides staleness is harmful.

02

Official sources only

Open-data exports under their stated licenses — never scraped where robots forbid it.

03

Morphology-aware

Per-language stemming so inflected queries find the right text — not brittle exact-string match.

04

Links are first-class

Amendments, repeals and citations are graph edges, queryable with SPARQL — not buried in prose.

05

Prebuilt & local

Download a ready dataset from Releases, or build your own. Runs on your machine; your data.

06

Open

Apache-2.0. No gatekeeper between you and your country's law. New-country scrapers welcome.