# LexAPI MCP server

> Enables AI assistants to access EUR-Lex legislation, CJEU case law, and semantic search for EU and national laws with historical version support.

- Repository: https://github.com/Lex-API/lexapi-mcp
- Page: https://hostedmcp.org/servers/lex-api/lexapi-mcp
- Transport: stdio, remote
- Stars: 3
- License: MIT
- Latest version: 0.3.0

## Install

### Claude Code

```sh
claude mcp add --env 'LEXAPI_API_KEY=<YOUR_LEXAPI_API_KEY>' lexapi-mcp -- npx -y @lexapi/mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "lexapi-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@lexapi/mcp"
      ],
      "env": {
        "LEXAPI_API_KEY": "<YOUR_LEXAPI_API_KEY>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "lexapi-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@lexapi/mcp"
      ],
      "env": {
        "LEXAPI_API_KEY": "<YOUR_LEXAPI_API_KEY>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"lexapi-mcp","type":"stdio","command":"npx","args":["-y","@lexapi/mcp"],"env":{"LEXAPI_API_KEY":"<YOUR_LEXAPI_API_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "lexapi-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@lexapi/mcp"
      ],
      "env": {
        "LEXAPI_API_KEY": "<YOUR_LEXAPI_API_KEY>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add lexapi-mcp --env 'LEXAPI_API_KEY=<YOUR_LEXAPI_API_KEY>' -- npx -y @lexapi/mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.lexapi-mcp]
command = "npx"
args = ["-y", "@lexapi/mcp"]

[mcp_servers.lexapi-mcp.env]
LEXAPI_API_KEY = "<YOUR_LEXAPI_API_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'LEXAPI_API_KEY=<YOUR_LEXAPI_API_KEY>' lexapi-mcp npx -- -y @lexapi/mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "lexapi-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@lexapi/mcp"
      ],
      "env": {
        "LEXAPI_API_KEY": "<YOUR_LEXAPI_API_KEY>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `LEXAPI_API_KEY` | yes | yes | LexAPI API key. Get one at https://lex-api.com/dashboard (FREE plan: 500 credits/month). |
| `LEXAPI_BASE_URL` | no | no | Override the LexAPI base URL. Defaults to https://lex-api.com/api/v1. |
| `LEXAPI_MCP_READ_ONLY` | no | no | Set to true to hide every non-read-only tool (webhook create/update/delete/test, citation extraction). |
| `LEXAPI_TIMEOUT_MS` | no | no | Deadline per tool call in milliseconds, retries included (default 55000). Raise only together with the MCP client timeout. |

## Tools (25)

- `lex_semantic_legislation`
- `lex_semantic_case_law`
- `lex_search`
- `lex_recent_documents`
- `lex_resolve`
- `lex_get_document`
- `lex_get_documents_batch`
- `lex_get_metadata`
- `lex_get_document_by_url`
- `lex_document_versions`
- `lex_get_document_version`
- `lex_cited_by`
- `lex_cites`
- `lex_citation_network`
- `lex_citation_path`
- `lex_related`
- `lex_citation_stats`
- `lex_extract_citations`
- `lex_export`
- `lex_national_coverage`
- `lex_list_national_documents`
- `lex_get_national_document`
- `lex_national_semantic_case_law`
- `lex_national_semantic_legislation`
- `lex_info`

## FAQ

### How do I connect to the LexAPI MCP server?

You can connect to the hosted server by signing in with your LexAPI account via your MCP client, or use an API key for local installations and scripts.

### Is there a free way to try LexAPI?

Yes, there is a free plan available that requires no credit card and provides enough credits to test the read tools.
