MCP DJEN服务器
面向法学硕士的巴西智能法庭通知
一个生产就绪的MCP(模型上下文协议)服务器,用于标准化LLM代理和AI应用程序对巴西电子司法日记(DJEN)数据的访问。
🎯 现实世界影响
此服务器为 亲密 Pro 系统,处理 566条通知 (测试期)包括:
- 准确率86.7% 在综合回归测试(v1.5)中
- **\ *“今天的传票是什么?”* → LLM → MCP服务器→ 结构化响应
这个MCP服务器是实现这一愿景的基础设施层。
🏗️ 建筑
流量:
- 法学硕士代理人要求法院通知
- MCP服务器查询DJEN API
- 数据被解析和标准化
- 结构化JSON返回LLM
🚀 快速开始
先决条件
- Python 3.11+
- Docker(可选)
- Git
地方发展设置
# Clone repository
git clone https://github.com/PdroBrandao/mcp-djen-server.git
cd mcp-djen-server
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set environment variables
cp .env.example .env
# Edit .env with your configuration
# Run server
python3 -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Docker设置
# Build and run with Docker
docker-compose up --build
# Or build manually
docker build -t mcp-djen-server .
docker run -p 8000:8000 mcp-djen-server环境变量
# Server Configuration
PORT=8000
HOST=0.0.0.0
DEBUG=false
# DJEN API Configuration
DJEN_API_BASE_URL=https://comunicaapi.pje.jus.br/api/v1/comunicacao
DJEN_API_TIMEOUT=30
# Rate Limiting
RATE_LIMIT_PER_MINUTE=100
RATE_LIMIT_PER_HOUR=1000
# Logging
LOG_LEVEL=INFO
LOG_FILE=logs/app.log
# Security
CORS_ORIGINS=*
API_KEY_REQUIRED=false🧪 测试
自动化测试
# Run all tests
python3 test_server.py
# Test specific endpoints
curl -X GET "http://localhost:8000/health"
curl -X GET "http://localhost:8000/intimations?name=PEDRO%20BRAND%C3%83O&date_start=2025-08-01&date_end=2025-08-06"手动测试
# Health check
curl http://localhost:8000/health
# Get notifications
curl "http://localhost:8000/intimations?name=PEDRO%20BRAND%C3%83O&date_start=2025-08-01&date_end=2025-08-06"
# Get case details
curl http://localhost:8000/intimations/1234567-89.2024.8.13.0001
# Get available courts
curl http://localhost:8000/courts📚 api参考
认证
目前,API已开放供开发。生产部署应实施:
- API密钥验证
- 每位客户的费率限制
- 请求日志记录和监控
端点
GET/健康
健康检查端点。
答复:
{
"status": "healthy",
"timestamp": "2025-08-06T17:48:25.231962",
"service": "mcp-djen-server"
}获取/提示
为律师检索法庭通知。
参数:
name(必填):律师全名date_start(必填):开始日期(YYYY-MM-DD)date_end(必填):结束日期(YYYY-MM-DD)oab(可选):OAB注册号
答复:
[
{
"date": "2025-08-06",
"court": "TJMG",
"lawyer_name": "PEDRO BRANDÃO",
"oab": "123456/MG",
"case_number": "1234567-89.2024.8.13.0001",
"type": "TOMAR_CIÊNCIA",
"summary": "Intimação para ciência de despacho proferido em 05/08/2025",
"url": "https://www.tjmg.jus.br/djen/123",
"deadline": "15 days",
"actions": ["MANIFESTAR_SE", "CALCULAR_PRAZO"]
}
]获取/通知/{case_number}
获取特定案例的详细信息。
GET/法院
获取可用法院列表。
🤖 LLM集成示例
OpenAI函数调用
import openai
import requests
# Configure OpenAI
openai.api_key = "your-api-key"
# Define the function
functions = [
{
"name": "get_court_notifications",
"description": "Get court notifications for a lawyer",
"parameters": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Lawyer's full name"
},
"date_start": {
"type": "string",
"description": "Start date (YYYY-MM-DD)"
},
"date_end": {
"type": "string",
"description": "End date (YYYY-MM-DD)"
}
},
"required": ["name", "date_start", "date_end"]
}
}
]
# User query
user_query = "Quais são as intimações do PEDRO BRANDÃO para hoje?"
# Call OpenAI
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": user_query}],
functions=functions,
function_call="auto"
)
# Extract function call
if response.choices[0].message.function_call:
function_call = response.choices[0].message.function_call
# Call MCP Server
mcp_response = requests.get(
"https://your-mcp-server.railway.app/intimations",
params=json.loads(function_call.arguments)
)
notifications = mcp_response.json()
print(f"Found {len(notifications)} notifications for PEDRO BRANDÃO")克劳德集成
import anthropic
import requests
client = anthropic.Anthropic(api_key="your-api-key")
# Define tool
tools = [
{
"name": "get_court_notifications",
"description": "Get court notifications for a lawyer",
"input_schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"date_start": {"type": "string"},
"date_end": {"type": "string"}
},
"required": ["name", "date_start", "date_end"]
}
}
]
# Call Claude
response = client.messages.create(
model="claude-3-sonnet-20240229",
max_tokens=1000,
messages=[{"role": "user", "content": "Quais são as intimações do PEDRO BRANDÃO para hoje?"}],
tools=tools
)📊 数据结构
输入(DJEN API)
{
"siglaTribunal": "TJMG",
"texto": "PEDRO BRANDÃO",
"dataDisponibilizacaoInicio": "2025-08-01",
"dataDisponibilizacaoFim": "2025-08-06"
}输出(MCP服务器)
[
{
"date": "2025-08-06",
"court": "TJMG",
"lawyer_name": "PEDRO BRANDÃO",
"oab": "123456/MG",
"case_number": "1234567-89.2024.8.13.0001",
"type": "TOMAR_CIÊNCIA",
"summary": "Intimação para ciência de despacho proferido em 05/08/2025",
"url": "https://www.tjmg.jus.br/djen/123",
"deadline": "15 days",
"actions": ["MANIFESTAR_SE", "CALCULAR_PRAZO"]
}
]🔧 技术细节
性能指标
- 响应时间: 平均\ 中期目标是将该系统转变为巴西领先的法律情报平台,律师可以通过WhatsApp使用自然语言访问案件的全部状态、截止日期和细节。其愿景是发展成为一个自主的法律代理人,具有集成的RAG和自我评估功能,能够在没有人为验证标准通知的情况下以98%以上的准确率运行。
该MCP服务器是实现这一愿景的基础设施,通过标准化LLM代理人对巴西法院数据的访问。
🤝 贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详情。
开发设置
# Fork and clone
git clone https://github.com/your-username/mcp-djen-server.git
cd mcp-djen-server
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest
# Run linting
flake8 app/
black app/代码规范
- 类型提示: 所有功能都需要
- 文档字符串 : 谷歌风格
- 测验: 90%+覆盖率
- Linting: 零警告
💼 业务影响
法律团队
- 节省时间: 将人工检查从每天30分钟减少到每天3分钟
- 准确度: 综合回归测试中为86.7%
- 顺从: 自动化审计跟踪
- 成本: 仅需0.45美元/律师/月(非常积极的投资回报率)
实际生产数据(2025年6月至7月)
| 度量 | 值 | 周期 |
|---|---|---|
| 平均成本/律师 | 每月0.45美元 | 过去30天 |
| 总分析 | 566 | 测试期 |
| 平均代币/分析 | 5217 | 每位律师 |
| 每次分析成本 | $0.0029 | 平均值 |
面向AI开发人员
- 标准化接口: 一致的API设计
- 生产就绪: 久经考验的可靠性
- 文档: 综合指南
- 技术支持: 活跃社区
对于LegalTech公司
- 集成: 易于LLM集成
- 定制: 灵活的体系结构
- 技术支持: 专业咨询
- 合作伙伴关系: 收入分享机会
📞 联系
- 作者 佩德罗 布兰登
- 电子邮件: hi@pdrobrandao.com
- 网站: https://www.pdrobrandao.com
- 领英: 佩德罗 布兰登
- github: @PdroBrandoo
- 亲密Pro: 仓库
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
______________________________________________________________________
内置于❤️ 巴西法律界
