Compare Cli Mcp

io.github.DrBaher由 GitHub 账号 DrBaher 发布v0.1.4更新于 Oct 28, 2026

MCP server for compare-cli: contract version diff/redline and a drift gate as agent tools.

已验证STDIO仅桌面效率与工作流开发者工具

概览

AI 生成的概览

本地 MCP 服务器,封装 compare-cli,让助手对比两份合同文档、生成红线并判断是否存在实质变更。

可以做什么
  • 对比两份文档,每侧可用路径、base64 或纯文本提供,返回结构化差异、退出分类与警告
  • 以 nda-review-cli 的 negotiation.json 作为基准与候选文本对比,并报告采用哪一级协商结果以便审计
  • 运行无需参数的演示对比,使用内置样例确认服务器已正确接入
  • 以结构化内容加文本块返回 compare --json 契约,可选附带人类可读报告
适用场景
适合需要判断合同或文档在不同版本间是否变化、生成红线,或在流水线中依据变更分类决定是否放行的场景。也可用演示工具快速验证连接是否正常。
运行要求
以 npm 包形式通过 stdio 在本机运行;compare-cli 是同级依赖,需一并安装,然后用 compare-mcp 命令启动。无需认证、API 密钥或环境变量,但可选设置 COMPARE_MCP_BASE_DIR 将文件访问限制在指定目录内。
安装前请注意
未设置 COMPARE_MCP_BASE_DIR 时,服务器可读取进程有权访问的任意文件,无人值守使用时建议设置该变量。文档内容会交给本地的 compare-cli 处理;扫描版 PDF 或格式损坏的文件会返回错误而非文本。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Compare Cli Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

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:

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

Then run:

sh
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):

json
{  "mcpServers": {    "compare-cli": {      "command": "compare-mcp"    }  }}

With base-directory lockdown (recommended for unattended use)

json
{  "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

sh
# From the repo root:npm install              # workspaces resolve compare-cli + compare-cli-mcpcd 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):

sh
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.

来源:mcp/README.md,提交 8b28632

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.4最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分