MCP server for UK legislation (legislation.gov.uk) — search and fetch Acts and Statutory Instruments with persistent identifiers and verifiable citations.
Project description
gb-eli-mcp
An MCP server for legislation.gov.uk, The National Archives' official portal for United Kingdom legislation. It searches and retrieves Acts of Parliament, UK Statutory Instruments, and the equivalent instruments of the Scottish Parliament, Senedd Cymru/Welsh Parliament and Northern Ireland Assembly, with persistent identifiers and verifiable citations.
Part of the MateMatic eu-legal-mcp production line: the UK counterpart of the Polish
sejm-eli-mcp and the German de-eli-mcp, built on the same architecture and citation
contract against the UK's own source.
No native ELI. legislation.gov.uk does not publish a native
/eli/namespace (confirmed live:GET /eli/ukpga/2018/12returns 404), even though its own persistent-identifier scheme predates and is closely related to ELI - the UK is widely credited with pioneering the URI-based legislation-identifier concept that ELI later formalised EU-wide.eli_uritherefore carries the UK's own stable id URI (https://www.legislation.gov.uk/id/{type}/{year}/{number}) instead of a fabricated ELI path - the same disclosure pattern used by this factory'snl-eli-mcpandse-eli-mcp. SeeCONSTITUTION.mdArt. 4.Licence. Content is published under the Open Government Licence v3.0 (confirmed live from the site's own
/helppage), which permits copying, publishing and adapting with attribution. This connector only relays that public content, with asource_urlon every response.
The four tools
| Tool | What it does |
|---|---|
gb_search |
Search legislation by text, doc type and year (/all/data.feed or /{doc_type}/data.feed). |
gb_get_act |
Fetch act/instrument metadata by reference (e.g. ukpga/2018/12). |
gb_get_text |
Fetch the full text (xml, html, akn/Akoma Ntoso, rdf, pdf, csv). |
gb_recent_legislation |
Legislation published since a date, newest-first, optionally by doc type. |
Every response carries the contract: eli_uri
(e.g. https://www.legislation.gov.uk/id/ukpga/2018/12), human_readable_citation
(e.g. Data Protection Act 2018 c. 12), and source_url.
Install
cd gb-eli-mcp
pip install -e .
Configure (Claude Code / any MCP client)
Copy .mcp.json.example and adjust if needed:
{
"mcpServers": {
"gb-eli-mcp": { "command": "gb-eli-mcp" }
}
}
Environment:
GB_ELI_BASE_URL- defaulthttps://www.legislation.gov.ukGB_ELI_CACHE_DIR- default~/.matematic/cache/gb-eliGB_ELI_AUDIT_DIR- default~/.matematic/audit
No API key. legislation.gov.uk is keyless.
Governance
- Public data only - read-only against legislation.gov.uk; no client data leaves the machine beyond search parameters.
- Audit log - every tool call appends one JSON line to
~/.matematic/audit/gb-eli-mcp.jsonl. - Vendor-neutral - the server talks only to legislation.gov.uk and the local filesystem; no LLM provider, no telemetry.
- Verifiable citations - every response is independently checkable via
source_url.
See CONSTITUTION.md (the binding rules) and DISCOVERY.md (the live API probe).
Tests
pip install -e ".[dev]"
pytest tests/test_instructions_drift.py -v # offline
pytest tests/test_smoke.py -v # hits live legislation.gov.uk
Licence
Apache-2.0. (c) Matematic Solutions / Wieslaw Mazur.
Note: the code in this repository is Apache-2.0. The legislation content fetched at runtime from legislation.gov.uk remains Crown copyright, published under the Open Government Licence v3.0 - not relicensed by this project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gb_eli_mcp-0.1.0.tar.gz.
File metadata
- Download URL: gb_eli_mcp-0.1.0.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a8dce107eb60f3ae6ee4fd850938c37269ac1d42cc7cc1ef95f11ad97479259
|
|
| MD5 |
c1b4a9e28241cce8aef2012f9580780d
|
|
| BLAKE2b-256 |
5a579d52659c3d37aefe328efb0205f167e0ba5061d9b436a6d0199535dfd533
|
File details
Details for the file gb_eli_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gb_eli_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1787d5da3ca2ad0464b7b05a9460c641eff58c6b5e841d7dcc176017f60e8cd6
|
|
| MD5 |
03b6e3908af3a66117405f1f391da233
|
|
| BLAKE2b-256 |
89292c2c7f45b41119de48c771f76cbb524b611e4f48401be6f844cfb0fe8a60
|