Skip to main content

best-cad-mcp

PyPI Python Platform License

A local, handle-first MCP server for agents that work with real AutoCAD drawings.

Inspect a DWG, reason over structured geometry, plan guarded edits, validate the result, and export visual evidence without hiding agent state inside the drawing.

简体中文 · Install · Workflow · Tool profiles · Safety

A mounting plate created from a validated CADPlan and exported from AutoCAD

A real AutoCAD export produced through best-cad-mcp: structured tools, semantic scan, validation, and visual verification in one workflow.

[!IMPORTANT] best-cad-mcp is beta software. It is designed for controlled local workflows where an operator can review plans and evidence, not unattended changes to valuable production drawings.

Why best-cad-mcp

Most CAD automation stops at drawing primitives. Useful agent workflows also need to know exactly what they are changing, why a target was selected, and whether the result is correct.

Handle-first control Drawing understanding Evidence before trust
Scan real AutoCAD handles, query exact entities, and edit those handles instead of guessing from labels or pixels. Build CAD-IR, semantic objects and graphs, dimension bindings, constraints, and validation reports in a local workspace. Validate and dry-run CADPlans, execute explicitly, rescan, and compare structured and visual results.

The server runs on the same Windows account as AutoCAD and communicates over MCP stdio. AutoCAD remains the source of truth; SQLite stores model-private context, scan results, and review artifacts alongside the workspace.

Quick start

Requirements

  • Windows
  • AutoCAD 2020 or newer recommended, installed and licensed
  • AutoCAD and the MCP client running as the same Windows user
  • Python 3.11 or newer
  • An MCP-compatible local client

Install the package

python -m pip install --upgrade best-cad-mcp
cad-mcp-doctor --check-autocad

For rendered overlays and visual-review helpers:

python -m pip install --upgrade "best-cad-mcp[visual]"
cad-mcp-doctor --check-autocad --require-visual-export

Keep AutoCAD open, then configure your MCP client to launch cad-mcp.

Codex

Codex supports both global ~/.codex/config.toml and trusted, project-scoped .codex/config.toml files. This minimal installed-package configuration uses the curated core tool profile:

[mcp_servers.best-cad-mcp]
command = "cad-mcp"
cwd = 'C:\CAD\your-project'
enabled = true
startup_timeout_sec = 30
tool_timeout_sec = 120
default_tools_approval_mode = "writes"

[mcp_servers.best-cad-mcp.env]
CAD_MCP_TOOL_PROFILE = "core"
CAD_MCP_WORKSPACE_ROOT = 'C:\CAD\your-project'

Restart Codex after editing the file, then inspect the connected server with /mcp. See the official Codex MCP configuration guide for configuration scopes and current options.

Claude Code and other JSON-configured clients

{
  "mcpServers": {
    "best-cad-mcp": {
      "command": "cad-mcp",
      "env": {
        "CAD_MCP_TOOL_PROFILE": "core",
        "CAD_MCP_WORKSPACE_ROOT": "C:\\CAD\\your-project"
      }
    }
  }
}

Save this as .mcp.json in the CAD project root and start the client from that project. CAD_MCP_WORKSPACE_ROOT should point to the CAD project being worked on, not to this repository. With an installed package, setting both the process cwd and workspace root to the project keeps runtime files together.

Install from source
git clone https://github.com/LokmenoWer/best-cad-mcp.git
cd best-cad-mcp
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[visual]"
.\.venv\Scripts\python.exe -m src.doctor --check-autocad

For a source checkout, start python -m src.server from the repository or set the MCP server cwd to the repository. Keep CAD_MCP_WORKSPACE_ROOT pointed at the separate CAD project you want to index.

The guarded workflow

Preflight, scan, dry-run, execute, and verify workflow

  1. Preflight — run check_runtime_environment(check_autocad=true) or cad-mcp-doctor --check-autocad; stop when the result reports ok=false.
  2. Scan — run scan_all_entities before reasoning about an existing DWG. Use topology_detail="full" for primitive grounding or cross-entity profiles.
  3. Understand — build CAD-IR, summarize the drawing, query semantics, and confirm important targets with explain_entity.
  4. Plan — express multi-step changes as a CADPlan, then call validate_cad_plan and dry_run_cad_plan.
  5. Execute explicitly — only after authorization and an acceptable dry-run, call execute_cad_plan(..., allow_modify=true, transactional=true).
  6. Verify — rescan, run geometric validation, export a clean view and overlay, and save only when the operator intends to persist the DWG.

