legal-contract-mcp
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-contract-mcp Can you load the NDA at tests/sample_contracts/weak_nda.txt and flag risky clauses?"
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-contract-mcp
An MCP (Model Context Protocol) server that gives an LLM client (Claude, Claude Code, Claude Desktop, etc.) tools to do a first-pass review of contracts: load a .txt/.docx/.pdf, detect standard clause types, flag heuristic risk issues, generate a summary, and diff two contracts against each other.
This is not legal advice — it's a rules-based first pass meant to speed up human review, built to demonstrate a real, non-trivial MCP server (as opposed to a toy "add two numbers" example).
Why this exists
Most MCP server examples are thin wrappers around an API call. This one does actual work locally:
Parses real document formats (txt/docx/pdf)
Detects 12 standard clause types via a maintained pattern library, not a single regex
Runs 8 explainable risk heuristics (e.g. indemnification without a liability cap, auto-renewal without a clear notice period, non-competes with no defined scope) — every flag cites the exact clause text it's based on
Falls back gracefully to an extractive summary if no
OPENAI_API_KEYis set, and upgrades to an LLM-generated summary if one is
Related MCP server: Contract Review AI MCP
Tools exposed
Tool | Description |
| Load a |
| List contracts loaded in this session |
| Detected clause types with snippets |
| Standard clause types NOT found — gap check |
| Heuristic risk flags with severity + evidence |
| Plain-English summary (LLM or extractive fallback) |
| Diff clause types and risk flags between two contracts |
| Look up a clause type's definition by keyword |
Setup
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"Optional — enable LLM-powered summaries:
export OPENAI_API_KEY=sk-ant-...Run it
Inspector (interactive dev UI):
mcp dev src/legal_contract_mcp/server.pyAs a stdio server (for Claude Desktop / Claude Code config):
{
"mcpServers": {
"legal-contract-mcp": {
"command": "python",
"args": ["-m", "legal_contract_mcp.server"],
"cwd": "/absolute/path/to/legal-contract-mcp",
"env": { "OPENAI_API_KEY": "sk-ant-..." }
}
}
}Then in a chat with the connected client:
Load the contract at tests/sample_contracts/weak_nda.txt and flag its risks.
Test
pytest # unit tests for clause detection + risk rules
python scripts/smoke_test.py # spins up the real MCP server over stdio and calls every toolIncludes two sample contracts (tests/sample_contracts/weak_nda.txt and solid_msa.txt) chosen so the risk engine's output differs meaningfully between a weak and a well-drafted agreement — tests assert on that difference, not just "does it run."
Project structure
src/legal_contract_mcp/
parsing.py # txt/docx/pdf -> plain text, in-memory doc store
clause_library.py # 12 clause types: definitions + detection patterns
clauses.py # runs the library against a document
risk_rules.py # 8 heuristic risk rules, each with cited evidence
llm.py # optional Claude-powered summary, extractive fallback
server.py # FastMCP tool definitions
tests/
sample_contracts/ # weak NDA vs. solid MSA fixtures
test_clauses_and_risks.pyExtending it
Add a clause type: add an entry to
CLAUSE_LIBRARYinclause_library.pywith a definition and one or more regex patterns.Add a risk rule: add a function block to
evaluate_risks()inrisk_rules.py— return aRiskFlagwithrule,severity,message, andevidence.Swap the in-memory store in
parsing.pyfor a database if you want documents to persist across server restarts.
Disclaimer
This tool provides automated, heuristic pattern-matching only. It is not a substitute for review by a licensed attorney and should not be relied on as legal advice.
Available Tools
8 toolscompare_contractsA
Compare two loaded contracts: which clause types each one has that the other lacks, and how their risk flags differ.
Args: doc_id_a: doc_id of the first contract. doc_id_b: doc_id of the second contract.
Inputs: doc_id_a (required), doc_id_b (required).
extract_clausesA
Detect standard clause types (indemnification, termination, IP, etc.) present in a loaded contract, with a text snippet for each.
Args: doc_id: doc_id returned by load_contract.
Inputs: doc_id (required).
flag_risksA
Run heuristic risk rules against a loaded contract (e.g. uncapped liability, auto-renewal without notice, one-sided termination) and return the flags with severity and supporting evidence.
Args: doc_id: doc_id returned by load_contract.
Inputs: doc_id (required).
list_documentsA
List all contracts currently loaded into this server's session.
Inputs: no named parameters.
load_contractB
Load a contract file (.txt, .docx, or .pdf) from disk and return its doc_id.
Args: path: Absolute or relative path to the contract file.
Inputs: path (required).
missing_clausesA
List standard clause types from the reference library that were NOT found in a loaded contract — useful for spotting gaps.
Args: doc_id: doc_id returned by load_contract.
Inputs: doc_id (required).
search_clause_libraryA
Search the reference library of standard clause types by keyword, e.g. 'liability' or 'renewal', and get plain-English definitions.
Args: query: Free-text search term.
Inputs: query (required).
summarize_contractA
Summarize a loaded contract in plain English and list the top things a reviewer should double check. Uses Claude if ANTHROPIC_API_KEY is set in the server environment, otherwise falls back to an extractive summary built from detected clauses and risk flags.
Args: doc_id: doc_id returned by load_contract.
Inputs: doc_id (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose: loading, listing, extracting clauses, flagging risks, summarizing, comparing, gap analysis, and library search. There is no meaningful overlap between tool responsibilities.
Most tools follow a consistent snake_case verb_noun pattern like load_contract, extract_clauses, and compare_contracts. The one minor deviation is missing_clauses, which is not in an imperative verb form.
With 8 tools, the server is well-scoped for contract analysis. Each tool covers a distinct part of the workflow without redundancy or bloat.
The core analysis workflow is well covered: load, extract, flag, summarize, compare, and check missing clauses. Minor gaps exist such as no tool for unloading documents or retrieving raw full contract text, but agents can work around these.
Related MCP Connectors
B2B, GovCon & LegalTech MCP server for live RFPs, contract parsing, compliance & proposal tools.
MCP server for VC pitch-deck scoring, thesis-fit matching, and deal-flow management.
Document-to-Markdown MCP server — convert PDF, Office and HTML into LLM-ready Markdown.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn enterprise-grade MCP server that provides specialized tools for legal reasoning and analysis, automatically detecting legal domains and offering domain-specific guidance, templates, and citation formatting.333ISC

Contract Review AI MCPofficial
AlicenseNot gradedqualityCmaintenanceContract Review AI - MCP server providing AI-powered tools and automation by MEOK AI Labs4 npm2MIT- AlicenseNot gradedqualityCmaintenanceLegal Document AI - MCP server providing AI-powered tools and automation by MEOK AI Labs2 npmMIT
- FlicenseNot gradedqualityDmaintenanceMCP server that analyzes legal documents, extracts key clauses, identifies risks, and summarizes contracts. 8 tools for AI agents needing legal document intelligence.-