This server acts as a modern, AI-friendly bridge to the official EUR-Lex SOAP webservice. It exposes the complex EUR-Lex API as a simple and powerful Model Context Protocol (MCP) server, making the entire body of European Union law accessible to modern AI agents, developer tools, and applications.
By wrapping the legacy SOAP API, this server unlocks use cases in automated legal research, compliance monitoring, policy analysis, and more, without requiring AI agents to understand the complexities of WSDL or XML.
- Dual-Mode Transport: Runs over STDIO for secure, local integration with desktop applications (like Claude Desktop, Cursor) and over HTTP for remote access by AI agents and web services.
- Expert Search Tool: Provides an
expert_searchtool that allows for powerful, flexible querying using the native EUR-Lex expert search syntax. - Direct Document Access: Includes a
get_document_by_celexresource template for fetching specific legal documents directly via a clean URI (resource://eurlex/document/{celex_number}). - Clean, Structured Output: Automatically parses the verbose SOAP/XML responses into a clean, easy-to-use JSON format, perfect for LLM consumption.
- Easy Installation: Can be easily installed into compatible clients using the
fastmcpcommand-line tool.
Before you begin, ensure you have the following:
- Python 3.11+ and the
uvpackage manager. If you don't haveuv, install it with:pip install uv
- EUR-LEX Webservice Credentials. You must register for a webservice account to get a username and password. You can do this by following the "Webservice registration" link on the EUR-Lex website after logging in.
Follow these steps to get the server up and running on your local machine.
1. Clone the Repository (This is only necessary if you want to install it to Claude Desktop with the practical fastmcp install command)
Clone this project to your local machine.
git clone https://github.com/scimorph/eur-lex-mcp.git
cd eur-lex-mcpCreate and activate a virtual environment, then install the required dependencies using uv.
# Create and activate the virtual environment
uv venv
# On macOS/Linux
source .venv/bin/activate
# On Windows
.venv\Scripts\activate
# Install dependencies
uv pip install -r pyproject.tomlThe server requires your EUR-LEX webservice username and password. The most secure way to provide them is through a .env file.
-
Create a file named
.envin the root of the project directory. -
Never commit this file to Git! It is already included in the
.gitignore. -
Add your credentials to the
.envfile like this:# .env EURLEX_USERNAME="your-eurlex-username" EURLEX_PASSWORD="your-webservice-password"
This server can be run in two modes, depending on your use case.
This is the recommended mode for integrating with local applications. The server will run over STDIO.
You do not need to run the server manually. Instead, you "install" it into your client application.
The easiest way to install the server is with the fastmcp CLI:
# Run the install command from the project root
fastmcp install server.py --name "EUR-LEX Search"This command will automatically detect your server.py, read its dependencies, and configure Claude Desktop to run it. Simply restart Claude Desktop and the "EUR-LEX Search" tool will be available.
For other applications (optionally for Claude Desktop), you will need to manually configure them to run the server.py script. Find the MCP server configuration section in your application's settings and add an entry that executes the script.
{
"mcpServers": {
"eurlex-search": {
"command": "npx",
"args": [
"-y",
"-p", "fastmcp",
"-p", "zeep",
"-p", "python-dotenv",
"fastmcp", "run", "https://scimorph/eur-lex-mcp/main/server/server.py"
],
"env": {
"EURLEX_USERNAME": "YOUR_EURLEX_USERNAME",
"EURLEX_PASSWORD": "YOUR_WEBSERVICE_PASSWORD"
}
}
}
}For running the server in HTTP mode, the easiest and most portable method is to use Docker. This approach encapsulates all dependencies and requires no local Python environment setup.
You will need Docker Desktop installed on your machine.
We provide a pre-built Docker image on Docker Hub for your convenience.
1. Create a Credentials File
On your local machine, create a file named eurlex.env. This file will securely store your credentials and will be passed to the container at runtime.
# eurlex.env
EURLEX_USERNAME="YOUR_EURLEX_USERNAME"
EURLEX_PASSWORD="YOUR_WEBSERVICE_PASSWORD"2. Run the Docker Container
Execute the following command in your terminal. It will pull the image from Docker Hub and run it with your credentials.
docker run -d --name eur-lex-mcp -p 8000:8000 --env-file ./eurlex.env --rm enzofanaccount/eur-lex-mcp:latestThat's it! The server is now running and accessible at http://localhost:8000.
-d: Runs the container in detached mode (in the background).--name eurlex-mcp: Gives the container a memorable name.-p 8000:8000: Maps port 8000 from the container to port 8000 on your local machine.--env-file ./eurlex.env: This is how we handle credentials. It securely injects the variables from your localeurlex.envfile into the container's environment.--rm: Automatically removes the container when it stops.
If you prefer to build the image yourself:
1. Create the Dockerfile
Create a file named Dockerfile in a new directory and paste the contents from the Dockerfile above. Make sure to update the ADD line with the correct URL to your server.py file.
2. Create the eurlex.env Credentials File
Create the eurlex.env file in the same directory as your Dockerfile, as described in Option A.
3. Build the Docker Image
From the directory containing your Dockerfile and eurlex.env, run:
docker build -t eurlex-mcp-server .4. Run Your Locally Built Image
Run the same command as before, but use the local image name:
docker run -d --name eur-lex-mcp -p 8000:8000 --env-file ./eurlex.env --rm eurlex-mcp-serverThe server is now running and accessible at http://localhost:8000.
Run the following command from your terminal:
python server.py --transport httpThe server will start and be accessible at http://127.0.0.1:8000.
You can customize the host and port:
python server.py --transport http --host 0.0.0.0 --port 9001The EUR-LEX MCP Server exposes the following capabilities:
Performs a flexible search across the EUR-Lex database using the official expert search syntax.
- Parameters:
query(str): The search query, following EUR-Lex syntax. Required.language(str): The two-letter language code for the search. Default:"en".page(int): The page number of the results. Default:1.page_size(int): The number of results per page. Default:10.
- Returns: A list of document objects.
Example Return Value:
[
{
"celex": "32016R0679",
"title": "Regulation (EU) 2016/679 of the European Parliament and of the Council...",
"url": "http://publications.europa.eu/resource/celex/32016R0679.EN.html"
}
]Fetches a single, specific document directly by its CELEX number.
- URI Template:
resource://eurlex/document/{celex_number} - Parameters:
celex_number(str): The unique CELEX identifier of the document.
- Returns: A single document object.
Example URI:
resource://eurlex/document/32016R0679
Example Return Value:
{
"celex": "32016R0679",
"title": "Regulation (EU) 2016/679 of the European Parliament and of the Council of 27 April 2016 on the protection of natural persons with regard to the processing of personal data and on the free movement of such data, and repealing Directive 95/46/EC (General Data Protection Regulation) (Text with EEA relevance)",
"url": "http://publications.europa.eu/resource/celex/32016R0679.EN.html"
}Contributions are welcome! If you'd like to improve the server, please follow these steps:
- Fork the repository.
- Clone the fork to your IDE.
- Create a descriptive new branch for your feature (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add some amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.