EU law · 24 official languagesArticle-level JSON · typed citation graphMCP server · Claude, Cursor, VS CodeSDKs · Python, TypeScriptFree plan · 500 credits to start
Brussels · CET
Vol. II·Section S — Solutions Desk
MCP · REST · Python · TypeScript

§ Legal data API for AI agents — For developers

EU law as tools your AI agent can call.

Connect an agent to EU law over the Model Context Protocol, or call the REST API from your own tool loop: legislation by article, Court of Justice case law, citations and semantic search, with the identifiers to cite each source.

The free plan starts with 500 credits, no card. Your API key is on the dashboard once you confirm your email.

Create a free accountQuickstart

§ 01 — Hosted MCP

Nothing to install.

You need: Claude Code and a LexAPI account

  1. Run this in your terminal.
  2. In Claude Code, run /mcp, choose lexapi, then Authenticate. Sign in to LexAPI in the browser and approve.
  3. Ask: Using LexAPI, quote Article 17 of the GDPR (CELEX 32016R0679) and cite it.
Claude Code
claude mcp add --transport http lexapi https://mcp.lex-api.com/v1

An agent without a browser signs in with an API key instead:

claude mcp add --transport http lexapi https://mcp.lex-api.com/v1 --header "Authorization: Bearer lex_your_key"

The server is at https://mcp.lex-api.com/v1 (Streamable HTTP) and serves 37 tools. Tool calls use your plan’s credits at the price of the REST call they wrap, and each tool description states that price, so the model can see it.

claude.ai, Cursor and VS Code setup

§ 02 — Local MCP

The npm package, over stdio.

You need: Node.js 20 or newer and an API key

@lexapi/mcp runs on your machine and serves the same tools. Claude Code:

Claude Code
claude mcp add lexapi --env LEXAPI_API_KEY=lex_your_key -- npx -y @lexapi/mcp

Claude Desktop, Cursor and other stdio clients take the same command as JSON:

mcpServers config
{
  "mcpServers": {
    "lexapi": {
      "command": "npx",
      "args": ["-y", "@lexapi/mcp"],
      "env": { "LEXAPI_API_KEY": "lex_your_key" }
    }
  }
}

For an agent that should only read, set LEXAPI_MCP_READ_ONLY=true in the package’s environment. It hides the tools that write: lex_extract_citations, lex_create_webhook, lex_update_webhook, lex_delete_webhook, lex_test_webhook.

§ 03 — Tools

Find, read, cite.


These tools cover the loop an agent runs to answer from EU law. Each wraps one REST route and is billed like it.

ToolWhat it doesREST routeCredits
lex_semantic_legislationFind articles of EU legislation by meaningPOST /legislation/semantic5
lex_semantic_case_lawFind Court of Justice case law by meaningPOST /search/semantic5
lex_resolveTurn an ECLI, an ELI or a EUR-Lex link into a CELEX numberPOST /resolve1
lex_get_documentRead a document, or one article of itPOST /documentContent1 / 4 / 5
lex_cited_byList what cites, amends or corrects a documentGET /citations/cited-by/:celexNumber1
lex_citesList what a document citesGET /citations/cites/:celexNumber1
lex_infoCheck the plan and the credits leftGET /info0

A document read costs 1 credit when LexAPI already holds the document, 4 or 5 when it is fetched from the source first.

Prompts to try

  • Using LexAPI, find the GDPR article on the right to erasure, quote it and cite it by CELEX number and article.Typically uses lex_semantic_legislation, lex_get_document.
  • Using LexAPI, find Court of Justice judgments on transfers of personal data to third countries and give each case number, ECLI and CELEX number.Typically uses lex_semantic_case_law, lex_resolve.
  • Using LexAPI, list what has corrected or amended Regulation (EU) 2016/679 since it was published.Typically uses lex_cited_by.

All tools, by group

§ 04 — REST and SDKs

Your own tool loop.

You need: curl in bash or zsh, and an API key

An agent that defines its own tools calls the same routes directly, with the key in the x-api-key header. This call is free: it returns your plan and the credits left, so an agent can check its budget before it starts.

curl
curl "https://lex-api.com/api/v1/info" \
  -H "x-api-key: lex_your_key"
You get (abridged)
{
  "service": "LexAPI",
  "subscription": { "tier": "PROFESSIONAL", "pricingMode": "credits", … },
  "credits": { "operation_weight": 0, "remaining": 149898, "resetsAt": "2026-12-17T18:09:15.340Z", … },
  …
}
  • On a credit plan the response to a metered call carries credits.operation_weight, what the call cost, and credits.remaining.
  • A pool that cannot cover a call answers 402; more requests in a minute than the plan allows (15 on the free plan) answer 429 with a Retry-After header.
  • The official SDKs wrap the same routes: pip install lexapi-client for Python and npm install @lexapi/client for TypeScript.

Worked requests, with curl, Python and TypeScript: European legal RAG, GDPR API and European case law API.

The errors a first call meets

§ 05 — Works with

Your framework, your AI app.


One account and a single credit pool cover all of these. Every call is billed like the REST call it makes.

WhereHow
Claude (claude.ai, Desktop, mobile)Listed in Claude’s Connectors Directory: connect it and sign in to LexAPI.
Claude Code, Cursor, VS CodeThe hosted MCP server, or the npm package over stdio.
LangChain and LangGraphlangchain-lexapi: retrievers and agent tools.
LlamaIndexRetrievers and a tool spec for agents.
Your own tool loopThe REST API, or the Python client.
§ 06 — FAQ

Asked & answered.

N° 01How do I connect Claude or Cursor to EU law?+
Through the LexAPI MCP server. Hosted: add https://mcp.lex-api.com/v1 (Streamable HTTP) to a client that takes remote servers; it serves 37 tools. Local: run the npm package @lexapi/mcp over stdio with your API key in LEXAPI_API_KEY. The local package needs Node.js 20 or newer.
N° 02How does the LexAPI MCP server authenticate?+
The hosted server accepts a sign-in with your LexAPI account, where you approve the connection in the browser, or an API key in the Authorization: Bearer header. An app connected by sign-in never sees your password or your API keys. The local package reads the key from the LEXAPI_API_KEY environment variable.
N° 03Can I stop an agent from creating or deleting webhooks?+
With the local package, yes. Set LEXAPI_MCP_READ_ONLY=true in its environment and the tools that write are hidden: lex_extract_citations and the four webhook tools that create, update, delete and test a webhook. The hosted server runs with read-only mode off.
N° 04Does an agent need MCP to use LexAPI?+
No. An agent that defines its own tools calls the REST API directly, with the key in the x-api-key header, or through the Python package lexapi-client or the TypeScript package @lexapi/client. The MCP tools wrap the same REST routes.
§ 07 — Next

Keep building.


  • GDPR APIRead the GDPR by article or recital, cite it, and list what corrects or amends it.
  • European case law APISearch Court of Justice case law by meaning, resolve an ECLI, read the judgment.
  • European legal RAGSemantic search to article text with provenance, citations and the text for a date.
  • QuickstartA first request by curl, MCP, Python and TypeScript.
  • API referenceEvery endpoint, parameter, response field and error.
  • MCP serverSetup for Claude, Cursor and VS Code, and the tool list.
  • PricingPlans, credit pools and what each call costs.

LexAPI returns source texts and their identifiers. It does not assess compliance and gives no legal advice.