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-服务器-legifrance

MCP模型上下文协议服务器允许通过兼容 LLM(例如 Claude)中的 Legifrance API 查询法国法律基础。

描述

该项目实现了一个 MCP 服务器,可直接从大型语言模型访问法国法律资源(法律文本、法典、判例法)。它通过交互式工具使 Legifrance 数据可访问,从而促进法律研究。

在创建pylegifrance包之后,这是必要的。

什么是 MCP?

模型上下文协议 (MCP) 是由 Anthropic 开发的标准化协议,允许像 Claude 这样的语言模型以结构化的方式与外部工具和服务进行交互。这是 LLM 互操作性向前迈出的令人兴奋的一步,因为它建立了在模型和第三方 API 之间交换数据和执行功能的通用框架。到目前为止,有必要为每项服务开发特定的函数调用。

通过 MCP 实现互操作性

MCP 的重要性在于它能够在 LLM 和外部系统之间创建标准化接口。这种标准化有几个优点:

  1. 模块化架构:开发人员可以创建专用工具,轻松与不同协议兼容的 LLM 集成。
  2. 提高安全性:MCP 将模型访问限制为仅明确定义的特征,从而降低安全风险。
  3. 简化维护:可以独立于模型对外部工具进行更新,从而促进系统发展。
  4. 能力扩展:LLM 可以访问实时数据并执行他们无法单独执行的复杂操作。

mcp-server-legifrance?

这个想法是利用 Claude 等语言模型的强大功能,通过 Légifrance 对官方法律内容进行处理,并最终通过其他公共数据库(如 RNE、BODACC 等)进行处理。初步结果非常有希望,并有可能克服 Légifrance 提出的经典统计研究的某些局限性。该服务正在不断改进,但您已经可以在下面看到一些示例搜索。

该服务器支持以下功能:

  • 在法律文本中搜索(法律、条例、法令、命令)
  • 法国法律法规条款的咨询
  • 司法案例法研究

Legifrance 的其他基金也将很快实施。

如果您想直接访问 Legifrance API 来连接您自己的 MCP 服务器,请点击这里: https://lab.dassignies.lawlinkedin

先决条件

  • Python 3.9+
  • Legifrance 的 API 密钥(可从lab.dassignies.law获取)
  • 与MCP协议兼容的模型(例如Claude桌面)

设施

  1. 创建虚拟环境并激活它:
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. 通过 pip 安装:
pip install git+https://github.com/rdassignies/mcp-server-legifrance.git
  1. 通过 UV 安装
uv pip install git+https://github.com/rdassignies/mcp-server-legifrance.git
  1. 使用您的凭据在项目根目录创建一个.env文件:
LAB_DASSIGNIES_API_KEY=votre_clé_api LEGAL_API_URL=https://lab.dassignies.law/api/ # ou l'URL correspondante

使用

与克劳德的整合

这是“最简单”的集成。

  1. 使用以下配置文件将 MCP 服务器集成到 Claude Desktop。要找到此文件,请转到设置>开发人员>编辑配置(链接到.json 格式的配置文件)。

还有一个通过 uv 的命令行程序,稍后将记录。

以下是使用示例:

{ "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. 启动 Claude 桌面,您应该会看到工具图标出现:

可用工具

1. 在法律文本中搜索

搜索法律文本(法律、条例、法令、命令)中的文章。

设置:

  • text_id :文本标识符(例如,“78-17”代表数据保护法)
  • 搜索:关键字或文章编号
  • 字段:搜索区域(“ALL”、“TITLE”、“TABLE”、“NUM_ARTICLE”、“ARTICLE”)
  • search_type :搜索模式(“ALL_WORDS_IN_A_FIELD”、“EXACT_EXPRESSION”、“AT_LEAST_ONE_WORD”)
  • page_size :结果数量(最多 100 条)

有关详细信息,请参阅https://lab.dassignies.law/api/docs

**例如:**搜索法律 78-17 第 7 条:

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

2. 搜索代码

搜索法国法律法规中的文章。

例如。 “请给我写一份关于 PACS 法律制度的摘要”

设置:

  • 搜索:搜索词
  • code_name :代码名称(例如“民法典”、“劳动法典”)
  • field :搜索区域
  • sort :对结果进行排序
  • search_type :搜索模式
  • page_size :结果数量
  • fetch_all :是否应获取所有结果

**例如:**要在民法典中搜索有关 PACS 的信息,语言模型将发送以下查询:

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

有关详细信息,请参阅https://lab.dassignies.law/api/docs

3. 搜索司法案例

搜索司法案例数据库。我们可以利用语言模型的力量直接在 Legifrance 中搜索判例法。

示例 1某一主题的最新新闻文章概述(例如,“找出有关既定商业关系突然破裂的最新新闻文章并写一份摘要表给我”)。

例2从某已知判决(上诉编号23-23.382)中,我们可以分阶段进行分析:

  1. 我们找到站点,Claude 生成站点表
  2. 他被要求提取相关物品并在 Legifrance 中找到它们
  3. 他被要求寻找类似的jp
  4. ETC ...

设置:

  • 搜索:条款或案件编号
  • publication_bulletin :是否在公告中发布 ["T"] 或未发布 ["F"]
  • sort :对结果进行排序
  • field :搜索区域
  • search_type :搜索模式
  • page_size :结果数量
  • fetch_all :是否应获取所有结果
  • juri_keys :要提取的响应字段
  • 司法管辖区:司法管辖区列表

有关详细信息,请参阅https://lab.dassignies.law/api/docs

预定义提示

服务器可能包括预定义的提示以方便使用。到目前为止,仅实现了一个提示作为示例。可以设置更详细的提示,特别是在多个文档中执行深度搜索操作或提取......

专家法律代理人

创建一位专业的法律代理人:

  • 系统地引用你的资料来源
  • 使用相关工具搜索信息
  • 提供逐步分析
  • 包含法律文本的官方链接

使用:

# 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?" } } } ] } ] )

限制

  • 为了符合 API 限制,请求数限制为每秒 10 个
  • 需要互联网连接才能访问法律基础
  • 服务器不缓存结果,每个请求都会查询 API

贡献

欢迎投稿!请打开问题或提交拉取请求以获取任何改进或修复。

执照

MIT 许可证

-
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.

实现模型上下文协议的服务器允许从兼容的大型语言模型(如 Claude)直接访问法国法律资源(法律、法典、判例法),从而能够通过 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