For precise edits, prefer handles returned by AutoCAD over names inferred from screenshots. For visual findings, treat grounding as evidence: confirm the candidate entity and its geometry before changing it.

What it can do

Area Representative capabilities
2D drafting Lines, polylines, curves, circles, regions, hatches, text, dimensions, leaders, tables, layers, blocks, and attributes
Editing Move, copy, rotate, scale, mirror, offset, trim, extend, fillet, chamfer, arrays, properties, selections, and handle-targeted changes
Drawing understanding SQLite scan, CAD-IR v2, summaries, semantic objects/graphs, constraints, dimension binding, validation, and repair proposals
Guarded automation CADPlan variables, dependencies, captured handles, preconditions, postconditions, dry-runs, transactional execution, undo, and rollback attempts
Visual grounding Clean exports, adaptive numeric overlays, pixel/world mapping, path and polygon grounding, tile crops, and VLM finding reconciliation
Image-to-CAD ImageDrawingSpec tracing, calibration, fidelity checks, staged execution, and visual comparison against the source image
Mechanical drawings Orthographic views, sections, hatches, centerlines, dimensions, BOMs, balloons, layouts, and assembly-oriented prompt/skill assets
3D and output 3D solids and operations, layouts, plotting, PDF/DXF/DWF/image export, and direct in-result image content

Tool profiles

The shipped client configs and examples recommend core because it keeps tool selection reliable while covering normal guarded workflows. When the profile environment variable is omitted, the Python server falls back to full for backward compatibility.

Profile Tools Intended use
lean 113 Smallest dependable surface for common drawing and inspection tasks
core 210 Recommended default for full guarded CAD workflows
full 321 Every registered tool, including specialized and legacy operations

Select a profile with CAD_MCP_TOOL_PROFILE=lean|core|full. Fine-grained allow/deny controls are also available through CAD_MCP_TOOLS_INCLUDE and CAD_MCP_TOOLS_EXCLUDE.

From real CAD to grounded evidence

The hero mounting plate is a real AutoCAD export, not a generated UI mockup. It was created during a live MCP session from a validated and dry-run CADPlan, then rescanned and validated before export. The diagram below illustrates how a separate grounding layer keeps geometry readable while attaching exact handles.

Clean CAD geometry mapped to path, polygon, and handle evidence

Copy a mechanical drawing from one image

A typical tracing loop is:

  1. call prepare_image_trace(image_path, domain="mechanical");
  2. use prepare_visual_semantic_context and get_trace_source_image to inspect global and tiled source images;
  3. produce ImageDrawingSpec/v1, echoing each observed image's source_ref_template for measured coordinates;
  4. call validate_image_drawing_spec, then submit_image_drawing_spec;
  5. call compile_image_spec_to_cad_plan;
  6. call validate_image_fidelity_contract(spec, cad_plan);
  7. call validate_cad_plan, then dry_run_cad_plan;
  8. only after authorization, call execute_cad_plan(..., allow_modify=true, transactional=true);
  9. rescan, validate, and compare the final AutoCAD export with the source.

Do not execute a trace just because its JSON is valid. Check view count, symmetry, dimensions, centerlines, hole placement, and source/render fidelity first.

Visual grounding in v1.6

Version 1.6 adds drawing-level topology for boundaries assembled across multiple entities, including line-line and supported line-curve intersections plus closed-loop profiles. Use scan_all_entities(topology_detail="full") when primitive relations are required. Grounding now carries real path/polygon geometry, multiple-handle candidates, adaptive overlays, and tile-aware pixel/world contracts.

This improves selection quality on mechanical profiles, but it does not make vision infallible. Important edits should still follow:

visual finding -> grounding candidates -> explain_entity -> handle-targeted edit

The default VLM review prompt is vlm_review_drawing/v3. Snapshot schema versions are returned in tool results; overlay schema versions are stored in the referenced sidecars so strict consumers can detect contract changes.

Safety model

  • Read and scan before editing an existing drawing.
  • Keep raw command execution, deletion, purge, audit, save, close, and execute_cad_plan behind explicit client approval.
  • Validate and dry-run plans before modification.
  • Use returned handles and structured geometry for exact targets.
  • Rescan after modifications; do not rely on stale SQLite rows.
  • Keep model-private notes and spatial annotations in .cad_mcp/, not in visible DWG geometry, XData, or hidden layers.
  • Treat saving and closing as separate operator decisions.
  • Treat top/plan model-space views as the strongest grounding case. View twist, custom UCS, 3D geometry, and complex layout viewports can reduce confidence.

