Data source: EUR-Lex CELLAR (publications.europa.eu)
Overview
EUR-Lex (EU Legislation) wraps EUR-Lex CELLAR (publications.europa.eu), handling authentication, pagination, and rate limits for you. This tutorial covers all 5 tools with working code examples you can copy and run.
Prerequisites
- Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
- Choose your integration method: MCP protocol or REST API.
Connect via MCP
Add to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"gnist-eurlex": {
"url": "https://context.gnist.ai/mcp/eurlex/",
"headers": {
"Gnist-API-Key": "YOUR_API_KEY"
}
}
}
}
Tools (5)
search_legislation
Search EU legislation by keyword. Searches titles of EU legal acts (regulations, directives, decisions) published in the Official Journal. Covers the entire EUR-Lex corpus from the founding treaties to present-day legislation. Args: query: Search term to match against legislation titles. doc_type: Optional filter for document type. year: Optional filter for publication year. limit: Number of results to return (1-50, default 20). Returns: List of matching legal acts with CELEX number, title, date, and link.
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | required | Search term for EU legislation titles (e.g. "artificial intelligence", "data protection", "climate", "digital markets"). |
doc_type | any | optional | Filter by document type: "regulation", "directive", or "decision". Omit for all types. |
year | any | optional | Filter by year of publication (e.g. 2024). |
limit | integer | optional | Number of results to return (1-50, default 20). (default: 20) |
curl -X POST "https://context.gnist.ai/mcp/eurlex/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_legislation", "arguments": {"query": "artificial intelligence"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/eurlex/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'query': 'artificial intelligence'},
'name': 'search_legislation'}},
)
print(resp.json())
get_document
Get an EU legal document by its CELEX number. Returns metadata for a specific EU legal act including title, date, document types, and a direct link to the full text on EUR-Lex. CELEX numbers follow the pattern: sector + year + type + number. Common sectors: 3 = secondary legislation, 1 = treaties, 6 = case law. Args: celex: CELEX document identifier. Returns: Document metadata including title, date, types, and EUR-Lex URL.
| Parameter | Type | Required | Description |
|---|---|---|---|
celex | string | required | CELEX document number (e.g. "32024R1689" for the AI Act, "32016R0679" for GDPR). |
curl -X POST "https://context.gnist.ai/mcp/eurlex/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_document", "arguments": {"celex": "32024R1689"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/eurlex/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'celex': '32024R1689'}, 'name': 'get_document'}},
)
print(resp.json())
get_recent
Get recently published EU legislation. Returns the latest EU legal acts published within the specified time window. Useful for monitoring new regulations, directives, and decisions from the European Union. Args: doc_type: Optional filter for document type. days: Look back period in days (1-365, default 30). limit: Number of results to return (1-50, default 20). Returns: List of recent legal acts with CELEX number, title, date, and link.
| Parameter | Type | Required | Description |
|---|---|---|---|
doc_type | any | optional | Filter by type: "regulation", "directive", or "decision". Omit for all types. |
days | integer | optional | Look back period in days (1-365, default 30). (default: 30) |
limit | integer | optional | Number of results to return (1-50, default 20). (default: 20) |
curl -X POST "https://context.gnist.ai/mcp/eurlex/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_recent", "arguments": {"doc_type": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/eurlex/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'doc_type': 'example'}, 'name': 'get_recent'}},
)
print(resp.json())
search_by_subject
Search EU legislation by EuroVoc subject matter. EuroVoc is the EU's multilingual thesaurus used to classify all legal acts. This searches by subject descriptor rather than title keywords, which can find legislation that doesn't mention a topic explicitly in its title. Args: subject: EuroVoc subject descriptor to search for. limit: Number of results to return (1-50, default 20). Returns: List of matching legal acts with subject labels.
| Parameter | Type | Required | Description |
|---|---|---|---|
subject | string | required | EuroVoc subject descriptor (e.g. "environmental policy", "consumer protection", "competition", "transport"). |
limit | integer | optional | Number of results to return (1-50, default 20). (default: 20) |
curl -X POST "https://context.gnist.ai/mcp/eurlex/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_by_subject", "arguments": {"subject": "environmental policy"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/eurlex/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'subject': 'environmental policy'},
'name': 'search_by_subject'}},
)
print(resp.json())
report_feedback
Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.
| Parameter | Type | Required | Description |
|---|---|---|---|
feedback | string | required | |
feedback_type | string | optional | (default: general) |
curl -X POST "https://context.gnist.ai/mcp/eurlex/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/eurlex/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())
Common Patterns
Use
search_legislation to find items, then get_document to get full details. This two-step pattern is common for exploring data before drilling down.Several tools support
limit, offset, or page parameters. Start with small limits during development, then increase for production queries.FAQ
What data does EUR-Lex (EU Legislation) provide?
EU legislation database — search regulations, directives, and decisions via CELLAR SPARQL. Covers the entire Official Journal corpus from founding treaties to present. It exposes 5 tools: search_legislation, get_document, get_recent, search_by_subject, report_feedback.
What do I need to get started?
A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.
What format does the EUR-Lex (EU Legislation) API return?
JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.