UK Legal Research MCP Server
This MCP server connects AI assistants to UK legal and parliamentary data through 24 read-only tools (23 require no API keys) across 8 modules:
Case Law
Search UK judgments by full text, court, judge, party, or date range
Search within a specific judgment using text/regex patterns
Access judgment headers, paragraph indexes, and individual paragraphs via URI templates
Legislation
Search Acts of Parliament and Statutory Instruments by title or full text
Retrieve tables of contents, specific sections (with territorial extent and in-force status), and point-in-time historical versions
Parliament
Search Hansard debates by keyword, member, or date
Run a "vibe check" on a policy topic — uses LLM sentiment analysis to identify supporters, opponents, and concerns
Look up MPs/Lords by name; retrieve their debate contributions and registered financial interests (donations, shareholdings, directorships)
Search Parliament petitions by keyword and state
Bills
Search parliamentary bills by keyword, session, house, or stage
Get full bill details: sponsors, legislative stages, long title, and Royal Assent date
Votes
Search Commons and Lords division records by keyword or date
Get full division details including how each member voted
Committees
Search select committees by name and house; get membership and contact details
Search oral and written evidence submitted to committees
Citations (OSCOLA)
Parse and classify all OSCOLA citations from free text (neutral citations, law reports, legislation, SIs, retained EU law)
Resolve a single citation to its canonical TNA or legislation.gov.uk URL
Map the full citation network of a judgment
HMRC Tax
Look up UK VAT rates for any commodity or service
Check a business's Making Tax Digital (MTD) VAT mandate status (requires HMRC OAuth credentials)
Search GOV.UK for HMRC guidance documents
Workflow Prompts — four built-in multi-step research workflows: summarise_act, compare_legislation, policy_vibe_check, and member_position_analysis.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@UK Legal Research MCP Serversearch for recent Supreme Court judgments regarding duty of care"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
uk-legal-mcp
A Model Context Protocol server for UK legal research. Connects AI assistants to case law, legislation, parliamentary debates, bills, votes, committees, OSCOLA citation parsing, and HMRC tax data through a single endpoint.
24 tools across 8 modules. One connection. Read-only. No API keys required for 23 of 24 tools.
MCP Client (Claude, Cursor, etc.)
|
v
uk-legal-mcp gateway (Streamable HTTP)
+----------------------------------------------------+
| |
| case_law TNA Find Case Law API |
| legislation legislation.gov.uk Atom feed |
| parliament Hansard API + Members API |
| bills Parliamentary Bills API |
| votes Commons + Lords division records |
| committees Select committees + evidence |
| citations OSCOLA regex parser (no network) |
| hmrc HMRC sandbox/prod + GOV.UK search |
| |
+----------------------------------------------------+Quickstart
Connect to the hosted server
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"uk-legal": {
"type": "streamable-http",
"url": "https://uk-legal-mcp.fly.dev/mcp"
}
}
}Then try:
"Search for case law about cycling accidents"
"Get section 172 of the Companies Act 2006"
"Parse the citations in: The court applied Donoghue v Stevenson [1932] AC 562 and s.2 Occupiers' Liability Act 1957"
"What is parliament saying about short selling?"
Run locally
pip install -e .
python -m src.gateway
# Server starts on http://localhost:8000/mcpInspect with the MCP Inspector:
npx @modelcontextprotocol/inspector http://localhost:8000/mcpTools
Case Law
Tool | What it does |
| Full-text search of UK judgments. Filter by court, judge, party, date range. |
| Find paragraphs in a judgment matching a pattern. Returns |
Resource templates (read via resources/read or the read_resource tool generated by ResourcesAsTools):
URI template | Returns |
| Metadata header (parties, judges, citation). ~1k tokens. |
| Paragraph eId + first-line per row. ~4k tokens. Walk this to discover paragraphs. |
| A single paragraph including its sub-paragraphs. 400–1700 tokens. |
Upstream: TNA Find Case Law (Atom/XML). Rate limit: 1,000 req/5 min. Cached 1 hour.
Legislation
Tool | What it does |
| Search Acts of Parliament and Statutory Instruments on legislation.gov.uk. |
| Table of contents for an Act — parts, chapters, sections, schedules. |
| Retrieve a specific section with territorial extent, in-force status, and version date. |
Resource templates (alternative to the tools above for clients that prefer URI-addressed reads):
URI template | Returns |
| Full Act/SI as CLML XML. |
| A specific section as CLML XML. |
| Flat |
| Point-in-time CLML for a YYYY-MM-DD date. |
Upstream: legislation.gov.uk (CLML XML + Atom feed). Cached 24 hours. Uses curl_cffi with Chrome impersonation to defeat CloudFront 437; Companies Act 2006 currently hits an AWS WAF JS challenge intermittently.
Note: Always check the extent field. A section may apply to England and Wales but not Scotland or Northern Ireland.
Parliament
Tool | What it does |
| Search Hansard debate contributions by exact phrase. |
| Assess parliamentary reception of a policy topic. Searches Hansard, then uses LLM sampling to classify sentiment, supporters, opponents, and concerns. |
| Look up an MP or Lord by name. Returns member ID for use with |
| Retrieve a specific member's Hansard contributions, optionally filtered by topic. |
| Get a member's registered financial interests (donations, shareholdings, etc.). |
| Search UK Parliament petitions by keyword. |
Upstream: hansard-api.parliament.uk + members-api.parliament.uk + petition.parliament.uk. Not cached (live data).
Bills
Tool | What it does |
| Search current and historical parliamentary bills by keyword, session, or type. |
| Get full bill detail — stages, sponsors, publications. |
Upstream: bills-api.parliament.uk. Cached 1 hour.
Votes
Tool | What it does |
| Search Commons and Lords division records by keyword or date. |
| Get full division detail — vote counts, how each member voted. |
Upstream: commonsvotes-api.parliament.uk + lordsvotes-api.parliament.uk. Cached 24 hours.
Committees
Tool | What it does |
| Search parliamentary select committees by keyword. |
| Get committee detail — membership, sub-committees. |
| Search oral and written evidence submissions to committees. |
Upstream: committees-api.parliament.uk. Cached 1 hour.
Citations
Tool | What it does |
| Extract all OSCOLA citations from free text. Resolves to canonical URLs. Disambiguates bare court codes via LLM sampling. |
| Parse and resolve a single citation string to its canonical URL. |
| Fetch a judgment from TNA and map every citation within it — cases, legislation, SIs, EU law. |
Self-contained. No external API. Zero network dependency (except citations_network which fetches the judgment XML).
Supported citation formats:
Format | Example |
Neutral citation |
|
Law report (with or without volume) |
|
Legislation section |
|
Statutory Instrument |
|
Retained EU law |
|
HMRC
Tool | What it does |
| VAT rate lookup for any commodity or service. Static table current as of Autumn Statement 2023. |
| Check Making Tax Digital VAT mandate status for a VRN. Requires HMRC OAuth credentials. |
| Search GOV.UK for HMRC guidance documents. |
hmrc_get_vat_rate and hmrc_search_guidance require no credentials. hmrc_check_mtd_status requires HMRC_CLIENT_ID and HMRC_CLIENT_SECRET — register at developer.service.hmrc.gov.uk. Defaults to sandbox; set HMRC_API_BASE=https://api.service.hmrc.gov.uk for production.
Prompts
Four workflow prompts are available for multi-step legal research. Exposed as tools via PromptsAsTools for ChatGPT; accessible natively on protocol-aware clients (Claude, Inspector).
Prompt | Module | Description |
| legislation | Structured summary of a UK Act or SI |
| legislation | Comparative analysis of two pieces of legislation on a topic |
| parliament | Parliamentary reception assessment for a policy |
| parliament | A member's position and voting record on a topic |
Architecture
src/
gateway.py FastMCP gateway — mounts all modules, applies middleware
deps.py Shared httpx clients (lifespan-managed) + error formatting
modules/
case_law/ TNA Find Case Law (Atom/XML parsing)
legislation/ legislation.gov.uk (CLML XML + Atom feed)
parliament/ Hansard API + Members API + Petitions (JSON)
bills/ Parliamentary Bills API (JSON)
votes/ Commons + Lords division records (JSON)
committees/ Select committees + evidence (JSON)
citations/ OSCOLA regex engine (compiled once, lru_cache)
hmrc/ HMRC OAuth + GOV.UK search (JSON)
tests/
test_citations.py 35 unit tests — regex patterns, resolution, disambiguationEach module is a standalone FastMCP instance mounted into the gateway with a namespace prefix (case_law_, legislation_, etc.). All modules share a single httpx client pool via the gateway's lifespan context.
Middleware stack (gateway level):
Middleware | Purpose |
| Catches unhandled exceptions |
| JSON logging with duration and payload size |
| Per-tool timing logs |
| 80,000 char cap (LegalDocML XML can exceed 200k) |
Per-module caching: ResponseCachingMiddleware with TTLs — case_law (1hr), legislation (24hr), bills (1hr), votes (24hr), committees (1hr), hmrc (90 days). Parliament and citations are not cached.
Deployment
Fly.io
fly auth login
fly launch --name uk-legal-mcp --region lhr
fly deployOptional secrets:
fly secrets set HMRC_CLIENT_ID=your_id HMRC_CLIENT_SECRET=your_secret
# For production HMRC (default is sandbox):
fly secrets set HMRC_API_BASE=https://api.service.hmrc.gov.ukDocker
docker build -t uk-legal-mcp .
docker run -p 8000:8000 uk-legal-mcpTesting
pip install -e '.[test]' # or: pip install pytest
pytest tests/test_citations.py -vAll 35 citation tests run offline with no API credentials.
Upstream APIs and Licences
Source | API | Licence | Auth |
TNA Find Case Law |
| None | |
legislation.gov.uk |
| None | |
UK Parliament Hansard |
| None | |
UK Parliament Members |
| Open Parliament Licence | None |
UK Parliament Petitions |
| Open Parliament Licence | None |
UK Parliament Bills |
| Open Parliament Licence | None |
UK Parliament Votes |
| Open Parliament Licence | None |
UK Parliament Committees |
| Open Parliament Licence | None |
HMRC |
| OGL / commercial terms | OAuth 2.0 |
GOV.UK Search |
| OGL v3 | None |
Stack
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/paulieb89/uk-legal-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server