{"id":50520382,"url":"https://github.com/tggo/lex","last_synced_at":"2026-06-03T03:31:29.083Z","repository":{"id":360635767,"uuid":"1251025489","full_name":"tggo/lex","owner":"tggo","description":"Open legislation as an MCP knowledge graph — search and traverse a country's laws \u0026 bylaws from Claude Code. RDF/ELI + SPARQL + FTS. Ukraine first; country-agnostic.","archived":false,"fork":false,"pushed_at":"2026-05-27T09:04:28.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-27T09:13:27.383Z","etag":null,"topics":["claude-code","golang","knowledge-graph","law","legal-tech","legislation","mcp","model-context-protocol","open-data","rdf","sparql","ukraine"],"latest_commit_sha":null,"homepage":"https://tggo.github.io/lex/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tggo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-27T07:14:00.000Z","updated_at":"2026-05-27T09:04:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tggo/lex","commit_stats":null,"previous_names":["tggo/lex"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tggo/lex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tggo%2Flex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tggo%2Flex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tggo%2Flex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tggo%2Flex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tggo","download_url":"https://codeload.github.com/tggo/lex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tggo%2Flex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33847264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude-code","golang","knowledge-graph","law","legal-tech","legislation","mcp","model-context-protocol","open-data","rdf","sparql","ukraine"],"created_at":"2026-06-03T03:31:28.280Z","updated_at":"2026-06-03T03:31:29.078Z","avatar_url":"https://github.com/tggo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lex\n\n**Open legislation as an MCP knowledge graph.**\n\n`lex` is an open-source [MCP](https://modelcontextprotocol.io) server that puts\na country's laws and subordinate legislation at the fingertips of MCP clients\n(Claude Code, Claude Desktop, …) — searchable, retrievable, and linked as a\ngraph (which act amends, repeals, or cites which).\n\nEach country lives in its own directory (`./ua` for Ukraine first; `./jp`,\n`./uk`, `./us`… later). A country directory ships Go scrapers that pull the\nofficial legal source and emit RDF; the shared `lex` server indexes that RDF\nand serves it over MCP. The goal: anyone, anywhere, can run the laws of their\nown country locally and query them with an AI assistant.\n\n## Status\n\n🚧 Early design / scaffolding. See [`docs/prd`](docs/prd) for the vision and\n[`docs/adr`](docs/adr) for architecture decisions.\n\n## How it works\n\n```\nofficial source ──scraper (Go, per country)──▶ RDF (ELI ontology)\n                                                   │\n                                                   ▼\n                                      goRDFlib + Badger triplestore\n                                       + decoupled search index (FTS5)\n                                                   │\n                                                   ▼\n                                          lex MCP server  ◀── Claude Code\n```\n\n- **Storage / linking**: RDF triplestore via\n  [`goRDFlib`](https://github.com/tggo/goRDFlib) (Badger backend), modelled with\n  the [ELI](https://eur-lex.europa.eu/eli) vocabulary so amendments, repeals, and\n  citations are first-class graph edges queryable with SPARQL.\n- **Search**: a decoupled sibling index (SQLite FTS5 to start) over act titles\n  and article text.\n- **Distribution**: build the database yourself with the scrapers, or download\n  a prebuilt one from GitHub Releases.\n\n## Quick start\n\nThe fastest path — **don't scrape anything**. `lex` downloads a prebuilt\ndataset (graph + full-text index) from GitHub Releases on first run:\n\n```bash\ngo build -o lex ./cmd/lex\n./lex -data ua/data        # no local dataset → pulls lex-ua.tar.gz from Releases\n```\n\nOr build the dataset yourself from the official source (a dataset is a\ndirectory: `graph/` Badger + `index.fts` full text):\n\n```bash\ngo run ./ua/scripts/import -out ua/data                       # titles only\ngo run ./ua/scripts/import -out ua/data -articles -relations  # + article text + edges\n./lex -data ua/data                                            # serve it\n```\n\nFetched act bodies are cached under `ua/.cache` (keyed by version), so\nre-imports skip the network. Pass `-no-pull` to `lex` to never download.\n\nThen register `lex` as a stdio MCP server in your client (e.g. Claude Code).\nIt exposes:\n\n- `search_laws(query, limit)` — full-text search; returns hits with an `act_uri`.\n- `get_act(uri)` — metadata (title, **as-of date**, in-force status, source) + articles.\n- `get_article(act_uri, number)` — a single article.\n- `list_amendments(uri)` — `amends` / `amended_by` / `repeals`.\n- `find_related(uri)` — `cites` / `consolidates`.\n\n## Add your country\n\nWrite a scraper under `./\u003ccc\u003e/scripts` that emits RDF conforming to\n[`docs/ontology.md`](docs/ontology.md). That is the entire integration — the\nserver is country-agnostic. PRs welcome.\n\n## Legal note\n\nLegislative texts of Ukraine are not objects of copyright, and the source data\nis published as **open data under CC BY 4.0**. `lex` redistributes texts with\nattribution to the official source (`data.rada.gov.ua` / Verkhovna Rada for\nUkraine). We use official open-data exports, not website scraping. See each\ncountry's README.\n\n## License\n\nApache-2.0 (code). Legislative texts retain their public-domain / official\nstatus from the source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftggo%2Flex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftggo%2Flex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftggo%2Flex/lists"}