Skip to main content
Glama

contract-key-terms-mcp

A small, read-only MCP server that finds contract clause types in plain-text agreements and shows why. It wraps a local sentence model trained on CUAD v1, the public contract dataset labelled by lawyers at The Atticus Project. The model covers CUAD's 36 clause types (assignment, governing law, termination for convenience, exclusivity, and so on). Everything runs on your machine, and the server makes no network calls.

Built by Wilshem Pennick, It Just Gets Better, L.L.C.

Demo: listing clause types, extracting key terms from a sample contract, and explaining one prediction

The GIF is rendered from the actual output of scripts/demo.py (an MCP client calling the three tools on a bundled sample), drawn frame by frame with Pillow by scripts/render_demo_gif.py. It is not a screen recording.

Not legal advice. Each result quotes what an agreement says and where. It does not say what a clause means, whether it is enforceable, or what follows when a clause is not found.

Tools

Tool

What it returns

list_clause_types()

The 36 CUAD clause types: key, plain label, CUAD category name, the model's threshold, and whether the model is used for that type

extract_key_terms(path)

For each clause type, whether the model found it and up to two sentences quoted as written, best first, each with its character offset and score

explain_prediction(path, clause_type)

The clause type's best sentences in that file, the words and word pairs that raised (and lowered) each score most, and the clause type's highest-weighted terms overall

For 3 of the 36 types the model's scores were too weak in training. list_clause_types marks them model_used: false, and extract_key_terms does not report them.

Related MCP server: BitsBound MCP Server

How the model works

Each sentence becomes word and word-pair TF-IDF features. Then one logistic regression per clause type gives a probability. A sentence at or above that type's threshold is reported. explain_prediction shows the arithmetic: each term's contribution is its weight times its TF-IDF value, and the contributions plus the intercept give the score. The model is read with the Python standard library alone, and its SHA-256 is checked before it loads.

The model holds no CUAD sentence or passage. It holds a vocabulary of 30,000 lower-case words and two-word pairs that each appear in at least two CUAD sentences (these can include names and numbers from the contracts), how common each is across those sentences, and, per clause type, weights learned from which sentences the dataset's lawyers labelled with that type; the labels for document name, parties and dates were not used.

This version reports the model alone. No accuracy figure is given for it yet.

Setup

You need uv and Python 3.11 or later.

git clone https://github.com/wilshem/contract-key-terms-mcp
cd contract-key-terms-mcp
uv sync
uv run pytest -q          # optional: run the tests

The server reads files from one folder only, set when it starts. By default that's the three bundled sample contracts. Pass --allow /path/to/folder (or set KEY_TERMS_ALLOWED_DIR) to point it at your own .txt or .md files.

To keep folders out even when they sit inside the allowed folder, list them in KEY_TERMS_DENY_DIRS, and list folder names to skip wherever they appear in KEY_TERMS_DENY_NAMES. Separate entries with : on Linux and macOS, or ; on Windows. Common key and credential folders (~/.ssh, ~/.aws and similar) are always refused. For example:

KEY_TERMS_DENY_DIRS="~/contracts/private:~/contracts/archive" KEY_TERMS_DENY_NAMES="drafts" \
  uv run contract-key-terms-mcp --allow ~/contracts

Claude Code

claude mcp add contract-key-terms -- uv run --directory /path/to/contract-key-terms-mcp contract-key-terms-mcp
# or, to read your own folder:
claude mcp add contract-key-terms -- uv run --directory /path/to/contract-key-terms-mcp contract-key-terms-mcp --allow /path/to/contracts
# with deny settings (claude mcp add -e sets the server's environment):
claude mcp add contract-key-terms -e KEY_TERMS_DENY_NAMES=drafts -- uv run --directory /path/to/contract-key-terms-mcp contract-key-terms-mcp --allow /path/to/contracts

Claude Desktop

Add this to claude_desktop_config.json (Settings, Developer, Edit Config), then restart Claude Desktop:

{
  "mcpServers": {
    "contract-key-terms": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/contract-key-terms-mcp", "contract-key-terms-mcp"]
    }
  }
}

On Windows, use a Windows path such as C:\\path\\to\\contract-key-terms-mcp. If the code lives in WSL, use "command": "wsl.exe" with "args": ["uv", "run", "--directory", "/path/to/contract-key-terms-mcp", "contract-key-terms-mcp"]. If uv is not on the WSL path, give its full path instead.

Example conversation

The tool results below are real output on the bundled services_agreement.txt. They're shortened, and the quotes are cut at about 110 characters. The assistant's wording is illustrative.

