Skip to main content
Glama
legislation.gov.uk MCP Server

legislation.gov.uk MCP Server

by legislation

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
PORTNoHTTP server port when using HTTP transport.3000
AWS_REGIONNoAWS region for the Data API client.eu-west-2
MCP_TRANSPORTNoCommunication transport. Options are stdio or http.stdio
DUTIES_DB_NAMENoDatabase name for the powers-and-duties database.duties
MCP_SERVER_KEYNoOptional bearer token. If set, clients must send Authorization: Bearer <key> on the /mcp endpoint.
SEMANTIC_API_KEYNoAPI key for semantic search authentication.
DUTIES_DB_SECRET_ARNNoARN of the Secrets Manager secret holding the powers-and-duties database credentials. Required together with DUTIES_DB_CLUSTER_ARN to enable the powers-and-duties tools.
DUTIES_DB_CLUSTER_ARNNoARN of the Aurora cluster for the powers-and-duties database. Required together with DUTIES_DB_SECRET_ARN to enable the powers-and-duties tools.
RESEARCH_API_BASE_URLNoBase URL for the Research API.https://research.legislation.gov.uk
RESEARCH_API_PASSWORDNoBasic-auth password for the Research API. Required together with RESEARCH_API_USERNAME to enable the advanced search tools.
RESEARCH_API_USERNAMENoBasic-auth username for the Research API. Required together with RESEARCH_API_PASSWORD to enable the advanced search tools.
SEMANTIC_API_BASE_URLNoBase URL for the semantic search API. Setting this enables the semantic search tools.http://localhost:8000

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server publishes no instructions, or was last inspected before Glama recorded them.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{}
resources
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
search_legislationA

Search for UK legislation by keyword, title, or other criteria on legislation.gov.uk. Returns JSON by default (set format="xml" for raw Atom feed).

Results include: id, type, year, number, title, and date. Use q for full-text keyword search, title for title search. Filter by type, year, startYear/endYear range, subject, department, extent, or language. Use sort to order results. Returns 20 results per page — use page to paginate; check meta.morePages in the response.

subject only applies to SI-family types (uksi, ssi, wsi, nisr, etc.); Acts don't carry subject metadata. If subject is set without a type, secondary is used by default.

See: types://guide, json://search-response, atom://feed-guide

get_legislation_metadataA

Retrieve structured metadata for a UK legislation document or a specific fragment (Part, Chapter, section, etc.). More efficient than fetching the full document when you only need metadata.

type, year, and number must be exact — use search_legislation to confirm if unsure.

Returns JSON with: id, type, year, number, title, status (draft/final/revised/proposed), extent (e.g. ["E","W","S","NI"]), key dates (enactmentDate/madeDate), version (label of the returned representation), pointInTime (requested date, when present), versions (available milestone version labels), and unappliedEffects (amendments enacted but not yet applied to the text).

prospective is true when the response contains provisions not yet in force; version says whether the returned version is itself the prospective one. The field is never false, and it is absent on enacted/made text. A whole document requested without a version holds no provision text, so there its absence doesn't mean there are no prospective provisions.

unappliedEffects and upToDate are only present for the latest version (no version parameter). When a specific version is requested, both fields are omitted — effects are not tracked for point-in-time snapshots. For the latest version, upToDate is true when all in-force effects have been applied, false when some are outstanding.

Fragment: pass a fragment to scope metadata to a specific provision (e.g. "section/12", "part/2/chapter/1"). unappliedEffects and upToDate are scoped to the fragment for both revised and enacted/made legislation. Use get_legislation_table_of_contents to discover valid fragment IDs.

Version: use a date (YYYY-MM-DD) for a point-in-time snapshot, or enacted/made/created/adopted for the original version. The returned version field labels the version returned (for fragments, it may be earlier than the requested pointInTime). The versions field may also contain the label prospective; that label identifies the prospective version, which is fetched by omitting version rather than by passing it.

For response field details, see json://metadata-response. For legislation type codes, see types://guide. For checking geographical extent, see cookbook://check-extent. For retrieving historical versions, see cookbook://point-in-time-version. For determining whether legislation is up to date and which amendments have yet to be applied, see cookbook://check-outstanding-effects.

get_legislationA

Retrieve a full UK legislation document by type, year, and number. Returns readable plain text by default (text). Also available: xml (CLML with full metadata), akn (Akoma Ntoso), html.