Transaction and rollback support reduce risk but cannot guarantee recovery from every AutoCAD or COM failure. Work on copies when the drawing is valuable.

Workspace and data

CAD_MCP_WORKSPACE_ROOT controls <workspace>/.cad_mcp/workspace.db. The default log, visual exports, and image trace assets are written relative to the MCP process cwd as cad_mcp.log, cad_visual_exports/, and cad_image_traces/.

External CAD projects are not ignored automatically. Add these entries to the project's .gitignore when it is a Git repository:

.cad_mcp/
cad_mcp.log
cad_visual_exports/
cad_image_traces/

The database helps connect turns and tools, but AutoCAD remains authoritative. If a drawing changes outside the server, scan it again before using stored entities. A warning about a legacy root autocad_data.db means an older database exists; verify migration, then archive it separately.

Troubleshooting

Symptom Check
AutoCAD is open but unavailable Run cad-mcp-doctor --check-autocad; make sure both processes use the same Windows account and privilege level.
Server starts with too many tools Set CAD_MCP_TOOL_PROFILE=core or lean, then restart the client.
Visual export is unavailable The [visual] extra provides Pillow/CairoSVG for raster and SVG work. AutoCAD WMF-to-PNG usually still needs ImageMagick/Wand, Inkscape, or LibreOffice. Check get_vision_capabilities() and its wmf_to_png_available result; PDF can also be rasterized externally.
Queries return stale entities Activate the intended drawing and rerun scan_all_entities.
MCP server starts in the wrong folder Set server cwd to the source checkout only when developing; set CAD_MCP_WORKSPACE_ROOT to the CAD project.
A plan is rejected Run validate_cad_plan, inspect the exact failing step, and dry-run again after correcting it.

For machine-readable diagnostics:

cad-mcp-doctor --json

Development

git clone https://github.com/LokmenoWer/best-cad-mcp.git
cd best-cad-mcp
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev,visual]"
python -m pytest -q -m "not autocad_com"

Tests marked autocad_com require a live local AutoCAD session and are excluded from the release workflow. Release publication validates the version, runs the non-COM suite, builds the package, checks it with Twine, publishes to PyPI, and then publishes the MCP server metadata.

Contributions are welcome. Please keep changes scoped, add regression tests for behavior changes, and preserve the scan → plan → validate → verify safety model.

Acknowledgements

The model-private annotation and pointer-style CAD context design was informed by the public Pointer-CAD project and paper. No Pointer-CAD source code is copied into this repository.

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

best_cad_mcp-1.6.1.tar.gz (463.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

best_cad_mcp-1.6.1-py3-none-any.whl (508.6 kB view details)

Uploaded Python 3

File details

Details for the file best_cad_mcp-1.6.1.tar.gz.

File metadata

  • Download URL: best_cad_mcp-1.6.1.tar.gz
  • Upload date:
  • Size: 463.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for best_cad_mcp-1.6.1.tar.gz
Algorithm Hash digest
SHA256 aa265096ab3edb2b8159d51df984f88c7bbb6171a97b5a0eee244663562d6f76
MD5 5da5cd2c531c115c8af4753af802c8f5
BLAKE2b-256 037a7d56f1cae4976b476e48782ed5038de0f17bc0d6af0b567e486d85fefcac

See more details on using hashes here.

Provenance

The following attestation bundles were made for best_cad_mcp-1.6.1.tar.gz:

Publisher: release.yml on LokmenoWer/best-cad-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file best_cad_mcp-1.6.1-py3-none-any.whl.

File metadata

  • Download URL: best_cad_mcp-1.6.1-py3-none-any.whl
  • Upload date:
  • Size: 508.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for best_cad_mcp-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d110b20148bc3768f2eaf837b8d742f7e3df93ad18c8a65994170384f57a2d6e
MD5 403040e9b705e7924d9969ba97df43b1
BLAKE2b-256 9e7b42c7d03d6b611b219d274f95f6c5a23a6e2aa049699e9da57b917da45c62

See more details on using hashes here.

Provenance

The following attestation bundles were made for best_cad_mcp-1.6.1-py3-none-any.whl:

Publisher: release.yml on LokmenoWer/best-cad-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.7.0

2 files

This release

1.6.1 This release

2 files

1.5.0

2 files

1.4.9

2 files

1.4.8

2 files

1.4.7

2 files

1.4.6

2 files

1.4.5

2 files

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.5

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page