You: Which key terms are in services_agreement.txt?

Tool call: extract_key_terms(path="services_agreement.txt")

Result (clauses found):

  • anti_assignment (score 0.9997): "No Party shall have the right to assign its rights or obligations under this Agreement without the consent of ..."

  • termination_for_convenience (0.9955): "This Agreement may be terminated by (a) the written agreement of the Parties or (b) by either Party upon 5 day..."

  • governing_law (0.9999): "This Agreement shall be subject to and governed by the laws of the State of Colorado, excluding any conflicts-..."

Claude: The model found three clause types: an anti-assignment clause, a termination right that needs no breach, and a governing-law clause (Colorado). Here are the quoted sentences ...

You: Why did it flag termination for convenience?

Tool call: explain_prediction(path="services_agreement.txt", clause_type="termination_for_convenience")

Result: probability 0.9955 against a threshold of 0.98. Top contributions: "be terminated" (+1.80), "terminated" (+1.32), "written notice" (+1.28), "days written" (+1.20), "party upon" (+0.76).

Claude: The sentence scored 0.9955, above the 0.98 threshold. The terms that pushed it up most were "be terminated", "written notice" and "days written" ...

Limits

  • It reads .txt and .md only, up to 2 MB per file. It doesn't read PDFs or Word files.

  • It's a word-based model. It can flag a sentence that only uses a clause's words; for example, a quality "minimum of six percent" can score as a minimum commitment. Read every quoted sentence yourself.

  • The model was trained on U.S. commercial contracts filed with the SEC. Other kinds of documents may read less well.

  • Contract text is returned to your assistant as data. A document can contain text written to look like instructions, so treat results as untrusted.

Security

See SECURITY.md. In short: stdio only, no network, read-only, one allowed folder, paths resolved before they are checked, folders you list refused (compared ignoring case, on every system), files with more than one hard link refused, and the model's checksum verified before it loads.

Design notes

  • Local and read-only: contracts are often confidential, so the server reads them on your machine, sends nothing anywhere and never changes a file.

  • Paths are resolved before they are checked: a link or .. can make a path that looks inside the allowed folder lead outside it, so the check runs on where the path really leads.

  • The deny list can only add refusals: settings can name more folders to refuse, but no setting can widen what is read beyond the one allowed folder or remove the built-in refusals.

Licence and data

Citation (a courtesy): Hendrycks, Burns, Chen and Ball, "CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review", NeurIPS 2021.

Available Tools

3 tools
explain_predictionB

Why the model scored one clause type as it did in one agreement: its best sentences with the words and word pairs that pushed the score up (and down) the most, and the clause type's top-weighted terms overall.

Inputs: path (required), clause_type (required).

extract_key_termsA

Key terms of one agreement (.txt or .md inside the allowed folder; a relative path is read from it): for each clause type, whether the model found it and up to two sentences quoted as written, best first.

Inputs: path (required).

list_clause_typesA

The 36 CUAD clause types: key, plain label, CUAD category name, the model's threshold, and whether the model is used for that type (for 3 types it is not, and extract_key_terms does not report them).

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: list_clause_types is metadata lookup, extract_key_terms runs the model across all clause types for one agreement, and explain_prediction drills into a single clause type with word-level attributions. Descriptions make the boundary between extraction and explanation explicit (quotes vs. score-driving terms).

    Naming Consistency5/5

    All three tools follow the same verb_noun snake_case pattern (list_clause_types, extract_key_terms, explain_prediction). The verbs are distinct and accurately signal the operation.

    Tool Count4/5

    Three tools form a tight, coherent pipeline for a narrow purpose (enumerate types, extract, explain), with no redundant tools. It is slightly lean — a discovery/validation helper would round it out — but nothing feels over- or under-built.

    Completeness3/5

    The list/extract/explain triad covers the core workflow, but there is no tool to enumerate which agreements exist in the allowed folder, so an agent must already know a valid path. There is also no bulk or multi-agreement extraction, leaving a notable discovery gap.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      Enables Claude to directly access, query, and analyze local CSV files using natural language, keeping data private and local.
      4
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables local, on-device legal document analysis including clause extraction, risk flagging, compliance checking, and clause-level version comparison without sending documents externally.
      51 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude Desktop to redact and count personal data in PDFs and images, strip hidden metadata from photos, anonymize Word and text files, prepare watermarked ID copies, and compare contract versions using only user-approved local folders. All processing runs offline on the user's computer, creating new copies instead of modifying or deleting the originals.
      Apache 2.0