MCP Server Legifrance

Integrations

  • Uses .ENV files to securely store API credentials and configuration needed to access the Legifrance API.

  • Allows installation directly from GitHub repository using pip or uv package managers.

  • Leverages Python for implementing the MCP server, with support for Python 3.9+ environments and package management.

mcp-server-legifrance

MCP Model Context Protocol server allowing querying of French legal bases via the Legifrance API in compatible LLMs such as Claude.

Description

This project implements an MCP server that provides access to French legal resources (legal texts, codes, case law) directly from a Large Language Model. It facilitates legal research by making Legifrance data accessible via interactive tools.

It is necessary following the creation of the pylegifrance package.

What is MCP?

The Model Context Protocol (MCP) is a standardized protocol developed by Anthropic that allows language models like Claude to interact in a structured way with external tools and services. This is an exciting step forward in LLM interoperability because it establishes a common framework for data exchange and function execution between models and third-party APIs. Until now, specific function calls had to be developed for each service.

Interoperability via MCP

The importance of MCP lies in its ability to create a standardized interface between LLMs and external systems. This standardization has several advantages:

  1. Modular architecture : Developers can create specialized tools that are easily integrated with different protocol-compatible LLMs.
  2. Increased security : MCP limits model access to only explicitly defined features, reducing security risks.
  3. Simplified maintenance : Updates to external tools can be made independently of the model, facilitating system evolution.
  4. Capability Expansion : LLMs can access real-time data and perform complex operations that they could not perform alone.

mcp-server-legifrance?

The idea is to harness the power of language models like Claude to perform processing on official legal content via Légifrance, and eventually, other public databases like the RNE, the BODACC, etc. The initial results are very promising and help overcome some of the limitations of the traditional statistical research offered by Légifrance. The service is continuously improving, but you can already see some examples of research below.

The server supports the following features:

  • Search in legal texts (laws, ordinances, decrees, orders)
  • Consultation of articles of French legal codes
  • Research in judicial case law

The other Legifrance funds will soon be implemented.

If you want to directly access the Legifrance API to connect your own MCP server, click here: https://lab.dassignies.law or linkedin

Prerequisites

  • Python 3.9+
  • API key for Legifrance (obtainable from lab.dassignies.law )
  • A model compatible with the MCP protocol (like Claude desktop)

Facility

  1. Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # Sur Windows: venv\Scripts\activate
uv venv .venv source .venv/bin/activate # Sur Windows: venv\Scripts\activate
  1. Install via pip:
pip install git+https://github.com/rdassignies/mcp-server-legifrance.git
  1. Install via UV
uv pip install git+https://github.com/rdassignies/mcp-server-legifrance.git
  1. Create a .env file at the root of the project with your credentials:
LAB_DASSIGNIES_API_KEY=votre_clé_api LEGAL_API_URL=https://lab.dassignies.law/api/ # ou l'URL correspondante

Use

Integration with Claude

This is the "simplest" integration.

  1. Use the following configuration file to integrate the MCP server into Claude Desktop. To find this file, go to Settings > Developer > Edit Configuration (links to the configuration file in .json format).

There is also a command line procedure via uv which will be documented later.

Here is an example of use:

{ "mcpServers": { "legifrance": { "command": "<CHEMIN_VERS_VOTRE_REP>/mcp-server-legifrance/venv/bin/python", "args": [ "<CHEMIN_VERS_VOTRE_REP>/mcp-server-legifrance/src/server.py" ] } } }
  1. Start Claude desktop, you should see tool icons appear:

Available tools

Search for articles in legal texts (laws, ordinances, decrees, orders).

Settings:

  • text_id : Text identifier (e.g. "78-17" for the Data Protection Act)
  • search : Keywords or article number
  • field : Search zone ("ALL", "TITLE", "TABLE", "NUM_ARTICLE", "ARTICLE")
  • search_type : Search mode ("ALL_WORDS_IN_A_FIELD", "EXACT_EXPRESSION", "AT_LEAST_ONE_WORD")
  • page_size : Number of results (max 100)

For details, see https://lab.dassignies.law/api/docs

Example: To search for article 7 of law 78-17:

