Skip to content

UK Legislation MCP Server

A local MCP server providing real-time access to UK statute data from legislation.gov.uk.

Overview

PropertyValue
Sourcelegislation.gov.uk (Open Government Licence v3.0)
API keyNot required
Transportstdio (runs as a local process)
Locationmcp-servers/uk-legislation/src/index.ts
Cache24-hour in-memory, 500-entry LRU
Fetch timeout30 seconds

Running the Server

bash
cd mcp-servers/uk-legislation
npm install
npm run dev     # start the server (tsx src/index.ts)

For production builds:

bash
npm run build   # compiles to dist/
npm test        # build + run tests

Automatic Startup

When configured in .mcp.json, Claude Code starts the server automatically when a skill needs it. You do not need to start it manually.

Tools

The server exposes 6 tools:

1. search_legislation

Search UK legislation by title keywords.

ParameterTypeRequiredDescription
titlestringYesSearch keywords for the legislation title
typestringNoFilter by legislation type (e.g., ukpga, uksi)
yearnumberNoFilter by year

Returns: Up to 20 results, each with title, type, year, number, and URI.

Example: search_legislation("Companies Act", type="ukpga")

2. lookup_statute

Get full metadata and text of a specific Act or Statutory Instrument.

ParameterTypeRequiredDescription
typestringYesLegislation type (e.g., ukpga, uksi)
yearnumberYesYear of the legislation (1200-2100)
numbernumberYesNumber within that year

Returns: Title, enacted date, extent, parts count, provisions count, and full text.

Example: lookup_statute(type="ukpga", year=2006, number=46)
         → Companies Act 2006

3. lookup_section

Get a specific section of an Act, including amendment notes.

ParameterTypeRequiredDescription
typestringYesLegislation type
yearnumberYesYear
numbernumberYesNumber
sectionstringYesSection number (e.g., "1", "10A")

Returns: Section text and commentary references (amendment notes with ID, type, and description).

Example: lookup_section(type="ukpga", year=2006, number=46, section="172")
         → Companies Act 2006, s.172 — Duty to promote the success of the company

4. check_in_force

Check whether a statute or specific provision is currently in force.

ParameterTypeRequiredDescription
typestringYesLegislation type
yearnumberYesYear
numbernumberYesNumber
sectionstringNoSpecific section to check

Returns: Status per provision, categorised as:

  • In Force -- provision is currently active, with commencement date
  • Not Yet In Force -- provision has a future commencement date
  • Prospective -- provision is enacted but awaiting commencement order
  • Repealed -- provision has been repealed

Commencement Complexity

Some Acts commence in stages over years. If no explicit commencement data is found in the XML, the tool recommends checking the Act's commencement section or related Commencement Orders (SIs).

5. check_amendments

Get amendments affecting a specific statute from the legislation.gov.uk changes feed.

ParameterTypeRequiredDescription
typestringYesLegislation type
yearnumberYesYear
numbernumberYesNumber

Returns: Up to 30 amendments, each with:

  • Amending instrument (the SI or Act that made the change)
  • Affected provision (the specific section amended)
  • Effect type (e.g., substituted, inserted, repealed)
  • Date of the amendment
Example: check_amendments(type="ukpga", year=1998, number=42)
         → Amendments affecting the Human Rights Act 1998

6. get_extent

Check the territorial extent of UK legislation -- which jurisdictions it applies to.

ParameterTypeRequiredDescription
typestringYesLegislation type
yearnumberYesYear
numbernumberYesNumber

Returns: Overall extent and provision-level breakdown with decoded extent codes:

CodeJurisdiction
E+W+S+N.I.England, Wales, Scotland, Northern Ireland (UK-wide)
E+W+SEngland, Wales, Scotland (Great Britain)
E+WEngland and Wales
EEngland only
WWales only
SScotland only
N.I.Northern Ireland only

Legislation Types

The server supports 15 legislation types:

CodeDescription
ukpgaUK Public General Acts
uksiUK Statutory Instruments
aspActs of the Scottish Parliament
ascActs of Senedd Cymru
anawActs of the National Assembly for Wales
mwaMeasures of the National Assembly for Wales
niaNorthern Ireland Acts
nisiNorthern Ireland Orders in Council
nisrNorthern Ireland Statutory Rules
ssiScottish Statutory Instruments
wsiWales Statutory Instruments
uklaUK Local Acts
ukcmUK Church Measures
ukciUK Church Instruments
uksroUK Statutory Rules and Orders

Caching

The server maintains a 24-hour in-memory cache to reduce load on legislation.gov.uk and improve response times.

PropertyValue
TTL24 hours
Max entries500
EvictionLRU (oldest entry removed when full)
ScopePer server process (resets on restart)

Cache Behaviour

Cache hits are logged to stderr as [uk-legislation] Cache hit: <url>. On a fresh start, the first request for each statute will be slower (network fetch), but subsequent requests within 24 hours return instantly.

Error Handling

ScenarioBehaviour
Statute not foundReturns Error: Not found: <url>
Network timeoutReturns Error: Request timed out after 30s: <url>
HTTP errorReturns Error: HTTP <status> fetching <url>
Amendments feed unavailableReturns helpful message suggesting the changes feed may not be available for that item

AI Legal UK · The Counsel — Established MMXXVI · Built for England & Wales · Not legal advice.