clausediff-mcp
# `clausediff-mcp` — Offline Contract Redline Diff, DOCX Extractor & Unicode Spoof MCP Server + GitHub Action
[](https://glama.ai/mcp/servers/z121245017-ai/clausediff-mcp)
Zero-dependency, 100% offline **Model Context Protocol (`MCP`) Server**, **CLI**, and **GitHub Action** enabling AI coding agents (Claude Desktop, Cursor, Windsurf, Antigravity) and pull-request CI pipelines to diff contract/SLA versions, extract `.docx` paragraphs + `<w:delText>` Track-Changes deletions without cloud uploads, detect hidden Unicode spoofing, and scan unbalanced commercial risk patterns.
> *Disclaimer: Risk Checklist Reference — Not Legal Advice. Consult qualified legal counsel before executing binding agreements.*
## MCP Tools Exposed (`stdio`)
| Tool | Purpose | Safety Annotations |
| :--- | :--- | :--- |
| `diff_contract_versions` | Runs Eugene Myers `O(ND)` paragraph alignment and inline token/CJK diff between baseline and counterparty drafts, isolating stealth numeric, percentage, date, and obligation-flip mutations. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `extract_docx_text_offline` | Extracts ordered paragraphs and hidden `<w:delText>` Word Track-Changes deletions from local `.docx` files or Base64 `.docx` archives with zero network calls. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `detect_unicode_spoofs` | Scans legal, policy, or SLA text for zero-width and Bidi characters (`U+200B..U+200F`, `U+202A..U+202E`, `U+FEFF`), Cyrillic/Greek homoglyphs, and fullwidth/halfwidth digit spoofing. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `scan_contract_risk_signals` | Flags unbalanced commercial risk patterns (back-to-back payment, uncapped indemnity, missing acceptance timeout, auto-renewal traps, background IP sweeps) across 18 bilingual rules with balanced alternatives. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
## Quick Start (MCP Client & Local CLI)
```bash
# Start MCP server over stdio (supports both NDJSON and Content-Length framing)
npx -y github:z121245017-ai/clausediff-mcp
# List MCP tool schemas from terminal
npx -y github:z121245017-ai/clausediff-mcp --list
# Diff two contract or SLA clauses directly from CLI
npx -y github:z121245017-ai/clausediff-mcp --cli diff_contract_versions '{"baselineText":"Invoices are due Net 15 days. Liability is capped at 100% of fees paid.","candidateText":"Invoices are due Net 75 days. Liability is uncapped for all claims."}'
```
### Claude Desktop / Cursor / Windsurf / Antigravity Config
```json
{
"mcpServers": {
"clausediff": {
"command": "npx",
"args": ["-y", "github:z121245017-ai/clausediff-mcp"]
}
}
}
```
### Docker (`node:22-alpine`, non-root `USER node`)
```bash
docker build -t clausediff-mcp .
docker run -i --rm clausediff-mcp
```
## GitHub Action (`z121245017-ai/clausediff-mcp@v1`)
Add `clausediff-mcp@v1` to `.github/workflows/` to inspect legal, policy, terms-of-service, and SLA Markdown files (`LEGAL/`, `SECURITY.md`, `SLA.md`, `TERMS.md`) for hidden zero-width/homoglyph Unicode spoofs and stealth numeric, percentage, date, or obligation-flip edits in pull requests:
```yaml
name: Legal & SLA Stealth Mutation Audit
on:
pull_request:
paths:
- 'legal/**'
- 'policies/**'
- '**/*SLA*.md'
- '**/*TERMS*.md'
permissions:
contents: read
jobs:
clausediff-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check policy & SLA Markdown for Unicode spoofs and stealth numeric edits
uses: z121245017-ai/clausediff-mcp@v1
with:
paths: 'legal,policies'
baseline-ref: 'origin/main'
fail-on-spoofs: 'true'
fail-on-stealth-mutations: 'true'
```
### Action Inputs & Outputs
| Name | Kind | Default | Description |
| :--- | :--- | :--- | :--- |
| `paths` | Input | `.` | Newline-, comma-, or space-separated files or directories to inspect. |
| `baseline-ref` | Input | `""` | Optional Git ref (such as `origin/main` or `HEAD~1`) to compare modified Markdown/text files for stealth numeric, date, and obligation-flip edits. |
| `fail-on-spoofs` | Input | `true` | Exit `1` when zero-width/Bidi characters, Cyrillic/Greek homoglyphs, or fullwidth digit spoofs are detected. |
| `fail-on-stealth-mutations` | Input | `true` | Exit `1` when baseline diff detects stealth numeric, percentage, date, or obligation-flip changes. |
| `fail-on-high-risk-signals` | Input | `false` | Exit `1` when high-severity commercial risk signals are detected. |
| `ignore` | Input | `node_modules,.git,dist,build,coverage,vendor,test,tests` | Comma-separated directory names skipped during recursive workspace scan. |
| `scanned-files` | Output | — | Number of Markdown and text policy files inspected. |
| `spoofs-found` | Output | — | Count of hidden Unicode, Bidi, homoglyph, or fullwidth spoofing findings. |
| `stealth-mutations-found` | Output | — | Count of stealth numeric, date, or obligation-flip mutations against baseline. |
| `risk-signals-found` | Output | — | Count of high-severity commercial risk signals detected. |
| `report-json` | Output | — | Structured JSON summary of findings. |
## Verification
```bash
npm test
```
## License
MIT License — `0` external npm dependencies, `0` network calls, `100%` local execution.
TDQS
Scored across 4 tools
Each tool targets a distinct stage: ingestion (extract_docx_text_offline), comparison (diff_contract_versions), character-level scanning (detect_unicode_spoofs), and clause-level risk scanning (scan_contract_risk_signals). The one soft boundary is hidden-Unicode detection, which diff_contract_versions also claims to isolate, potentially overlapping with detect_unicode_spoofs.
All names are snake_case verb-first patterns (diff_, extract_, detect_, scan_), which is predictable. extract_docx_text_offline is the outlier, appending a format and an 'offline' qualifier not seen elsewhere, but overall readability and consistency are strong.
Four tools is within the well-scoped 3-15 range for a focused contract-diff pipeline, and each tool covers a distinct, substantial capability rather than being redundant. Nothing feels padded or arbitrarily split.
The surface covers docx ingestion, version diffing, Unicode spoof detection, and risk flagging, but lacks ingestion for PDF/other common contract formats and any structured report/redline export, which are meaningful gaps for a contract-diff domain. Agents can partially work around by consuming raw diff output, but key lifecycle steps are missing.