{ "text_id": "78-17", "search": "7", "champ": "NUM_ARTICLE" }

2. search_code

Search for articles in French legal codes.

For example: "Write me a summary on the legal regime of the PACS"

Settings:

  • search : Search terms
  • code_name : Name of the code (e.g. "Civil Code", "Labor Code")
  • field : Search area
  • sort : Sorting results
  • search_type : Search mode
  • page_size : Number of results
  • fetch_all : Whether all results should be fetched

Example: To search for information on PACS in the Civil Code, the language model will send the following query:

{ "search": "pacte civil de solidarité", "code_name": "Code civil" }

For details, see https://lab.dassignies.law/api/docs

3. search_judicial_case law

Search the judicial case law database. You can use the power of language models to search for case law directly in Legifrance.

Example 1 Overview of the latest news articles on a particular theme (e.g. "Find me the latest news articles on the sudden breakdown of established commercial relations and write me a summary table").

Example 2 From a particular known decision (appeal number 23-23.382), we can carry out analyses in stages:

  1. We find the stop and Claude generates the stop sheet
  2. He is asked to extract the articles in question and find them in Legifrance
  3. He is asked to find similar jp
  4. etc ...

Settings:

  • search : Terms or case number
  • publication_bulletin : Whether published in the bulletin ["T"] or not ["F"]
  • sort : Sorting results
  • field : Search area
  • search_type : Search mode
  • page_size : Number of results
  • fetch_all : Whether all results should be fetched
  • juri_keys : Response fields to extract
  • judicial_jurisdiction : List of jurisdictions

For details, see https://lab.dassignies.law/api/docs

Predefined prompts

The server can include predefined prompts to facilitate use. Currently, only one prompt has been implemented as an example. It is possible to implement much more detailed prompts, particularly for performing deep search operations or extracting from multiple documents.

Creates an expert legal agent who:

  • Systematically cite your sources
  • Uses relevant tools to search for information
  • Provides step-by-step analysis
  • Includes official links to legal texts

Use:

# Exemple d'utilisation du prompt prédéfini response = client.messages.create( model="claude-3-opus-20240229", max_tokens=1000, tools=tools, messages=[ { "role": "user", "content": [ { "type": "tool_use", "id": "prompt_use_1", "name": "legifrance.get_prompt", "input": { "prompt_name": "agent_juridique_expert", "inputs": { "question": "Quelles sont les conditions de validité d'un contrat de mariage?" } } } ] } ] )

Limitations

  • Requests are limited to 10 per second to comply with API limits
  • An internet connection is required to access the legal bases
  • The server does not cache results, each request queries the API

Contribution

Contributions are welcome! Please open an issue or submit a pull request for any improvements or fixes.

License

MIT License

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

A server implementing the Model Context Protocol to allow direct access to French legal resources (laws, codes, case law) from compatible Large Language Models like Claude, enabling interactive legal research through the Legifrance API.

  1. Description
    1. Qu'est-ce que le MCP ?
    2. L'interopérabilité via MCP
    3. mcp-server-legifrance ?
  2. Prérequis
    1. Installation
      1. Utilisation
        1. Intégration avec Claude
      2. Outils disponibles
        1. 1. rechercher_dans_texte_legal
        2. 2. rechercher_code
        3. 3. rechercher_jurisprudence_judiciaire
      3. Prompts prédéfinis
        1. agent_juridique_expert
      4. Limitations
        1. Contribution
          1. Licence

            Related MCP Servers

            • A
              security
              F
              license
              A
              quality
              A Model Context Protocol server that enables AI assistants like Claude to access and search Atlassian Confluence content, allowing integration with your organization's knowledge base.
              Last updated -
              5
              328
              3
              TypeScript
              • Apple
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol server that enables Large Language Models to access and interact with database connections, including viewing schemas and performing CRUD operations on connected databases.
              Last updated -
              TypeScript
              • Apple
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol server that enables Claude to interact with your Todoist account, allowing you to manage tasks, projects, and labels through natural language.
              Last updated -
              1
              Python
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol Server that enables language models to access and manipulate Readwise documents and highlights programmatically.
              Last updated -
              2
              Python

            View all related MCP servers

            ID: pwyfvagys5