MCP server for the [legislation.gov.uk](https://www.legislation.gov.uk) API: search, retrieve, and summarise UK legislation with full jurisdiction, status, and amendment tracking.
  • TypeScript 99.4%
  • JavaScript 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ric Harvey 4eccf18734
Add tests for new parser features to meet 85% branch coverage
Cover Pblock/P1group unwrapping, UnorderedList/ListItem extraction,
standalone Para elements, dc:title lowercase handling, DocumentClassification
nesting, ContentsPblock, SecondaryMetadata, and additional status branches.

176 tests, 86.43% branch coverage (threshold: 85%).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:45:48 +00:00
.forgejo/workflows Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00
src Fix CLML parser for real API structure (v1.0.2) 2026-03-26 18:39:08 +00:00
tests Add tests for new parser features to meet 85% branch coverage 2026-03-26 18:45:48 +00:00
.eslintrc.json Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00
.gitignore Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00
CHANGELOG.md Fix CLML parser for real API structure (v1.0.2) 2026-03-26 18:39:08 +00:00
LICENSE Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00
package-lock.json Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00
package.json Fix CLML parser for real API structure (v1.0.2) 2026-03-26 18:39:08 +00:00
README.md Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00
tsconfig.json Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00
vitest.config.ts Initial release: 13 MCP tools for legislation.gov.uk API 2026-03-26 17:46:36 +00:00

legislation-gov-uk-mcp

An MCP server that wraps the legislation.gov.uk API, letting AI agents search, retrieve, and summarise UK legislation. It tracks jurisdiction, enforcement status, and amendment history, and always links back to the original source.

Warning

Community Project, Not Official This is an independent, community-maintained project. It is not affiliated with, endorsed by, or officially supported by the UK Government, The National Archives, or legislation.gov.uk. It uses the publicly available legislation.gov.uk API under their reuse licence. Always verify information against the official legislation.gov.uk website.

Features

  • 13 tools across 6 resource areas: search, legislation content, changes/effects, metadata, publication log, and SPARQL
  • Labels every result with its jurisdiction (UK, England, Wales, Scotland, Northern Ireland)
  • Shows whether legislation is In Force, Repealed, Not Yet In Force, Revoked, or Partially In Force
  • Tracks amendments, repeals, and commencements with their application status
  • Supports point-in-time retrieval so you can see what the law said on any given date
  • Every response includes the legislation.gov.uk URL so users can check the original
  • Generates proper legal citations (e.g. "Equality Act 2010 (c.15)")
  • Passes instructions to AI agents on connection so they cite and reference correctly
  • No API key needed. Just install and go.

Installation

npm install -g legislation-gov-uk-mcp

Claude Desktop Quick Start

Add the legislation-gov-uk entry to the mcpServers object in your Claude Desktop config file. If you already have other servers configured, add it alongside them. Don't replace what's already there:

{
  "mcpServers": {
    "your-existing-server": {
      "...": "keep your existing servers here"
    },
    "legislation-gov-uk": {
      "command": "npx",
      "args": ["-y", "legislation-gov-uk-mcp"]
    }
  },
  "preferences": {
    "...": "keep your existing preferences here"
  }
}

Auto-approve tools

If you'd like to skip confirmation prompts for the read-only tools, add an autoApprove array:

{
  "mcpServers": {
    "your-existing-server": {
      "...": "keep your existing servers here"
    },
    "legislation-gov-uk": {
      "command": "npx",
      "args": ["-y", "legislation-gov-uk-mcp"],
      "autoApprove": [
        "leg_search",
        "leg_search_advanced",
        "leg_search_new",
        "leg_get",
        "leg_get_section",
        "leg_get_version",
        "leg_get_contents",
        "leg_changes_affecting",
        "leg_changes_by",
        "leg_status",
        "leg_types",
        "leg_updates",
        "leg_sparql"
      ]
    }
  },
  "preferences": {
    "...": "keep your existing preferences here"
  }
}

Config file locations

Platform Path
macOS ~/Library/Application Support/Claude/claude_desktop_config.json
Windows %APPDATA%\Claude\claude_desktop_config.json
Linux ~/.config/Claude/claude_desktop_config.json

Tools

Search (3 tools)

Tool Description
leg_search Search legislation by title or text content, with type, year, and jurisdiction filters
leg_search_advanced Full search with boolean operators, year/number ranges, extent matching, and sort options
leg_search_new Get newly published or recently updated legislation

Legislation Content (4 tools)

Tool Description
leg_get Fetch a legislation item by type/year/number, including metadata and table of contents
leg_get_section Fetch a specific section or part with its content text
leg_get_version Fetch legislation as it stood on a given date (point-in-time)
leg_get_contents Fetch the table of contents structure for a piece of legislation

Changes & Effects (2 tools)

Tool Description
leg_changes_affecting List amendments, repeals, and commencements that affect a piece of legislation
leg_changes_by List changes that a piece of legislation makes to other legislation

Metadata (2 tools)

Tool Description
leg_status Check status (in force, repealed, etc.), pending amendments, jurisdiction, and extent
leg_types List all legislation type codes with descriptions and jurisdictions

Publication Log (1 tool)

Tool Description
leg_updates Get recent publications and updates from the legislation.gov.uk publication log

SPARQL (1 tool)

Tool Description
leg_sparql Run SPARQL queries against the legislation.gov.uk linked data endpoint

Legislation Type Codes

Code Description Jurisdiction
ukpga UK Public General Acts UK
uksi UK Statutory Instruments UK
asp Acts of the Scottish Parliament Scotland
ssi Scottish Statutory Instruments Scotland
asc Acts of Senedd Cymru Wales
anaw Acts of the National Assembly for Wales Wales
wsi Welsh Statutory Instruments Wales
nia Northern Ireland Assembly Acts Northern Ireland
nisr Northern Ireland Statutory Rules Northern Ireland

Run leg_types for the full list.

Rate Limits

The legislation.gov.uk API allows 3,000 requests per 5 minutes per IP address. No API key is needed. The server sends a User-Agent header as required by the API.

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Lint
npm run lint

# Start the server
npm start

License

MIT