cad-deliver-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
cad-deliver-mcp
English | 中文
A pre-delivery gatekeeper for CAD artefacts: stage, verify offline, then commit.
It exists because "the model said it finished" is not a delivery. This server parses generated CAD files without launching any commercial CAD runtime, decides whether the drawing holds up against geometric and drafting rules, and returns UNKNOWN instead of PASS whenever a file cannot be inspected.
Quick Start & MCP Client Setup
Installation
pip install "cad-deliver-mcp[mcp]" # CLI + MCP server
pip install cad-deliver-mcp # CLI onlyezdxf and PyMuPDF are default dependencies on purpose: without them every DXF and every PDF would be reported as UNKNOWN, and a checker that can only say "could not judge" is not worth installing. To track the repository instead of a release:
pip install "cad-deliver-mcp[mcp] @ git+https://github.com/27painter/cad-deliver-mcp.git"Client Configuration (mcp_config.json)
Any MCP-capable client works — for example Codex CLI, Claude Code, or DeepSeek Harness. Add the following to its MCP configuration. Setting PYTHONUTF8=1 is strongly recommended on Windows, because GB/T layer names and title-block attributes are Chinese text:
{
"mcpServers": {
"cad-deliver": {
"command": "python",
"args": ["-m", "cad_deliver.server"],
"env": {
"PYTHONUTF8": "1",
"PYTHONIOENCODING": "utf-8"
}
}
}
}The package also registers two console scripts, so this is equivalent:
{ "mcpServers": { "cad-deliver": { "command": "cad-deliver-mcp", "args": [] } } }Related MCP server: NS Workflow
The Three-Phase Commit Protocol
deliver_stage(paths, profile="GB_T_TIER1") ──▶ STAGED (copy files, record SHA-256)
deliver_verify(staging_id) ──▶ VERIFIED (offline deterministic check)
deliver_commit(staging_id, target_dir) ──▶ COMMITTED (atomic release to target)deliver_commitrefuses anything that is notVERIFIED.It re-hashes the staged bytes at commit time and refuses release if the file changed after verification.
It refuses to overwrite an existing file in
target_dirunlessoverwrite=Trueis passed explicitly — a filename collision is a version decision, and no_1or_v2suffix is ever invented.deliver://audit/{staging_id}exposes the full audit record as an MCP resource: file hashes, every verification attempt, structured findings, and deterministic fix instructions.
What the State Machine Buys — and What It Does Not
It makes the gap between "verified" and "released" observable. An agent that edits a file after verification is caught by the SHA-256 comparison at commit time.
It is not a security sandbox. An agent can stage the same file again after editing it and obtain a clean VERIFIED state. The audit store tracks attempts and history so re-entry loops remain visible — a protocol discipline, not a security boundary.
Atomic Storage & Protocol Isolation
Where files go: Staging lives under
%TEMP%/cad-deliver-staging/<id>/(CAD_DELIVER_STAGINGoverrides it). Nothing touches the user's delivery folder until commit. At commit, each file is written to<target_dir>/<name>.partial, flushed, and atomically promoted viaos.replace— preventing half-written files on crash and avoiding cross-drive rename errors.stdoutis the protocol channel: MCP overstdiocarries JSON-RPC frames onstdout.server.pyredirectsprintand configuresloggingtostderrat import time before transport initialization, ensuring stray diagnostics never corrupt a frame.
Architecture & Repository Layout
src/cad_deliver/
├── models.py # ParsedDrawing, Check, Verdict, StageState — the core contract
├── core.py # Constants and SHA-256 file digests
├── taxonomy.py # Seven layer roles, aliases, and normalization
├── parsers/ # The ONLY layer allowed to import a CAD library
│ ├── dxf.py # ezdxf → ParsedDrawing
│ └── dwg.py # DWG → DXF conversion (ODA / LibreDWG / custom template)
├── geometry/ # Standard-agnostic geometric integrity checks
│ ├── dxf_checks.py # Dimensions, units, sheets, lineweights, fonts, dim-text vs geometry
│ ├── topology.py # Outline closure: dangling ends at a 0.01 mm tolerance
│ ├── pdf_checks.py # Page size and text layer verification
│ ├── step_checks.py # FILE_SCHEMA, entity counts, raw coordinate bounding box
│ ├── model_checks.py
│ └── review_checks.py
├── standards.py # Half-delivery profile: values validated against standards.json
├── pipeline.py # Verification kernel: one path in, one verdict out
├── state_machine.py # STAGED / VERIFIED / COMMITTED + persistent audit store
├── server.py # MCP stdio surface: 3 tools + 1 audit resource
├── rules/ # Pluggable drafting standard rules
│ ├── base.py # BaseStandardRule(ABC) + registry
│ ├── codes.py # Stable machine codes (E_… / W_…)
│ ├── taxonomy.py # Compatibility re-export of cad_deliver.taxonomy
│ ├── registry.py # PROFILES + SEVERITY_PROFILES + runner
│ └── gb/ # GB/T 14689 sheet, GB/T 4457.2 layers and closure, GB/T 10609.1 title block
└── cli.py # Backward-compatible CLI invoked by dsh-sw-cadEnforced Orthogonal Layering
Layer | Knows About | May Import |
| Raw CAD formats ( |
|
|
| Standard library + |
|
| Standard library + |
A rule is a pure function of ParsedDrawing. It never opens files on disk and does not know which profile invoked it — the profile alone determines severity. tests/test_layering.py fails the test suite if either geometry/ or rules/ ever imports a CAD library.
Layering is enforced two ways, not one. The import check catches new dependencies; the absence of a live-document field on ParsedDrawing catches the other route — an implementation that smuggles the CAD object through an opaque field would pass an import scan and still read the document. tests/test_parsers.py asserts that attribute stays gone.
Drafting Rules & Profiles
Four Rules in GB_T_TIER1
Rule ID | Standard | Blocks On |
| GB/T 14689-2008 | Sheet dimensions outside A4–A0 (landscape or portrait, ±2 mm tolerance) |
| GB/T 4457.2-2003 | Dimension off its semantic layer, outline left on layer |
| GB/T 4457.2-2003 | Contour ring leaving a dangling endpoint ( |
| GB/T 10609.1-2008 | Missing title-block block reference, or blank mandatory attributes ( |
Why attribute-level title-block checks matter: Checking block existence alone proves nothing — an empty title block still exists.
gb.title_blockinspectsATTRIBvalues and blocks when required fields are blank, catching the exact failure mode LLM agents produce.Why endpoint-degree closure matters: Real SolidWorks and NX exports frequently write visually closed rings with the DXF
closedflag set toFalseand the final vertex coinciding with the first. Relying on the flag triggers false positives on valid industrial exports — a gate that cries wolf gets switched off. Endpoints are snapped at0.01 mmtolerance, flagging only true dangling vertices (degree == 1). Note that snapping must be a neighbourhood search, notround(x / tolerance): rounding to a grid only joins points within half a cell, so a 0.008 mm round-trip artefact would still read as a break.
Every failure carries a concrete fix. A finding that only says "something is wrong" is noise to an agent; the closure rule reports the coordinates of the gap and what to do about it.
Profiles & Severity Overrides
PROFILES = {
"LEGACY_COMPAT": [], # Byte-compatible with dsh-sw-cad 2.2.0
"GEOMETRY_ONLY": [], # Generic geometric checks only, no drafting standard
"GB_T_TIER1": ["gb.sheet_size", "gb.layer_taxonomy", "gb.closed_profile", "gb.title_block"],
"ISO_216_TIER1": ["gb.sheet_size"], # Same rule reused under ISO 216
}SEVERITY_PROFILES maps machine codes (E_TITLE_BLOCK, E_SHEET_SIZE, etc.) to ERROR or WARNING per profile, allowing strict gating in GB_T_TIER1 while preserving backward compatibility in LEGACY_COMPAT.
from cad_deliver.rules import run_profile
for result in run_profile(drawing, "GB_T_TIER1"):
print(result.code, result.severity.value, result.detail, result.fix)CLI Usage & Exit Codes
cad-deliver <dir|file>... [--profile LEGACY_COMPAT|GB_T_TIER1|GEOMETRY_ONLY] \
[--require drawing,pdf] [--out delivery.json] [--json] [--quiet]Default Profile Difference: The CLI defaults to
LEGACY_COMPATso existingdsh-sw-cadworkflows retain exact backward compatibility, whereas the MCP server defaults toGB_T_TIER1so agents are gated strictly out of the box.normalandhalfare still accepted as legacy spellings ofLEGACY_COMPAT.
Exit Code | Meaning |
| PASS — The delivery holds up under the active profile |
| FAIL — One or more |
| UNKNOWN — Could not be judged (missing parser/converter or unreadable file) |
2 is never a pass. A skipped check must never masquerade as success, because downstream agents read PASS and stop inspecting.
The contract holds even when the tool itself cannot run: if cad-deliver-mcp is not importable, the dsh-sw-cad entry point still writes a delivery.json with verdict: unknown and exits 2. A missing report would be read by a caller as "nothing to complain about".
Supported Formats & Scope Boundaries
Format | What Is Checked |
|
|
| Version tag; converted via ODA / LibreDWG when available and checked in full as |
| Page dimensions against ISO 216 and presence of a real vector text layer |
|
|
| File presence, non-zero size, and binary signature (explicitly reports |
|
|
Explicit Non-Goals
This gatekeeper does not judge engineering design intent: dimensional tolerances and fits (H7/g6), material selection, heat treatment, tolerance-stack closure, or manufacturability. A PASS guarantees structural and drafting-standard integrity — not shop-floor sign-off.
Development & Roadmap
pip install -e ".[dev]"
pytestThe suites are also plain scripts, so pytest is optional:
python tests/test_rules.pyIndividual test suites:
tests/test_layering.py— Enforces zero CAD-library imports ingeometry/andrules/tests/test_geometry.py&tests/test_topology.py— Bounding-box degeneracy, tolerance-snapped ring closure, and layer filteringtests/test_rules.py— 22 unit tests over pure in-memoryParsedDrawingfixturestests/test_server.py— End-to-endstage → verify → commit, SHA-256 tamper rejection, and collision refusaltests/test_legacy_compat.py— Exit codes0 / 1 / 2andLEGACY_COMPATgating paritytests/test_packaging.py— Version consistency and classifiers that PyPI would reject at upload time
Roadmap
Core Engine & 2PC MCP Server: Orthogonal
ParsedDrawingcontract,GB_T_TIER1ruleset, atomic commit store, anddsh-sw-cadCLI integration.50-Task Hybrid Benchmark (
benchmarks/): 15 anonymized real SolidWorks/NX exports + 15 parametricezdxffixtures + 20 deterministic fault-injected cases evaluating recall, false-positive rate, and latency across G1–G3 baselines.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Deterministic PASS/FAIL deliverable checks with objective evidence and repair instructions.
Preflight QA for AI-agent deliverables with structured verdicts and repair guidance.
Durable commitment lifecycle, verification, governance and recovery layer for agentic commerce.
Verifies AI agent work end to end: real artifacts and outcomes checked, not self-reported success.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to validate deliverables (JSON, ZIP, PDF, DOCX) against signed contracts, generating verifiable receipts with Ed25519 signatures.-
- AlicenseNot gradedqualityCmaintenanceEnables MCP-capable AI agents to work on bounded project folders through read, write, run, and verify tools, with durable approval/resume workflows and completion proven by observed verification evidence rather than self-reported results.MIT
- AlicenseAqualityBmaintenanceEnables AI engineering agents to deterministically validate 3D mesh invariants (C1-C10), verify SHA-256 content hashes, and generate fail-closed conformance reports.31MIT
- AlicenseNot gradedqualityBmaintenanceEnables cooperating AI agents to manage versioned files and JSON key-value state, record tool-call history, and publish changes atomically after dependency validation.1MIT