Skip to main content
Lex API EXPERIMENT
Checking...

This is an experiment – your feedback will help us improve it.

Lex API

UK legal API for AI agents and researchers. Access comprehensive UK legislation data with semantic search and Model Context Protocol integration. Data is sourced from legislation.gov.uk under the Open Government Licence v3.0.

Important

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

Quick Start

Search UK legislation with a single API call:

curl -X POST https://lex-api.victoriousdesert-f8e685e0.uksouth.azurecontainerapps.io/legislation/search \
  -H "Content-Type: application/json" \
  -d '{"query": "data protection compliance"}'

Returns matching Acts and Statutory Instruments ranked by relevance:

{
  "results": [
    {
      "title": "Data Protection Act 2018",
      "type": "ukpga",
      "year": 2018,
      "number": 12,
      "score": 0.92
    },
    {
      "title": "The Data Protection, Privacy and Electronic Communications (Amendments etc) (EU Exit) Regulations 2019",
      "type": "uksi",
      "year": 2019,
      "number": 419,
      "score": 0.87
    }
  ],
  "total": 43
}

See the full API documentation for all endpoints, filters, and response schemas.

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-api.victoriousdesert-f8e685e0.uksouth.azurecontainerapps.io/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-api.victoriousdesert-f8e685e0.uksouth.azurecontainerapps.io/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 (Plugin)

Install as a plugin from GitHub:

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

# Install the skill plugin
/plugin install lex-uk-law@i-dot-ai-lex

Alternatively, if you've cloned the repo, the skill is already at .claude/skills/lex-uk-law/SKILL.md and activates automatically.

Claude Desktop / claude.ai

Download the skill file and add it manually:

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-api.victoriousdesert-f8e685e0.uksouth.azurecontainerapps.io/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. Authentication: No API key required — the Lex API is open access

Server URL:

https://lex-api.victoriousdesert-f8e685e0.uksouth.azurecontainerapps.io/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-api.victoriousdesert-f8e685e0.uksouth.azurecontainerapps.io/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-api.victoriousdesert-f8e685e0.uksouth.azurecontainerapps.io/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

  • Acts and Statutory Instruments
  • individual legal sections
  • explanatory note sections
  • legislative amendments

Temporal Coverage

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

PDF Digitisation

Historical legislation digitised using AI for improved accessibility:

  • PDF-sourced Acts (LLM extracted)
  • 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 Sections (by year)

Files split by year for manageability. 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.