UK legal API for AI agents and researchers. Access comprehensive UK legislation and caselaw data with semantic search and Model Context Protocol integration.

Our API provides programmatic access to millions of UK legal documents, court decisions, and statutory instruments with advanced semantic search capabilities, making it easier than ever to build AI-powered legal applications and conduct comprehensive legal analysis. Data is sourced from legislation.gov.uk under the Open Government Licence v3.0 and The National Archives under the Open Justice Licence.

This API is hosted as an experimental service and should not be used as a production dependency.

Important

This API is for research and non-production use. Rate limited to 60 requests per minute, 1000 per hour per IP address.

What Can You Build?

⚖️

Legal Research

Find precedents and relevant legislation in seconds. Ask natural language questions about UK law.

📊

Policy Analysis

Track legislative changes over time. Compare provisions across different Acts and amendments.

🤖

AI Grounding

Ground AI assistants in authoritative UK legal sources. Reduce hallucinations with verified data.

Model Context Protocol Setup

Connect the Lex API to AI assistants via Model Context Protocol for seamless legal research integration.

Claude Desktop Configuration

Add this configuration to your Claude Desktop configuration file:

Config file location: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "lex": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote@latest",
        "https://lex.lab.i.ai.gov.uk/mcp"
      ]
    }
  }
}

Tip: Also install the Lex UK Law skill for enhanced legal research guidance.

Claude Code Configuration

Connect Claude Code to Lex API using the CLI. Claude Code supports HTTP, SSE, and stdio MCP transports.

One-Line Install

Run this command in your terminal to add the Lex MCP server:

claude mcp add --transport http lex https://lex.lab.i.ai.gov.uk/mcp

Tip: Also install the Lex UK Law skill for enhanced legal research guidance.

Configuration options

Scope options:

  • --scope local (default) — Available only in current project
  • --scope project — Shared via .mcp.json file
  • --scope user — Available across all projects

Manage servers:

# List configured servers
claude mcp list

# Check server status (in Claude Code)
/mcp

# Remove a server
claude mcp remove lex

Lex UK Law Skill

Install the Lex UK Law skill for automatic legal research guidance. Skills work across Claude Code, Claude Desktop, and claude.ai.

Claude Code

Run these commands in Claude Code:

# Add the marketplace
/plugin marketplace add i-dot-ai/lex

# Install the skill
/plugin install lex-uk-law

Claude Desktop / claude.ai

Download the skill and upload via Settings → Capabilities → Upload skill:

Download Skill (.zip)
What are skills?

Skills are reusable capabilities that Claude automatically activates based on your request. Unlike MCP servers which provide tools, skills provide context and guidance for specific domains.

When you ask about UK law, Claude will automatically use the Lex skill to guide its legal research approach.

Skill vs MCP server

Use both together for best results:

  • MCP Server — Provides the search tools (required)
  • Skill — Provides domain expertise and best practices (recommended)

Install the MCP server first, then add the skill for enhanced legal research guidance.

Cursor Configuration

Add the Lex API MCP server to Cursor with one click or configure manually.

One-Click Install

Click the button below to automatically add Lex to your Cursor configuration:

Add to Cursor
Manual Configuration

Add this to your Cursor MCP configuration file:

Config file location: ~/.cursor/mcp.json (global) or .cursor/mcp.json (project)

{
  "mcpServers": {
    "lex": {
      "url": "https://lex.lab.i.ai.gov.uk/mcp"
    }
  }
}

Microsoft Copilot Studio Configuration

To use Lex API with Microsoft Copilot Studio, follow these steps:

  1. Access Copilot Studio: Go to your Microsoft Copilot Studio environment
  2. Create MCP Connection: Navigate to Tools → Add a tool → New tool → Model Context Protocol
  3. Configure Server URL: Enter the Lex API MCP endpoint URL
  4. Set Authentication: Configure API key authentication if required

Server URL:

https://lex.lab.i.ai.gov.uk/mcp
Requirements
  • Microsoft Copilot Studio access
  • Generative Orchestration must be enabled
  • Streamable transport support (current standard)

VS Code + GitHub Copilot Configuration

Add this configuration to your VS Code MCP settings file:

Config file location: .vscode/mcp.json (workspace) or user profile mcp.json

{
  "servers": {
    "lex": {
      "type": "http",
      "url": "https://lex.lab.i.ai.gov.uk/mcp"
    }
  }
}
Alternative setup methods

Via Command Palette:

  1. Open Command Palette (Cmd+Shift+P / Ctrl+Shift+P)
  2. Search for MCP: Add Server
  3. Select HTTP transport
  4. Enter URL: https://lex.lab.i.ai.gov.uk/mcp
  5. Enter server ID: lex
Requirements
  • VS Code 1.99 or later
  • GitHub Copilot extension installed
  • Agent mode enabled in Copilot Chat

Dataset Coverage

This experimental service provides access to comprehensive UK legal data for research and development purposes.

Available Documents

  • X Acts and Statutory Instruments
  • X individual legal sections
  • X court judgments and decisions
  • X AI-generated case summaries
  • X court case paragraphs
  • X explanatory note sections
  • X legislative amendments

Temporal Coverage

  • Legislation: 1267-present (complete from 1963)
  • Court cases: 2001-present
  • Search capabilities: Both semantic and exact matching
  • Updates: Dataset grows as new legislation and cases are published

PDF Digitisation

Historical legislation digitised using AI for improved accessibility:

  • X PDF-sourced Acts (LLM extracted)
  • X PDF-sourced sections (LLM extracted)
Warning LLM transcriptions are not independently verified. Data is labelled in API responses. Verify at source where accuracy is critical.

Bulk Downloads

Download complete datasets in Parquet format. Updated weekly every Sunday at 03:00 UTC.

Legislation

Legislation Sections (by year)

Files split by year for manageability. See manifest.json for current file list.

Caselaw

Caselaw Sections (by year)

Files split by year (2001-present). See manifest.json for current file list.

Format: Snappy-compressed Apache Parquet. 4-week retention for archived files. View manifest for file sizes and record counts.

API Documentation

Interactive API documentation with live examples and comprehensive endpoint details.

Swagger UI

Interactive API explorer with request and response examples for all endpoints.

View Swagger Documentation

ReDoc

Clean, reference-style documentation with detailed schemas and examples.

View ReDoc Documentation
GitHub

Open Source & Self-Hosting

Want to host your own instance or contribute to development? Lex API is open source under MIT licence.