uk-legislation-mcp-server MCP Server
Search and read UK legislation at any date, resolve citations, list amendments, track changes.
uk-legislation-mcp-server scores 72 (Good), licensed Apache-2.0 and written in TypeScript. It can be reached as a remote MCP endpoint. It declares 7 tools. Filed under Search. GitHub shows 2 stars. Package registries report about 1,122 downloads a week. Install configs are generated for 12 clients. Being listed in the registry is not the same as being vendor-official.
Good trust
72 of 100 from six public signals. Nobody can buy a point.
- Listed in the official MCP registry.
- OSI-style license: apache-2.0.
License, quality and maintenance
Quality: Grade B
78/100 for listing completeness. Lost points: 6 of 7 tools barely described, short summary.
How quality is graded
Where the 72 comes from
22 + 20 + 6 + 10 + 4 + 10 = 72. Each factor is capped, so no single signal can carry a listing.
Active in the official MCP registry, plus a known vendor namespace.
Registry: 22 of 30 points.How recently the repository saw a commit or release.
Maintenance: 20 of 20 points.GitHub stars and weekly downloads, on a log scale.
Popularity: 6 of 20 points.A clear, OSI-style open-source license.
License: 10 of 10 points.Not archived, a secure install path, a pinned version.
Security: 4 of 10 points.A real summary, a README with depth, listed tools.
Docs: 10 of 10 points.Install
Pick your client, copy the config, paste it in.
Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.
{ "mcpServers": { "cyanheads-uk-legislation-mcp-server": { "command": "npx", "args": [ "-y", "@cyanheads/uk-legislation-mcp-server@0.2.3" ], "env": { "UK_LEGISLATION_CONTACT": "", "UK_LEGISLATION_MIN_REQUEST_GAP_MS": "1000", "UK_LEGISLATION_CACHE_MAX_MB": "64", "UK_LEGISLATION_CLAMP_LIMITS": "true", "UK_LEGISLATION_PROVISION_COMMAS": "true", "MCP_LOG_LEVEL": "info" } } }}
Environment variables
| Name | Required | Notes |
|---|---|---|
UK_LEGISLATION_CONTACT | Optional | Email or URL appended to the User-Agent so legislation.gov.uk can reach the operator. Optional; set it on hosted deployments. |
UK_LEGISLATION_MIN_REQUEST_GAP_MS | Optional | Minimum gap between legislation.gov.uk request starts, in ms (minimum 250). Replicas sharing one User-Agent divide the fair use limit: use at least 250 ms x replica count. |
UK_LEGISLATION_CACHE_MAX_MB | Optional | Response cache size bound, in MB (8-1024). |
UK_LEGISLATION_CLAMP_LIMITS | Optional | true serves a limit above a tool's cap at the cap, with a notice; false advertises each cap as the maximum and rejects a larger limit. |
UK_LEGISLATION_PROVISION_COMMAS | Optional | true rewrites comma-separated provision shorthand (Sch. 2, para. 3) to its path before validation; false rejects it. |
MCP_LOG_LEVEL | Optional | Sets the minimum log level for output (e.g., 'debug', 'info', 'warn'). |
MCP_TRANSPORT_TYPE | Optional | Selects the HTTP transport. |
MCP_HTTP_HOST | Optional | The hostname for the HTTP server. |
MCP_HTTP_PORT | Optional | The port to run the HTTP server on. |
MCP_HTTP_ENDPOINT_PATH | Optional | The endpoint path for the MCP server. |
MCP_AUTH_MODE | Optional | Authentication mode to use: 'none', 'jwt', or 'oauth'. |
UK_LEGISLATION_CONTACT | Optional | Email or URL appended to the User-Agent so legislation.gov.uk can reach the operator. Set it on hosted deployments. |
UK_LEGISLATION_MIN_REQUEST_GAP_MS | Optional | Minimum gap between legislation.gov.uk request starts, in ms (minimum 250). Replicas sharing one User-Agent divide the fair use limit: use at least 250 ms x replica count. |
UK_LEGISLATION_CACHE_MAX_MB | Optional | Response cache size bound, in MB (8-1024). |
UK_LEGISLATION_CLAMP_LIMITS | Optional | true serves a limit above a tool's cap at the cap, with a notice; false advertises each cap as the maximum and rejects a larger limit. |
UK_LEGISLATION_PROVISION_COMMAS | Optional | true rewrites comma-separated provision shorthand (Sch. 2, para. 3) to its path before validation; false rejects it. |
MCP_LOG_LEVEL | Optional | Sets the minimum log level for output (e.g., 'debug', 'info', 'warn'). |
Tools7Tool docs quality grade F
All capabilitiesctx.logtoollogging and ctx.fail with a declared reason for expected failures
<sub>tool</sub>
<sub>tool</sub>
<sub>tool</sub>
<sub>tool</sub>
<sub>tool</sub>
<sub>tool</sub>
About
Public Hosted Server: https://uk-legislation.caseyjhand.com/mcp
Overview
The UK statute book from legislation.gov.uk: primary, secondary, and EU-origin legislation for the UK, England, Scotland, Wales, and Northern Ireland. Resolve citations, search by text or title, read any provision as it stands today, as enacted, or on a past date, and track amendments. No API key required.
Tools
| Tool | Description |
|---|---|
uklaw_search_legislation | Search by full text or title, or list by type and year, filtered by extent and point in time |
uklaw_get_document | Read an item or provision as revised, as enacted or made, or on a date, with its editorial status, unapplied effects, dates and associated documents |
uklaw_get_amendments | List the effects (amendments, repeals, commencements, modifications) recorded against an item or made by it |
uklaw_track_changes | Read the legislation.gov.uk Publication Log for a window of up to 31 days |
uklaw_lookup_citation | Resolve a citation, short title, or legislation.gov.uk URI to the canonical item and provision |
uklaw_list_reference | Decode type codes, extents, version keywords, annotation letters, citation forms, and other vocabulary, offline |
Resources
| Resource | Description |
|---|---|
skill://uk-legislation-guide/SKILL.md | Agent Skill covering how to decide with the uklaw_* tools whether a provision is in force and current, its text on a date, what amended or commenced it, and what changed since a date |
The skill is served over MCP through the Agent Skills extension (io.modelcontextprotocol/skills, skill://{+path} template) and ships in skills/ in the npm package, the Docker image, and the .mcpb bundle. The tools do not depend on it.
Capability reference
uklaw_search_legislation tool
text(full text: AND/OR, "quoted phrases", stemming) and/ortitle(every word must occur), or neither to list by type and year;limitdefault 20, at most 1,000 (a larger value returns 1,000 with a notice), withpage- Filters:
types(codes such asukpga,uksi,eur, or the groupsall,primary,secondary,eu-origin,draft; defaultall, which excludes drafts),yearoryear_from/year_to(1267–2100),extent(england,wales,scotland,ni) withextent_match(applicableorexact), andas_of(YYYY-MM-DD);extentandas_ofcannot be combined - Each result carries the
itempath to pass touklaw_get_document;has_moreflags more results and the notice gives the call that continues;made_dateis kept as recorded, and the notice names results whose date falls outside the year in their item path; title searches and listings addfacets(type counts and the newest 25 years)
uklaw_get_document tool
itemis a full path (ukpga/2018/12,uksi/2019/419,eur/2016/679, regnalukpga/Eliz2/3-4/19) or a legislation.gov.uk URI;provisiona path (section/45/2/f,schedule/2/paragraph/3) or shorthand (s. 45(2)(f),Sch. 2 para. 3);versioncurrent(default),enacted(ormade,adopted,created), or aYYYY-MM-DDdate;languageenorcy- A provision held as a separate text per extent is read at one with an extent segment after the provision (
…/schedule/7/paragraph/15/ni, initemorprovision); a read without one returns the first text, with a notice naming the URI that reads each other one. A provision legislation.gov.uk serves at another path (article/14of an Act held assection/14) is read there, with a notice kindisfull(Markdowntextwith itsannotations),outline(provision paths to read next, 100 per call fromoutline_offset), orpdf_only(links.pdf); text over 20,000 characters, or an item with more than 25 leaf provisions, comes back as an outline (a provision with no smaller provisions to list is returned whole up to 40,000 characters and in chunks past that), andmatch_textlists an item's provisions that contain a termtext_offsetreads a provision's whole text in chunks of at most 40,000 characters, an outlined one included: 0, then each next offset the notice names; a chunk inside a table repeats its header rows, and each carries the annotations and footnotes it referenceseditorial(document_status,outstanding_effects,caveat) andunapplied_effects(the first 20, at item or provision level; a provision read also lists the effects on its enclosing provisions and, on full text, the provisions inside it, and says when it could not check them) show how far the revised text can be relied on;version.availablelists the versions to pass asversion- A provision read also returns
provision.enclosing: the Part, Chapter, cross-heading, Schedule and (for a sub-provision) the section above it, outermost first, each with itspath,labelandheadingas the version served gives them itemaddsmade_date(a notice says when it falls outside the year in the item path),laid([{ date, legislature }]) andcoming_into_force(on a draft, the date it proposes);associated_documentslists the explanatory notes or memorandum, policy note, correction slips, impact assessments and other documents legislation.gov.uk publishes with the item (kind,title,date,language,uri), andlinks.notesits notes page, all linked and never fetched;links.pdfis the PDF in the language served
uklaw_get_amendments tool
itemfull or partial (uksi,ukpga/2018);directionaffected(default: changes made to it) oraffecting(changes it makes); filterscounterpart(the other item, full or partial),status(all,unapplied,applied; defaultall), andprovision(needs a full item; scans up to 1,500 effects per call, matching effects that name the provision under another of the item's paths, such as a pre-1963 Act's regnal path)limitdefault 20, at most 500, continued withnext_cursor; each effect names both sides with their provisions,in_forcedates,applied/outstanding, andnotes;totalcounts effects before the provision filter (for a counterpart matched locally, the amended item's whole feed), andscanreports a scan's coverage- legislation.gov.uk cannot filter by an amending item dated 2001 or earlier: as
counterpartit is matched over the amended item's own feed, up to 1,500 effects per call, and withdirectionaffectingit needs acounterpart - Pre-1963 Acts are queried by calendar year (
ukpga/1925/20) and drafts are not indexed: both fail asregnal_item/draft_item, with the route to take instead
uklaw_track_changes tool
start_date(required) andend_date(defaults tostart_date), a window of at most 31 days; filterscontent_type(legislation,changes,draft,associated-documents),direction(withchangesonly),category(primary,secondary,eu-origin; withlegislationorassociated-documentsonly),item,new_only, andevent(published,withdrawn)limitdefault 40, at most 80, continued withnext_cursor;modeisday_walk(days newest first, up to 4 upstream requests per call) oritem_log(a fullitempath reads that item's own log and reportsread_back_to)- A
changesevent carries no effect detail:uklaw_get_amendmentson its item has it
uklaw_lookup_citation tool
- One
citationof up to 300 characters: a numbered citation, a short title, or a legislation.gov.uk URI, optionally with a provision (forms below) - Returns the canonical
itempath, plusprovision_foundfor a cited provision, checked against the current version; a miss or an ambiguous title isfound: falsewithguidanceor up to 20candidates, not an error
| Form | Examples | Resolves to |
|---|---|---|
| UK Act by chapter | 2018 c. 12 | ukpga/2018/12; before 1963 the calendar year is searched and the regnal candidates returned |
| Act of the Northern Ireland Assembly | 2016 c. 5 (N.I.) | nia/2016/5 |
| UK Statutory Instrument | S.I. 2019/419, SI 2019 No. 419, S.I. 2002/808 (W. 89) | uksi/2019/419; alternative series numbers are ignored, and Welsh and NI SIs canonicalize to wsi / nisi |
| Scottish Statutory Instrument | S.S.I. 2020/123 | ssi/2020/123 |
| Northern Ireland Statutory Rule | S.R. 2020/12, S.R. 2020 No. 12 | nisr/2020/12 |
| Scottish and Welsh Acts and Measures | 2020 asp 13, asp 2020/13, 2016 anaw 1, 2021 asc 1, 2010 nawm 1 | asp/2020/13, anaw/2016/1, asc/2021/1, mwa/2010/1 |
| EU-origin legislation | Regulation (EU) 2016/679, Regulation (EC) No 1535/2003, Directive 95/46/EC, Decision (EU) 2019/419; the issuing body may lead (Council Regulation (EC) No 1/2003) | eur/2016/679, eur/2003/1535 (pre-2015 numbering is number/year), eudr/1995/46, eudn/2019/419 |
| Defined name | UK GDPR | eur/2016/679 |
| legislation.gov.uk URI | https://www.legislation.gov.uk/ukpga/2018/12/section/45 | Split into item, provision, and version |
| Short title | Data Protection Act 2018, Human Rights Act 1998 (c. 42) | Resolved by title and year; a trailing chapter resolves the Act by number when the title does not, and one naming a different Act than the title leaves the citation unresolved, with both Acts as candidates |
Any form can end with a provision (s. 45(2)(f), section 45, reg. 5, art. 28(3), r. 7, r. 3.4, Sch. 2 para. 3, Sch. B1 para. 14, Pt 3, Pt XA, parts optionally separated by commas), start with one followed by "of" or "of the" (section 45 of the Data Protection Act 2018), or start with a Schedule followed by "to" or "to the" (Schedule 2 to the Data Protection Act 2018, paragraph 3 of Schedule 2 to the Data Protection Act 2018). uklaw_list_reference topic citation_formats returns the same list.
uklaw_list_reference tool
topic:types,type_groups,extents,versions,document_status,annotation_types,effects,provision_paths,citation_formats,publication_log,coverage, orattribution- Offline, with no request to legislation.gov.uk; each entry is a
key,label,description, and optionaldetails
skill://uk-legislation-guide/SKILL.md resource
- Markdown with YAML frontmatter: scope, identifier sources, the gates for in-force status, revised-text lag, container effects, dated reads, and date semantics, and workflows for commencement, point-in-time text, amendment history, and changes since a date
- Listed in
resources/list; theskill://{+path}template reads any file under it
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
legislation.gov.uk-specific:
- Keyless client for legislation.gov.uk's API: CLML XML for documents, Atom feeds for search, effects, and the Publication Log
- Follows legislation.gov.uk's fair use policy: an identifying User-Agent on every request, one process-wide queue that spaces request starts (1 second apart by default) and adopts a longer robots.txt crawl delay set for this server, up to 60 seconds, and at most 4 upstream requests per tool call within a 45-second deadline
- Process-wide response cache, with lifetimes taken from upstream
max-age(capped at one hour) andIf-Modified-Sincerevalidation; while legislation.gov.uk refuses requests, an expired copy is served and named in the result's notice - Citation shorthand (
s. 45(2)(f),reg. 5,Sch. 2 para. 3) normalized to provision paths; pre-1963 regnal paths and Welsh-language text (language: "cy") supported - PDF-only items are linked, never fetched, as legislation.gov.uk's robots.txt requires
Agent-friendly output:
- Every document read returns its editorial status with the text (
editorial.document_status,caveat,outstanding_effects) and theunapplied_effectstouching it, so the caller can tell when the revised text is behind on amendments uklaw_lookup_citationreturns a miss asfound: falsewithguidanceorcandidates, not as an error- Each tool's typed error reasons (
provision_not_found,version_not_found,regnal_item, …) carry a recovery hint naming the next call - Every response that returns legislation includes
attribution, the licence lines its content needs (see License) - Upstream text is treated as data: legislation text, annotations, and effect notes are blockquoted in
content[], inline values are escaped, and URIs are percent-encoded
Getting started
Connect to the hosted instance, no install:
claude mcp add --transport http uk-legislation-mcp-server https://uk-legislation.caseyjhand.com/mcp
Every caller of the hosted instance shares one request queue, paced at one legislation.gov.uk request per second under its fair use policy. For sustained use, run your own instance.
Or run it locally:
claude mcp add uk-legislation-mcp-server -- npx -y @cyanheads/uk-legislation-mcp-server
For other clients, add this to the MCP config file:
{
"mcpServers": {
"uk-legislation-mcp-server": {
"command": "npx",
"args": ["-y", "@cyanheads/uk-legislation-mcp-server"]
}
}
}
No API key or account is needed. The legislation.gov.uk fair use policy asks non-browser clients to identify themselves, so set UK_LEGISLATION_CONTACT to an email or URL when you run a shared deployment. For Docker or a source build, see Running the server.
Configuration
| Variable | Description | Default |
|---|---|---|
UK_LEGISLATION_CONTACT | Email or URL appended to the User-Agent so legislation.gov.uk can reach the operator. Set it on shared deployments. | none |
UK_LEGISLATION_MIN_REQUEST_GAP_MS | Minimum gap between upstream request starts, in ms, across the process; 250 at least. A longer robots.txt crawl delay for this server's User-Agent raises it. Replicas sharing one User-Agent divide the fair use limit, so use at least 250 ms × replica count. | 1000 |
UK_LEGISLATION_CACHE_MAX_MB | Response cache size bound, in MB (8–1024). | 64 |
UK_LEGISLATION_CLAMP_LIMITS | true serves a limit above a tool's cap at the cap, with a notice naming the requested and applied values; false advertises each cap as the schema maximum and rejects a larger limit. | true |
UK_LEGISLATION_PROVISION_COMMAS | true rewrites comma-separated provision shorthand such as Sch. 2, para. 3 to its path before validation, with an info log line per rewrite; false rejects it with invalid_arguments. | true |
MCP_TRANSPORT_TYPE | Transport: stdio or http. | stdio |
MCP_HTTP_PORT | HTTP server port. | 3010 |
MCP_HTTP_HOST | HTTP server host. | 127.0.0.1 |
MCP_SESSION_MODE | HTTP session mode: stateless, stateful, or auto. .env.example and the Docker image set stateless. | auto |
MCP_AUTH_MODE | Authentication: none, jwt, or oauth. | none |
MCP_LOG_LEVEL | Log level (debug, info, warning, error, etc.). | info |
LOGS_DIR | Directory for log files (Node.js only). A relative path resolves against the application root, which for an installed server is the server package's own directory. | <app-root>/logs |
OTEL_ENABLED | Enable OpenTelemetry. | false |
See .env.example for the full list of optional overrides.
Running the server
Local development
Requires Bun v1.4.4 or higher (or Node.js v24+).
-
Clone and install:
git clone https://github.com/cyanheads/uk-legislation-mcp-server.git cd uk-legislation-mcp-server && bun install cp .env.example .env # optionally set UK_LEGISLATION_CONTACT -
Build and run the production version:
# One-time build bun run rebuild # Run the built server bun run start:http # or bun run start:stdio -
Run checks and tests:
bun run devcheck # Lints, formats, type-checks, and more bun run test # Runs the test suite
Docker
docker run --rm -p 3010:3010 ghcr.io/cyanheads/uk-legislation-mcp-server:latest
The image defaults to HTTP transport, stateless session mode, and logs to /var/log/uk-legislation-mcp-server. To run it over stdio from an MCP client, use "command": "docker" with "args": ["run", "-i", "--rm", "-e", "MCP_TRANSPORT_TYPE=stdio", "ghcr.io/cyanheads/uk-legislation-mcp-server:latest"]. To build locally, docker build -t uk-legislation-mcp-server .; OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
| Directory | Purpose |
|---|---|
src/index.ts | createApp() entry point: registers the six tools; setup() reads robots.txt and builds the pacer, response cache, client, and service. |
src/config | Server-specific environment variable parsing and validation with Zod. |
skills/ | The published uk-legislation-guide Agent Skill, served as an MCP resource via createApp({ skills: 'skills' }). |
src/mcp-server/tools/definitions | Tool definitions (*.tool.ts), plus the shared input/output schemas and Markdown rendering helpers. |
src/services/legislation | legislation.gov.uk service layer: HTTP client, response cache, citation and provision-path parsing, CLML and Atom parsers, reference data, attribution. |
tests/ | Unit tests mirroring src/, run against recorded CLML and Atom fixtures. |
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor logging andctx.failwith a declared reason for expected failures - Register new tools in
allToolDefinitionsinsrc/mcp-server/tools/definitions/index.ts - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run test
License
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
Legislation content from legislation.gov.uk is © Crown and database right, licensed under the Open Government Licence v3.0. EU-origin items also carry a European Union credit (© European Union, 1998-2020, re-used under Commission Decision 2011/833/EU), and pre-1987 statutory instruments contributed to legislation.gov.uk by Westlaw UK carry a Westlaw credit. Every tool that returns legislation lists the lines that apply to its content in attribution.
Frequently asked questions
What is uk-legislation-mcp-server MCP Server?
Search and read UK legislation at any date, resolve citations, list amendments, track changes.
How do I install uk-legislation-mcp-server MCP Server in Claude Desktop, Cursor, or VS Code?
Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. uk-legislation-mcp-server MCP Server runs locally from the npm package @cyanheads/uk-legislation-mcp-server with the command npx -y @cyanheads/uk-legislation-mcp-server@0.2.3.
Is uk-legislation-mcp-server MCP Server free and open source?
Yes. uk-legislation-mcp-server MCP Server is released under the Apache-2.0 license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.
Does uk-legislation-mcp-server MCP Server support remote (HTTP) connections?
Yes. uk-legislation-mcp-server MCP Server offers a hosted endpoint over Streamable HTTP, so HTTP-capable clients can connect to it without running anything locally.
What tools does uk-legislation-mcp-server MCP Server provide?
uk-legislation-mcp-server MCP Server provides 7 tools, including ctx.log, uklaw_get_amendments, uklaw_get_document, and uklaw_list_reference. See the full tool list for descriptions and parameters.
How is uk-legislation-mcp-server MCP Server's trust score calculated?
uk-legislation-mcp-server MCP Server scores 72 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.
Reviews
No reviews yet—Be the first to review
No published reviews yet. Used it? Tell the next person how it went.
Sign inA verified email is required to review this server.
Add badge to your README
Paste either snippet into the repository README. The image links to this listing.