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 分