Text is best for reading and summarisation. It discards semantic markup, amendment commentaries, and structural metadata — use xml to track amendments, follow cross-references, or check in-force status.

For large documents, use get_legislation_table_of_contents first, then get_legislation_fragment for specific sections.

Common types: ukpga (Acts), uksi (SIs), asp (Scottish Acts), asc (Welsh Acts), nia (NI Acts). type, year, and number must be exact — use search_legislation to confirm if unsure.

Version: use a date (YYYY-MM-DD) for a point-in-time snapshot, or enacted/made/created/adopted for the original version. Do not pass version="prospective"; when metadata lists "prospective", that is the latest version and should be fetched by omitting the version parameter.

See: types://guide, cookbook://point-in-time-version, text://format-guide

get_legislation_fragmentA

Retrieve a fragment (section, part, chapter, etc.) of a UK legislation document. Returns readable plain text by default (text). Also available: xml (CLML with full metadata), akn (Akoma Ntoso), html.

Text is best for reading and summarisation. It discards semantic markup, amendment commentaries, and structural metadata — use xml to track amendments, follow cross-references, or check in-force status.

type, year, and number must be exact — use search_legislation to confirm if unsure. Use get_legislation_table_of_contents to discover fragment IDs. Common fragmentId patterns: section/1, part/2, part/1/chapter/3, regulation/5, crossheading/name. The API does not support fragment IDs deeper than the section or regulation level (e.g. section/1/a is not a valid ID).

Version: use a date (YYYY-MM-DD) for a point-in-time snapshot, or enacted/made/created/adopted for the original version. Do not pass version="prospective"; when metadata lists "prospective", that is the latest fragment version and should be fetched by omitting the version parameter.

See: types://guide, cookbook://point-in-time-version

get_legislation_table_of_contentsA

Retrieve the table of contents for a UK legislation document. Returns structured JSON by default (json). Also available: xml, akn, html.

Shows the hierarchical structure (Parts, Chapters, Sections) with headings and fragment IDs for use with get_legislation_fragment.

meta.prospective is true when the response indicates that the document contains provisions not yet in force. It is left out on enacted/made text. Contents entries are marked inconsistently, so its absence doesn't mean there are no prospective provisions.

type, year, and number must be exact. If you're not certain, use search_legislation to confirm — identifiers guessed from general knowledge are often wrong.

Version: use a date (YYYY-MM-DD) for a point-in-time snapshot, or enacted/made/created/adopted for the original version. Do not pass version="prospective"; when metadata lists "prospective", that is the latest version and should be fetched by omitting the version parameter.

See: types://guide, cookbook://point-in-time-version, json://table-of-contents-response

search_effectsA

Search for legislative effects (amendments, repeals, insertions, etc.) by source and/or target legislation.

Use source parameters to find effects made BY a piece of legislation (e.g. "what did Act X amend?"). Use target parameters to find effects made TO a piece of legislation (e.g. "what amends Act Y?"). You can combine both to find specific effects between two pieces of legislation.

For step-by-step examples, see cookbook://search-effects. For legislation type codes, see types://guide.

get_resourceA

Fetch a resource by URI. For agents that cannot access MCP resources directly, use this tool to retrieve guides, reference material, and documentation.

