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.
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.
MCP tools
Five ways to interrogate a corpus.
search_lawsStemmed full-text search over titles and article text. Ranked hits with snippets.
get_actMetadata, in-force status, source, and articles — always with the as-of date.
get_articleA single article of an act, by number.
list_amendmentsWhat this act amends, is amended by, or repeals.
find_relatedWhat this act cites or consolidates — the reference web.
one country / instanceEach 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.
Country-agnostic by design — 11 more jurisdictions are scaffolded (importer + golden tests), with prebuilt datasets rolling out on Releases:
Principles
Built to be trusted with the law.
Honest by date
Every answer carries the as-of date and in-force status. A legal tool that hides staleness is harmful.
Official sources only
Open-data exports under their stated licenses — never scraped where robots forbid it.
Morphology-aware
Per-language stemming so inflected queries find the right text — not brittle exact-string match.
Links are first-class
Amendments, repeals and citations are graph edges, queryable with SPARQL — not buried in prose.
Prebuilt & local
Download a ready dataset from Releases, or build your own. Runs on your machine; your data.
Open
Apache-2.0. No gatekeeper between you and your country's law. New-country scrapers welcome.