Legal Analysis
БесплатноНе проверенLegal document analysis pipeline with contract review, citation validation, and governance scoring.
Описание
Legal document analysis pipeline with contract review, citation validation, and governance scoring.
README
Build MCP AI Agents for Legal — Dr. Maryam Miradi's 5-step framework, fully implemented.
AI-powered legal document analysis pipeline: parse → understand → generate → audit → route. One MCP server, reusable from LangGraph, CrewAI, and Google ADK.
Legal PDF
│
▼
Step 1: Scope/Objective
LegalAgentState initialised (confidence=0, escalation=True, validated=False)
Document type check: accept contracts/agreements/NDAs/leases/employment
Reject: invoices, scripts, unknown → escalate immediately
│
▼
Step 2: Ground/Observe
Run all 4 PDF parsers, pick highest score:
PyPDF (85%) → PDFPlumber (90%) → LlamaIndex (88%) → Docling (92%) ✓
Build surface map: what the document CAN and CANNOT answer
Label each topic: DECISIVE / INFORMATIVE / IGNORE
│
▼
Step 3: Logic/Input → Generator Agent
Extract: clauses, obligations, key dates, risk flags, governing law
Uses extended thinking (xhigh) — Claude Sonnet
│
▼
Step 4: Assembly/Execute → Auditor Agent
Verify every citation exists in the source document
Check required compliance clauses per document type
Produce audit score (0–1) and compliance gap report
│
▼
Step 4b: Router Agent
APPROVED → confidence ≥ 70% AND audit passed
REGENERATE → audit failed, regeneration budget remaining (max 2 attempts)
ESCALATE → max regenerations hit, low confidence, or unsupported type
│
▼
Step 5: Deploy/Reuse — MCP Server
extract_legal_document() → full pipeline
check_document_quality_tool() → fast quality gate
validate_legal_citation_tool() → citation existence check
analyze_contract_with_governance() → full + governance rules
legal_analysis_workflow (prompt) → workflow prompt for any LLM framework
Quick Start
pip install -e .
cp .env.example .env # set ANTHROPIC_API_KEY
# Run demo with a synthetic contract (no PDF needed)
legal-agent demo
# Analyze a real PDF
legal-agent analyze contract.pdf
# Quality gate (fast, no LLM)
legal-agent quality contract.pdf
# With governance rules
legal-agent analyze nda.pdf --governance "GDPR compliance, data retention, right to audit"
# HTTP API
legal-agent serve
# → http://localhost:8000/docs
# MCP server (for LangGraph / CrewAI / Google ADK)
pip install -e ".[mcp]"
legal-agent mcp-server
PDF Parsers
| Parser | OCR Confidence | Notes |
|---|---|---|
| PyPDF | 85% | Built-in fallback, always available |
| PDFPlumber | 90% | Highest word count, great for tables |
| LlamaIndex | 88% | pip install -e "[llama]" |
| Docling (IBM) | 92% | Recommended — pip install -e "[docling]" |
All four run in parallel. The highest confidence × word_count score wins.
LegalAgentState
from legal_agent import LegalAgentState
# Fail-safe defaults (Dr. Miradi's pattern)
state = LegalAgentState(
confidence=0.0, # no trust until measured
escalation=True, # escalate to human by default
validated=False, # not valid until Auditor passes
)
Accepted Document Types
| Type | Accepted | Required Clauses Checked |
|---|---|---|
| Contract | ✅ | governing_law, termination, liability_limitation, payment_terms |
| Agreement | ✅ | governing_law, termination, dispute_resolution |
| NDA | ✅ | confidentiality_scope, term, return_of_information |
| Lease | ✅ | rent_amount, lease_term, security_deposit |
| Employment | ✅ | compensation, termination, non_compete |
| Invoice | ❌ | Rejected — escalated immediately |
| Script | ❌ | Rejected — escalated immediately |
| Unknown | ❌ | Rejected — escalated immediately |
MCP Tools (reusable across LangGraph / CrewAI / Google ADK)
# Any framework calls the same MCP server
@mcp.tool()
async def extract_legal_document(file_path: str) -> str: ...
@mcp.tool()
def check_document_quality_tool(file_path: str) -> str: ...
@mcp.tool()
def validate_legal_citation_tool(document_text: str, citation: str) -> str: ...
@mcp.tool()
async def analyze_contract_with_governance(file_path: str, governance_rules: str) -> str: ...
Built With
- Anthropic Claude — Generator (extended thinking) + Auditor + surface map
- Docling (IBM) — best-in-class PDF parsing (92% OCR confidence)
- PDFPlumber — table-aware PDF extraction
- FastMCP — MCP server
- FastAPI + uvicorn — HTTP API
- Rich — terminal UI
Based on Dr. Maryam Miradi's framework: www.maryammiradi.com
Установка Legal Analysis
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/jaykimproject/legal-mcp-agentFAQ
Legal Analysis MCP бесплатный?
Да, Legal Analysis MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Legal Analysis?
Нет, Legal Analysis работает без API-ключей и переменных окружения.
Legal Analysis — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Legal Analysis в Claude Desktop, Claude Code или Cursor?
Открой Legal Analysis на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
GitHub
PRs, issues, code search, CI status
автор: GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
автор: mcpdotdirectCompare Legal Analysis with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development
