Cerebra Legal MCP 服务器
基于Anthropic 工程博客中的“思考”工具概念,用于法律推理和分析的企业级 MCP 服务器。
概述
Cerebra Legal 提供了三种强大的法律推理和分析工具:
- legal_think - 一种结构化的法律推理工具,可帮助通过特定领域的指导和模板分析复杂的法律问题。
- legal_ask_followup_question - 一种专门用于在法律背景下提出后续问题的工具,具有特定领域的选项。
- legal_attempt_completion - 一种以适当的结构和引用格式呈现法律分析结果的工具。
该服务器自动检测法律领域(ANSC 争议、消费者保护、合同分析)并提供特定领域的指导、模板和反馈。
特征
- 域检测:自动识别分析的合法域
- 特定领域指导:针对不同法律领域提供定制指导
- 结构化模板:提供特定领域的法律分析模板
- 引用格式:正确格式化法律引用
- 思维质量分析:提供法律推理质量的反馈
- 修订支持:允许修改以前的想法
安装
# Clone the repository
git clone https://github.com/yoda-digital/mcp-cerebra-legal-server.git
cd mcp-cerebra-legal-server
# Install dependencies
npm install
# Build the project
npm run build
用法
运行服务器
测试服务器
该存储库包括一个测试客户端,演示如何与服务器交互:
# Make the test client executable
chmod +x test-client.js
# Run the test client
./test-client.js
测试客户端将:
- 启动服务器
- 发送工具/列表请求以获取可用工具
- 发送带有示例想法的 legal_think 请求
- 显示服务器的响应
添加到克劳德
要将服务器添加到 Claude,请使用以下配置更新您的 MCP 设置文件:
对于 VSCode 扩展
编辑文件~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
:
{
"mcpServers": {
"cerebra-legal": {
"command": "node",
"args": ["/path/to/mcp-cerebra-legal-server/build/index.js"],
"disabled": false,
"alwaysAllow": []
}
}
}
对于克劳德桌面应用程序
编辑~/Library/Application Support/Claude/claude_desktop_config.json
(macOS) 或您平台上的等效文件:
{
"mcpServers": {
"cerebra-legal": {
"command": "node",
"args": ["/path/to/mcp-cerebra-legal-server/build/index.js"],
"disabled": false,
"alwaysAllow": []
}
}
}
使用 Claude 中的工具
将服务器添加到 Claude 后,您可以在对话中使用这些工具:
系统提示集成
为了使 AI 与这些法律工具实现最佳交互,必须在系统提示中包含适当的指导。这些工具遵循与标准 Cline 工具相同的 AI → 人机交互模型,但针对特定领域进行了增强。
系统提示应包括每个工具的详细文档:
## legal_think
Description: A structured legal reasoning tool that helps analyze complex legal issues with domain-specific guidance and templates. This tool enables step-by-step legal analysis with feedback on reasoning quality.
Parameters:
- thought: (required) The current legal reasoning step
- thoughtNumber: (required) Current thought number in sequence
- totalThoughts: (required) Estimated total thoughts needed
- nextThoughtNeeded: (required) Whether another thought step is needed
- category: (optional) Legal domain category (auto-detected if not provided)
- references: (optional) Array of legal references
- isRevision: (optional) Whether this revises previous thinking
- revisesThoughtNumber: (optional) Which thought is being reconsidered
- requestGuidance: (optional) Whether to request domain-specific guidance
- requestTemplate: (optional) Whether to request a domain-specific template
Usage:
<legal_think>
<thought>Your legal reasoning step here</thought>
<thoughtNumber>Current thought number</thoughtNumber>
<totalThoughts>Estimated total thoughts</totalThoughts>
<nextThoughtNeeded>true or false</nextThoughtNeeded>
<category>Legal domain (optional)</category>
<references>Array of references (optional)</references>
<isRevision>true or false (optional)</isRevision>
<revisesThoughtNumber>Thought number being revised (optional)</revisesThoughtNumber>
<requestGuidance>true or false (optional)</requestGuidance>
<requestTemplate>true or false (optional)</requestTemplate>
</legal_think>
## legal_ask_followup_question
Description: Ask the user a legal domain-specific question to gather additional information needed to complete the task. This tool enhances the standard ask_followup_question with legal domain detection, terminology formatting, and domain-specific suggested options.
Parameters:
- question: (required) The question to ask the user. This will be automatically enhanced with appropriate legal terminology.
- options: (optional) An array of 2-5 options for the user to choose from. If not provided, domain-specific options will be automatically suggested.
- context: (optional) Additional context to help with domain detection and question formatting.
Usage:
<legal_ask_followup_question>
<question>Your question here</question>
<options>
Array of options here (optional), e.g. ["Option 1", "Option 2", "Option 3"]
</options>
<context>Additional context to help with domain detection (optional)</context>
</legal_ask_followup_question>
## legal_attempt_completion
Description: Present the result of your work to the user with proper legal structure and formatting. This tool enhances the standard attempt_completion with legal domain detection, document structuring, and citation formatting.
Parameters:
- result: (required) The result of the task. This will be automatically formatted with proper legal structure.
- command: (optional) A CLI command to execute to show a live demo of the result to the user.
- context: (optional) Additional context to help with domain detection and result formatting.
Usage:
<legal_attempt_completion>
<result>
Your final result description here
</result>
<command>Command to demonstrate result (optional)</command>
<context>Additional context to help with domain detection (optional)</context>
</legal_attempt_completion>
本指南确保人工智能理解:
- 这些是标准工具的专门版本
- 它们保持相同的人工智能→人类交互流程
- 它们具有额外的功能和参数
- 如何正确格式化工具调用
如果没有这种指导,人工智能可能无法充分利用这些工具内置的特定领域功能。
1. 使用legal_think
legal_think工具可以帮助你以结构化的思维分析复杂的法律问题:
I need to analyze an ANSC contestation where a claimant argues that technical specifications in a tender were too restrictive.
Claude 将使用 legal_think 工具来:
- 检测合法领域(ANSC 争议)
- 提供特定领域的指导
- 提供结构化的分析模板
- 对法律推理的质量提供反馈
- 支持修改先前的想法
2. 使用legal_ask_followup_question
当克劳德需要更多信息来完成法律分析时:
What specific provisions of the technical specifications are being challenged?
Claude 将使用 legal_ask_followup_question 工具来:
- 使用适当的法律术语来格式化问题
- 提供特定领域的选项供用户选择
- 检测上下文感知提问的合法领域
3. 使用legal_attempt_completion
当克劳德准备提出最终的法律分析时:
Based on my analysis, the technical specifications requiring "minimum 5 years experience" appear disproportionate and likely violate Article 33(2) of Law 131/2015 on public procurement.
Claude 将使用 legal_attempt_completion 工具来执行以下操作:
- 用适当的法律结构格式化结论
- 提取并格式化法律引文
- 将分析组织成清晰的部分
- 提供专业的法律文件格式
工具输入模式
法律思考
{
"thought": "Analyzing ANSC contestation where claimant argues technical specifications were too restrictive.",
"thoughtNumber": 1,
"totalThoughts": 5,
"nextThoughtNeeded": true,
"category": "ansc_contestation", // Optional, auto-detected if not provided
"references": ["Law 131/2015", "ANSC Decision #12345"], // Optional
"isRevision": false, // Optional
"revisesThoughtNumber": null, // Optional
"requestGuidance": true, // Optional
"requestTemplate": true // Optional
}
法律问题
{
"question": "What specific provisions of the technical specifications are being challenged?",
"options": [ // Optional, auto-generated if not provided
"Are you challenging the experience requirements?",
"Are you challenging the technical capacity requirements?",
"Are you challenging the financial requirements?",
"Are you challenging the certification requirements?"
],
"context": "ANSC contestation regarding procurement of IT equipment" // Optional
}
合法尝试完成
{
"result": "Based on the analysis of ANSC contestation #12345, the technical specifications requiring 'minimum 5 years experience' appear disproportionate and likely violate Article 33(2) of Law 131/2015 on public procurement.",
"command": null, // Optional
"context": "ANSC contestation analysis" // Optional
}
建筑学
该服务器采用模块化架构构建:
- 域检测器:识别分析的合法域
- 法律知识库:提供特定领域的指导和模板
- 引用格式化程序:正确格式化法律引用
- 工具实现:处理每个工具的逻辑
发展
项目结构
mcp-cerebra-legal-server/
├── src/
│ ├── shared/ # Shared components
│ │ ├── DomainDetector.ts
│ │ ├── LegalKnowledgeBase.ts
│ │ ├── CitationFormatter.ts
│ │ └── types.ts
│ ├── tools/ # Tool implementations
│ │ ├── LegalThinkTool.ts
│ │ ├── LegalAskFollowupQuestionTool.ts
│ │ └── LegalAttemptCompletionTool.ts
│ ├── utils/ # Utilities
│ │ └── logger.ts
│ └── index.ts # Main server entry point
├── build/ # Compiled JavaScript
├── test-client.js # Test client
├── package.json
└── tsconfig.json
建筑
测试
# Run the test client
./test-client.js
存储库
该项目可在 GitHub 上找到: https://github.com/yoda-digital/mcp-cerebra-legal-server
参考
执照
麻省理工学院