legislation.gov.uk MCP Server
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| PORT | No | HTTP server port when using HTTP transport. | 3000 |
| AWS_REGION | No | AWS region for the Data API client. | eu-west-2 |
| MCP_TRANSPORT | No | Communication transport. Options are stdio or http. | stdio |
| DUTIES_DB_NAME | No | Database name for the powers-and-duties database. | duties |
| MCP_SERVER_KEY | No | Optional bearer token. If set, clients must send Authorization: Bearer <key> on the /mcp endpoint. | |
| SEMANTIC_API_KEY | No | API key for semantic search authentication. | |
| DUTIES_DB_SECRET_ARN | No | ARN 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_ARN | No | ARN 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_URL | No | Base URL for the Research API. | https://research.legislation.gov.uk |
| RESEARCH_API_PASSWORD | No | Basic-auth password for the Research API. Required together with RESEARCH_API_USERNAME to enable the advanced search tools. | |
| RESEARCH_API_USERNAME | No | Basic-auth username for the Research API. Required together with RESEARCH_API_PASSWORD to enable the advanced search tools. | |
| SEMANTIC_API_BASE_URL | No | Base 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
| Capability | Details |
|---|---|
| tools | {} |
| resources | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| search_legislationA | Search for UK legislation by keyword, title, or other criteria on legislation.gov.uk. Returns JSON by default (set Results include:
See: |
| 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.
Returns JSON with:
Fragment: pass a Version: use a date ( For response field details, see |
| get_legislationA | Retrieve a full UK legislation document by type, year, and number. Returns readable plain text by default ( Text is best for reading and summarisation. It discards semantic markup, amendment commentaries, and structural metadata — use For large documents, use get_legislation_table_of_contents first, then get_legislation_fragment for specific sections. Common types: Version: use a date ( See: |
| get_legislation_fragmentA | Retrieve a fragment (section, part, chapter, etc.) of a UK legislation document. Returns readable plain text by default ( Text is best for reading and summarisation. It discards semantic markup, amendment commentaries, and structural metadata — use
Version: use a date ( See: |
| get_legislation_table_of_contentsA | Retrieve the table of contents for a UK legislation document. Returns structured JSON by default ( Shows the hierarchical structure (Parts, Chapters, Sections) with headings and fragment IDs for use with get_legislation_fragment.
Version: use a date ( See: |
| 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 |
| 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:
|
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| Advanced Query Syntax | Complete 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.uk | The 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 CLML | Understanding restrictExtent attributes and territorial application of UK legislation |
| CLML Schema Guide | CLML (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 Index | Step-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 Legislation | This 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 Issues | Solutions to common errors and edge cases when working with UK legislation data. |
| Advanced Search Response Formats | JSON formats for `search_legislation_advanced` and `count_legislation_advanced` tool responses. |
| Metadata Response Format | JSON format for `get_legislation_metadata` tool responses. |
| Search Response Format | JSON format for `search_legislation` tool responses. |
| Semantic Search Response Format | Response format for `search_legislation_semantic` tool. |
| Semantic Section Search Response Format | Response format for `search_legislation_sections_semantic` tool. |
| Table of Contents Response Format | JSON format for `get_legislation_table_of_contents` tool responses. |
| Text Format Guide | The 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 Reference | UK 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 Data | CSV 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
Scored across 7 tools
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.
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.
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.
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.