mcpField
C
compare-cli-mcp

compare-cli-mcp

Local
github.com/DrBaherLegal & Government1Updated 21w ago

About compare-cli-mcp

compare-cli-mcp wraps compare-cli as an MCP server for agent pipelines that compare contract documents and identify version drift. It supports comparisons against negotiation records, structured results, optional human-readable reports, and a configurable file-access boundary.

Key features

  1. 01Compare two documents
  2. 02Use negotiation records as a base
  3. 03Run a synthetic comparison demo
  4. 04Return structured differences and status
  5. 05Optionally include a readable report
  6. 06Restrict access to a base directory

Use cases

  1. 01Review contract version changes
  2. 02Check negotiated contract text
  3. 03Add a drift gate to agent pipelines

MCP support

It exposes three tools over stdio to MCP clients: compare_files, compare_with_negotiation, and compare_demo. Results include structured JSON and can optionally include a human-readable report.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"drbaher-compare-cli": {
"command": "npx",
"args": [
"-y",
"compare-cli-mcp"
]
}
}
}
Run commandnpx -y compare-cli-mcp

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmcompare-cli-mcp0.1.4

Tools

3

Saved tool list · updated 2w ago

ParameterTypeRequiredDescription
baseobjectYes
base.pathstringNoServer reads this path with the process's privileges. Operators running this server for an unattended agent should restrict the working directory via COMPARE_MCP_BASE_DIR or run the server under a least-privileged user.
base.formatenumNoRequired with content_base64. With content_text, optional (default 'txt').docx | pdf | md | txt
base.content_textstringNoUTF-8 text. Convenience channel for md/txt inputs.
base.content_base64stringNoBase64-encoded bytes. Required for .docx / .pdf inline.
strictbooleanNoUpgrade typographic drift to substantive.
candidateobjectYes
candidate.pathstringNoServer reads this path with the process's privileges. Operators running this server for an unattended agent should restrict the working directory via COMPARE_MCP_BASE_DIR or run the server under a least-privileged user.
candidate.formatenumNoRequired with content_base64. With content_text, optional (default 'txt').docx | pdf | md | txt
candidate.content_textstringNoUTF-8 text. Convenience channel for md/txt inputs.
candidate.content_base64stringNoBase64-encoded bytes. Required for .docx / .pdf inline.
only_clausesarrayNoCase-insensitive substring patterns matched against normalized clause titles; keep only matches.
ignore_clausesarrayNoSame semantics as only_clauses but exclusion. Composes with only_clauses (ignore runs after).
strict_cosmeticbooleanNoUpgrade cosmetic drift to substantive.
include_human_reportbooleanNoAlso return the human-readable report as a second text content block.

Details

From the project README

compare-cli-mcp

npm version

MCP (Model Context Protocol) server wrapping compare-cli for agent pipelines. Three tools, stdio transport, JSON-first responses with optional human report.

Design contract: ../docs/mcp.md. This package ships the implementation; behavior and schemas track the design version.

Part of the contract-ops suite.


Install

compare-cli-mcp has compare-cli as a peer dependency, so install both:

npm install -g compare-cli@^0.3.0 compare-cli-mcp@^0.1.1

Then run:

compare-mcp           # spawns the MCP server on stdio

Wire into an MCP client

Claude Desktop / Claude Code

Add to your MCP-client config (e.g. ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "compare-cli": {
      "command": "compare-mcp"
    }
  }
}
With base-directory lockdown (recommended for unattended use)
{
  "mcpServers": {
    "compare-cli": {
      "command": "compare-mcp",
      "env": {
        "COMPARE_MCP_BASE_DIR": "/path/to/contract/documents"
      }
    }
  }
}

Every path argument the agent supplies is then resolved against COMPARE_MCP_BASE_DIR and rejected if it escapes the directory (symlinks collapsed). Without the env var the server reads any file the process can read — see the security note in ../docs/mcp.md §3.2.

Tools

ToolPurpose
compare_filesTwo-document comparison. Each side accepts path, content_base64, or content_text.
compare_with_negotiationBase is read from nda-review-cli's negotiation.json. Returns base.negotiation_resolution so the agent can audit which signal produced the agreed text.
compare_demoZero-arg synthetic comparison against bundled fixtures. Deterministically returns exit_class: "substantive". Use to confirm the server is wired up.

Tool descriptions, input schemas, and output schemas are advertised on tools/list. The schemas are stable across v1.x of this package; any change is fenced by the snapshot golden in tests/fixtures/tools-list.json.

Output shape

Every successful tool call returns:

  • structuredContent — the exact compare --json shape (top-level ok, exit_class, exit_code, base, candidate, summary, differences, warnings). Stable across compare-cli v1.x per its AGENTS.md. This is the contract the agent reads.
  • content[0] — the same JSON serialized as a text block, for MCP clients that don't yet read structuredContent.
  • content[1] (optional, when caller passes include_human_report: true) — the human-readable report.

compare_with_negotiation adds structuredContent.base.negotiation_resolution ∈ {"status", "per_round_agreed", "clause_status"} indicating which of the three resolution tiers produced the agreed base text.

Errors vs drift

Substantive drift is a successful tool call. The agent asked what's different and the server answered. Routing on exit_class is the contract — error envelopes (isError: true) are reserved for I/O / argument failures plus one explicit precondition exception:

CodeTrigger
INPUT_NOT_FOUNDPath not found / unreadable.
INPUT_MALFORMEDMalformed .docx / .pdf.
PDF_NO_TEXT_LAYERScanned PDF; pdfjs extracted zero characters.
INVALID_ARGSSchema-validation failure (missing args, oneOf violation, etc.).
PATH_OUTSIDE_BASE_DIRCOMPARE_MCP_BASE_DIR is set and the path escapes it.
NO_AGREED_ROUNDcompare_with_negotiation precondition: no agreed round found. The CLI returns exit 2 here; the MCP server promotes it to an error because no comparison ran.
NOT_SIGNED_OFFrequire_signoffs: true and signoffs.a / signoffs.b is missing.
INTERNAL_ERRORUnexpected; surfaces underlying message so the agent isn't blind.

Codes are stable across v1.x of this package.

Running the test suite

# From the repo root:
npm install              # workspaces resolve compare-cli + compare-cli-mcp
cd mcp && npm test       # 22 tests, ~100 ms

The conformance + snapshot suite is in tests/test_protocol.mjs. The tools/list golden lives at tests/fixtures/tools-list.json. To regenerate the golden after an intentional schema change (also bump the minor version):

node -e 'import("./compare-cli-mcp.mjs").then(m => process.stdout.write(JSON.stringify(JSON.parse(JSON.stringify(m.TOOLS)), null, 2)))' > tests/fixtures/tools-list.json

License

MIT. See ../LICENSE.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.