loading…
Search for a command to run...
loading…
OpenLawMCP is an open-source legal AI research tool built to make AI-assisted legal research more reliable. A major problem with using AI for legal research is
OpenLawMCP is an open-source legal AI research tool built to make AI-assisted legal research more reliable. A major problem with using AI for legal research is that it can give confident answers without showing whether the answer is grounded in real legal sources. For legal work, that creates a credibility problem. Users need answers that can be checked against actual legal material.
A free, open-source Model Context Protocol (MCP) server that exposes UK and EU open law — judgments, statutes, regulations, regulator notices — to host LLMs such as Claude, ChatGPT, and Cursor.
Where general-purpose chatbots invent citations, openlaw-mcp fetches the real text from official open-data sources (The National Archives' Find Case Law, legislation.gov.uk, EUR-Lex, HUDOC, ICO, HMRC) and returns it with full provenance and licence attribution. Every tool result is cite-back ready.
Three ways to use openlaw-mcp:
npx.node dist/http.js after npm run build.A community endpoint is available at https://openlawmcp.legalaispace.com/v1/mcp. No API key, no signup, no rate-limit gate beyond the per-IP throttle. Best-effort uptime — no SLA, may be rate-limited, throttled, or migrated as load grows.
Codex CLI
codex mcp add openlaw --url https://openlawmcp.legalaispace.com/v1/mcp
Claude Code CLI
claude mcp add --transport http openlaw https://openlawmcp.legalaispace.com/v1/mcp
Claude Desktop / Cursor (config file)
{
"mcpServers": {
"openlaw": {
"url": "https://openlawmcp.legalaispace.com/v1/mcp"
}
}
}
Health check: curl https://openlawmcp.legalaispace.com/healthz should return {"status":"ok","service":"openlaw-mcp"}.
Runs locally — no dependency on the hosted endpoint.
{
"mcpServers": {
"openlaw": {
"command": "npx",
"args": ["-y", "@legalaispace/openlaw-mcp"]
}
}
}
npm install
npm run build
node dist/http.js # listens on PORT (default 3000), mount /v1/mcp
Behind a reverse proxy (nginx, Cloudflare, etc.), set TRUST_PROXY to the number of proxy hops so express-rate-limit keys by the real client IP — see Configuration.
Once the server is configured, paste any of these into your host LLM. They are UK-focused and chosen to exercise the tools where MCP grounding makes the biggest difference — exact statute text, point-in-time status, judgment paragraph quotes, regulator deep links, and ICO / HMRC material that a plain web search cannot reliably return verbatim.
Statute lookups (lookup_statute, legislation_toc)
Case law (search_caselaw, fetch_judgment, grep_judgment, citator_lite)
Regulator material (search_fca_handbook, fetch_fca_notice, search_ico_guidance, fetch_hmrc_manual)
EU material (fetch_eurlex)
ECHR / Strasbourg (fetch_hudoc)
Citation hygiene (format_oscola)
| Tool | What it does | Source / URL |
|---|---|---|
search_caselaw |
Search The National Archives' Find Case Law (E&W courts + tribunals from 2001). | https://caselaw.nationalarchives.gov.uk/atom.xml?query=... |
fetch_judgment |
Pull a full judgment as structured Akoma Ntoso. | https://caselaw.nationalarchives.gov.uk/{court}/{year}/{number}/data.xml |
grep_judgment |
Run a regex inside a single judgment's paragraphs. | https://caselaw.nationalarchives.gov.uk/{court}/{year}/{number}/data.xml |
lookup_statute |
Point-in-time lookup of any UK statute section on legislation.gov.uk. | https://www.legislation.gov.uk/{type}/{year}/{number}/section/{section}/data.xml (or .../{YYYY-MM-DD}/data.xml) |
legislation_toc |
Walk the table of contents for an Act or SI. | https://www.legislation.gov.uk/{type}/{year}/{number}/contents/data.xml |
fetch_eurlex |
Fetch an EU document by CELEX number. | https://publications.europa.eu/resource/celex/{CELEX} |
fetch_hudoc |
Fetch an ECHR judgment (English / French Court-authored text only). | Search/metadata: https://hudoc.echr.coe.int/app/query/results; body: https://hudoc.echr.coe.int/app/conversion/docx/html/body?... |
search_fca_handbook |
Resolve an FCA Handbook reference (SYSC 4.1.1R) to a deterministic deep link.[^1] |
Local computation only (no fetch); emits deep link under https://www.handbook.fca.org.uk/handbook/... |
fetch_fca_notice |
Build metadata + deep link for a known FCA Final or Decision Notice slug.[^1] | Local computation only (no fetch); emits deep link https://www.fca.org.uk/publication/{category}/{slug} |
search_ico_guidance |
Search ICO guidance and enforcement notices. | POST https://ico.org.uk/api/search (mirrors listing at https://ico.org.uk/action-weve-taken/enforcement/) |
fetch_hmrc_manual |
Fetch a section of an HMRC internal manual. | https://www.gov.uk/api/content/hmrc-internal-manuals/{manual}[/{section}] |
format_oscola |
Format a parsed citation in OSCOLA (UK / Ireland) or Bluebook. | Local computation only (no network call) |
citator_lite |
Forward citation lookup for a judgment. Treatment classification is not included. | https://caselaw.nationalarchives.gov.uk/atom.xml?query=%22[citation]%22 |
[^1]: FCA materials are link-only / metadata-only. The server does not fetch FCA Handbook or notice body text, and notice listing is disabled unless FCA grants written permission for automated access. Users are pointed to the FCA's own site for authoritative content. See ATTRIBUTIONS.md for the legal posture.
Clients that support MCP resources can also read:
| Resource template | What it returns | Source / URL |
|---|---|---|
judgment://{slug}/{year}/{number}/header |
TNA judgment header text. URL-encode slugs with /, e.g. ewca%2Fciv. |
https://caselaw.nationalarchives.gov.uk/{slug}/{year}/{number}/data.xml |
judgment://{slug}/{year}/{number}/index |
JSON paragraph index for a judgment. | https://caselaw.nationalarchives.gov.uk/{slug}/{year}/{number}/data.xml |
judgment://{slug}/{year}/{number}/para/{eId} |
A single judgment paragraph by Akoma Ntoso eId. |
https://caselaw.nationalarchives.gov.uk/{slug}/{year}/{number}/data.xml |
statute://{type}/{year}/{number}/section/{section} |
Current legislation.gov.uk section document as JSON. | https://www.legislation.gov.uk/{type}/{year}/{number}/section/{section}/data.xml |
inputSchema validated by zod).src/sources/*.ts) that performs HTTP fetches via shared Fetcher, ordata fields.data, provenance (source, source_url, fetched_at, content_hash, cache_hit, licence metadata), and learn_more; some tools also include note.isError: true plus a canonical authoritative URL.search_caselaw: receives search filters (query, optional court/date/page), fetches TNA Atom feed, parses entries into normalized judgment refs, returns paged hits + provenance.fetch_judgment: receives neutral citation or TNA URI, resolves to /data.xml, parses Akoma Ntoso into meta, header, paragraphs, returns full structured judgment + provenance.grep_judgment: same fetch/parsing as fetch_judgment, then runs JS regex across parsed paragraph text, returns match list/snippets + provenance.lookup_statute: receives legislation type/year/number/section (+ optional as_of), fetches CLML section XML, extracts title/text/version metadata/extent/prospective flags, returns normalized section document + provenance.legislation_toc: receives legislation type/year/number, fetches CLML contents XML, flattens parts/chapters/sections into entries, returns TOC + provenance.fetch_eurlex: receives CELEX, validates/normalizes it, blocks out-of-scope national sectors (7/8), fetches from Cellar with content negotiation (XHTML then HTML fallback), returns raw body + detected media type + provenance.fetch_hudoc: receives either itemid or search query. Search path fetches JSON results and suppresses out-of-policy records. Item path fetches metadata then body only when language/doctype/translation guard passes. Returns records/body + provenance + suppression note when applicable.search_fca_handbook: receives parsed handbook reference inputs, computes deterministic deep link locally, returns metadata + local provenance (urn:openlaw-mcp:local) without FCA content fetch.fetch_fca_notice: receives known notice slug (+ category), computes deterministic FCA deep link locally, returns metadata + local provenance; listing path intentionally errors (scraping disabled).search_ico_guidance: receives optional type/sector/date/page filters, posts to ICO /api/search, shapes response into enforcement list items, returns paged results + provenance.fetch_hmrc_manual: receives manual slug (+ optional section slug), fetches GOV.UK Content API JSON, returns either manual navigation tree or section body (bodyHtml + bodyText) + provenance.format_oscola: receives citation text + formatting options, parses and formats locally (OSCOLA/Bluebook), optionally emits derived Find Case Law URL for neutral citations, returns formatted output + local provenance.citator_lite: receives neutral citation, searches TNA Atom with quoted query to find citing judgments, trims to limit, returns citing list + disclaimer + provenance.judgment://.../header: MCP resource vars (slug, year, number) are validated/parsed, server fetches TNA judgment XML once, extracts plain-text header, returns text/plain.judgment://.../index: same fetch path, maps parsed paragraphs to { eId, num, preview }, returns application/json.judgment://.../para/{eId}: same fetch path, selects one paragraph by exact Akoma Ntoso eId, returns text/plain ([num] text when num exists).statute://.../section/{section}: validates resource vars, fetches legislation.gov.uk section XML via legislation client, returns parsed section document JSON.Every tool response carries a provenance block:
{
"data": { },
"provenance": {
"source": "Find Case Law",
"source_url": "https://caselaw.nationalarchives.gov.uk/uksc/2024/12/data.xml",
"fetched_at": "2026-05-12T12:00:00Z",
"content_hash": "sha256-...",
"cache_hit": false,
"licence": "Open Justice Licence v2.0",
"licence_url": "https://caselaw.nationalarchives.gov.uk/open-justice-licence",
"attribution": "Contains information licensed under the Open Justice — Licence v2.0"
},
"learn_more": "https://legalaispace.com"
}
If you redistribute the content downstream, preserve the attribution.
www.legislation.gov.uk is fronted by an AWS WAF that issues a JavaScript challenge (HTTP 202 Accepted with x-amzn-waf-action: challenge and an empty body) to clients whose IPs it considers suspicious — typically datacenter egress. From a residential network or an allow-listed deployment the API serves XML normally. Affected calls (lookup_statute, legislation_toc) surface a clear error and retry with backoff; we do not bypass the challenge by fingerprint-spoofing.openlaw-mcp fetches on demand for individual user queries; it does not maintain a persistent cross-user index of fetched content.lookup_statute / legislation_toc fail with an AWS WAF challengeThe error you see in your host LLM will read something like:
upstream responded with an AWS WAF JavaScript challenge (HTTP 202) on every attempt
www.legislation.gov.uk is fronted by an AWS WAF that issues a JavaScript challenge to clients whose IPs it considers suspicious — typically datacenter egress, some VPNs, and an evolving list of residential prefixes. The server detects the challenge (HTTP 202, x-amzn-waf-action: challenge, empty body) and surfaces a structured error rather than spoof fingerprints to bypass it. See Limitations for the design rationale.
What to do:
lookup_statute, legislation_toc) are the only tools affected by the legislation.gov.uk WAF. Caselaw (search_caselaw, fetch_judgment, grep_judgment), ICO, HMRC, EUR-Lex, HUDOC, FCA Handbook, and OSCOLA formatting all use independent upstreams and continue to work.curl -s -o /dev/null -w "%{http_code}\n" https://www.legislation.gov.uk/ukpga/2010/23/section/1/data.xml
200 → the API is reachable from your network. 202 → WAF is challenging your IP.npx -y @legalaispace/openlaw-mcp fails to start in Claude Desktop / Cursor / Claude Codenode --version is >= 22 (engines.node in package.json). On Windows, install Node via nvm-windows or fnm; on Linux, prefer your distribution's Node 22+ package or Volta.npx downloads the package; subsequent runs are cached. If your host LLM kills the spawn before the download completes, run npm install -g @legalaispace/openlaw-mcp once and switch the config to { "command": "openlaw-mcp" }.Cached responses live in ~/.cache/openlaw-mcp/http-cache.sqlite (override with OPENLAW_CACHE_DIR; disable with OPENLAW_DISABLE_CACHE=1). Delete the file to force a fresh fetch from upstreams. See Cache for the multi-tenant guidance.
The shared fetcher trips a per-host circuit breaker on repeated 5xx / network errors and cools down for 30 seconds before retrying. If you see "circuit open" errors, wait, then retry — and check the upstream's own status page.
All configuration is via environment variables.
| Variable | Default | What it does |
|---|---|---|
OPENLAW_CACHE_DIR |
~/.cache/openlaw-mcp |
Path for the SQLite HTTP cache. Set to off to disable caching. |
OPENLAW_DISABLE_CACHE |
unset | Alternative way to disable caching; set to 1. |
OPENLAW_MCP_PATH |
/v1/mcp |
Mount path for the Streamable HTTP transport. |
OPENLAW_RPM_PER_IP |
600 |
Per-IP request budget per minute for the HTTP transport. |
OPENLAW_CORS_ORIGIN |
* |
Access-Control-Allow-Origin value for the HTTP transport. |
PORT |
3000 |
Listen port for the HTTP transport. |
TRUST_PROXY |
1 |
How many reverse-proxy hops to trust when reading X-Forwarded-For. Set to 0 or false when binding directly to the public network, or to the hop count when chained behind multiple proxies (2, etc.). Express trust proxy string values (loopback, uniquelocal, IP/CIDR) are passed through. |
By default, GET responses are cached in ~/.cache/openlaw-mcp/http-cache.sqlite
with source-specific TTLs. Delete the cache directory to clear stored responses.
Multi-tenant deployments: The cache is shared across all callers of a given process. The TNA Find Case Law content is licensed under the Open Justice Licence v2.0, whose "computational analysis" carve-out does not permit a persistent cross-user retrieval index. If you are running the HTTP transport for more than one end-user, either set
OPENLAW_CACHE_DIR=offor give each tenant its own ephemeral cache directory. Single-user stdio usage (npx @legalaispace/openlaw-mcp) is unaffected.
If you are a rights-holder and believe content fetched by this server has been redistributed in error, please email [email protected]. We will investigate within five working days.
npm install
npm run dev:stdio # run the stdio server locally
npm run dev:http # run the Streamable HTTP server with watch
npm test # unit tests, MCP protocol tests, and the ICO fixture test
npm run lint && npm run typecheck
npm run build
npm pack --dry-run # verify npm package contents; runs release gates
Source code is Apache-2.0; see LICENSE. Upstream-data attributions and prior-art credit (notably paulieb89/uk-legal-mcp) are in ATTRIBUTIONS.md.
Development assisted by AI and Daman Kaur.
The information returned by this server is for information and research only and does not constitute legal advice.
Выполни в терминале:
claude mcp add openlaw-mcp -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.