Available resources:

  • guide://getting-started — Overview and quick start

  • guide://troubleshooting — Common errors and edge cases

  • cookbook://index — Index of all cookbook recipes

  • cookbook://check-extent — How to check geographical extent

  • cookbook://point-in-time-version — How to retrieve historical versions

  • cookbook://semantic-search-workflow — Semantic search step-by-step (needs the semantic search backend)

  • types://guide — All UK legislation type codes (ukpga, uksi, etc.)

  • types://data — Type codes as JSON

  • years://regnal — Regnal year identifiers for pre-1963 legislation

  • text://format-guide — Plain text output format documentation

  • clml://schema-guide — CLML XML structure reference

  • clml://metadata/extent — Geographical extent in CLML

  • atom://feed-guide — Atom feed format for search results

  • json://search-response — search_legislation response format

  • json://metadata-response — get_legislation_metadata response format

  • json://table-of-contents-response — get_legislation_table_of_contents response format

  • json://semantic-search-response — search_legislation_semantic response format

  • json://semantic-section-response — search_legislation_sections_semantic response format

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription
Advanced Query SyntaxComplete reference for the query language used by `search_legislation_advanced` and `count_legislation_advanced`. Pass queries as the `query` parameter.
Atom Feed Guide for legislation.gov.ukThe search results from legislation.gov.uk are returned in **Atom feed format** (XML), which is a standard syndication format with custom extensions for legislative metadata.
Geographical Extent in CLMLUnderstanding restrictExtent attributes and territorial application of UK legislation
CLML Schema GuideCLML (Crown Legislation Markup Language) is the XML format used by legislation.gov.uk to represent UK legislation.
Check Geographical Extent**Question:** "Does the Fire Safety Act 2021 apply to Scotland?"
Check Outstanding Effects**Question:** "Is the Equality Act 2010 up to date, and if not, what amendments are outstanding?"
Find the Most Recent SI on a Subject**Question:** "What's the most recent Statutory Instrument about [topic]?"
Cookbook IndexStep-by-step recipes for common tasks with UK legislation data.
Point‑in‑Time Retrieval (Versioning)**Question:** "Show me this Act as it stood on a specific date."
Search Legislative Effects**Question:** "What does the Automated Vehicles Act 2024 amend?" or "What amends the Equality Act 2010?"
Semantic Search Workflow**Requires the semantic search backend.** Step-by-step guide for using semantic search to find relevant legislation. The recipe below calls `search_legislation_semantic` and `search_legislation_sectio...
Getting Started with UK LegislationThis MCP server provides tools and resources for working with UK legislation from legislation.gov.uk. Use `get_resource` to fetch any resource by URI — see its tool description for the full list.
Troubleshooting Common IssuesSolutions to common errors and edge cases when working with UK legislation data.
Advanced Search Response FormatsJSON formats for `search_legislation_advanced` and `count_legislation_advanced` tool responses.
Metadata Response FormatJSON format for `get_legislation_metadata` tool responses.
Search Response FormatJSON format for `search_legislation` tool responses.
Semantic Search Response FormatResponse format for `search_legislation_semantic` tool.
Semantic Section Search Response FormatResponse format for `search_legislation_sections_semantic` tool.
Table of Contents Response FormatJSON format for `get_legislation_table_of_contents` tool responses.
Text Format GuideThe default output format for `get_legislation` and `get_legislation_fragment`. Converted from CLML XML into a readable, markdown-inspired plain text format designed for AI consumption.
UK Legislation Types (JSON)Machine-readable list of all UK legislation type codes with short codes, long names, and categories. Use types://guide for the human-readable reference.
UK Legislation Types ReferenceUK legislation comes in many different types, each with a **short code** (used in URLs) and a **long name** (used in metadata and Atom feeds).
Regnal Years Reference DataCSV mapping of regnal year identifiers (e.g. Vict/50) to reign, year of reign, and calendar date ranges. Pre-1963 legislation is canonically identified by regnal year, though calendar years usually work too via API redirect. Use regnal years to disambiguate when a calendar year spans two regnal years.

TDQS

A4.4/5.0

Scored across 7 tools

Disambiguation4/5

The four retrieval tools (get_legislation, get_legislation_fragment, get_legislation_metadata, get_legislation_table_of_contents) share a prefix but each description clearly states its role and even prescribes a workflow (TOC first, then fragment; metadata instead of full document). search_legislation vs search_effects are cleanly separated by domain. Minor residual risk that an agent fetches a whole document instead of metadata/TOC, but the guidance largely prevents that.

Naming Consistency5/5

Every tool follows a strict verb_noun snake_case convention: get_legislation*, search_legislation, search_effects, get_resource. The get_legislation_* family is a predictable, extensible namespace that makes the hierarchy legible.

Tool Count5/5

Seven tools is well-scoped for a legislation retrieval domain: one search tool, one document example, three scoped retrievals, one effects search, and one documentation fetcher. Nothing looks redundant or superfluous.

Completeness4/5

Covers the core lifecycle: discover (search_legislation), navigate (TOC), retrieve (document/fragment), inspect (metadata), and trace amendments (search_effects). Gaps are modest: no tool to enumerate legislation types or available versions directly, and resources reference search_legislation_semantic / search_legislation_sections_semantic tools that are not actually exposed, which could dead-end an agent following the cookbook.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues