Legal Document RAG MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Legal Document RAG MCP Serversearch for non-compete clauses in kontrak_jual_beli.pdf"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Legal Document RAG — MCP Server
Fully local, offline RAG system for legal documents (Indonesian + English).
Built on MCP SDK, ChromaDB, SQLite FTS5, and multilingual-e5-large.
Requirements
Python ≥ 3.11
Tesseract OCR with Indonesian language pack:
# Ubuntu / Debian sudo apt install tesseract-ocr tesseract-ocr-ind # macOS brew install tesseract brew install tesseract-lang # includes ind
Related MCP server: Legal MCP
Setup
# 1. Clone / copy the project
cd legal_rag_mcp
# 2. Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. (First run) The multilingual-e5-large model (~2.2 GB) will be
# downloaded automatically to ~/.cache/huggingface/hub
# All subsequent runs are fully offline.Usage
Drop documents in the watch folder
legal_rag_mcp/raw_legal_docs/
├── kontrak_jual_beli.pdf
├── perjanjian_kerjasama.docx
├── schedule_of_fees.xlsx
└── scanned_addendum.pngLaunch the MCP server
# Development mode (with MCP Inspector UI)
mcp dev mcp_server/server.py
# Production mode (stdio, for Claude Desktop or any MCP client)
python mcp_server/server.pyClaude Desktop configuration (claude_desktop_config.json)
{
"mcpServers": {
"legal-rag": {
"command": "python",
"args": ["/absolute/path/to/legal_rag_mcp/mcp_server/server.py"]
}
}
}Tools Exposed
Tool | Purpose |
| Hybrid semantic + keyword search |
| Cross-document conflict detection (two-zone thresholds) |
| Document metadata + clause outline |
| Read a clause in full surrounding context |
| Inventory of all ingested files |
Conflict Detection Thresholds
Zone | Cosine Similarity | Interpretation |
Near-duplicate | > 0.88 | Same clause — skip |
HIGH suspicion | 0.75 – 0.88 | Same topic, different obligations |
MODERATE suspicion | 0.60 – 0.75 | Related topic, may diverge |
Unrelated | < 0.60 | Different provisions |
Thresholds are configurable in config.py.
Re-ingestion (Diff-Based)
When a file in raw_legal_docs/ is modified:
File-level SHA-256 hash is compared against the stored hash.
If unchanged → skip entirely.
If changed → re-chunk the document, compute per-chunk hashes.
Only changed or new chunks are re-embedded and upserted.
Orphaned chunks (present in old version, absent in new) are deleted.
Full re-embedding is never triggered by a partial change.
This server cannot be deployed
Maintenance
Related MCP Connectors
Task-oriented MCP for Indonesian law: search, resolve citations, read laws, and MK decisions.
LawOracle — 20 legal AI tools: case law search, contracts, EU regulations, citation graph.
Search U.S. case law, fetch opinions, and ask matter-aware legal questions over your documents.
Resolve, search and verify legal citations against the official sources, with provenance.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables users to search, retrieve, and validate over 11,000 Philippine statutes and nearly 100,000 provisions through AI-powered legal research tools. It supports full-text search across Republic Acts, the Constitution, and various codes while providing cross-referencing and international law alignment capabilities.1-
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to search and analyze German legal texts using vector embeddings and semantic search.89MIT
- AlicenseNot gradedqualityCmaintenanceEnables semantic search over Polish court judgments and legislative acts via MCP. Allows LLMs to retrieve legal documents using natural language queries.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to search, retrieve, and verify Indonesian laws (UU, PP, Perpres, etc.) and Constitutional Court decisions from authoritative sources with pasal-level granularity and citation-ready grounding.1AGPL 3.0