daobataotie/CAD-MCP
CAD MCP Server
CAD‑MCP Server – Control CAD with Natural Language
What it is – A Python‑based server that lets you drive popular Windows CAD programs (AutoCAD, GstarCAD, ZWCAD) by sending JSON‑encoded commands that are generated from plain‑text instructions. It implements the Model‑Context‑Protocol (MCP) so that LLM‑powered clients (Claude, Cursor, etc.) can call a set of 35 well‑defined tools to draw, query, edit, and manage CAD files.
Why it matters – By exposing CAD operations through a structured, self‑describing API, the project bridges natural‑language processing and traditional CAD automation. An LLM can ask the server to "draw a 5 m radius circle on layer ‘Walls’, then list all entities and show a screenshot" and the server will translate that into COM calls to the CAD application, return structured results, and even stream progress notifications.
Core capabilities (as listed in the README)
| Category | Tools (examples) | What you can do |
|---|---|---|
| Basic drawing | draw_line, draw_circle, draw_arc, draw_ellipse, draw_rectangle, draw_polyline, draw_text, draw_hatch, add_dimension |
Create geometric primitives and annotate them directly from text commands. |
| Query | list_layers, list_entities, get_entity_properties, screenshot |
Retrieve the current model state, inspect individual entity handles, and get a PNG preview of the CAD window. |
| Editing | erase_entity, move_entity, rotate_entity, scale_entity, copy_entity, mirror_entity, offset_entity, array_linear_entity, array_polar_entity, undo, redo |
Modify existing objects programmatically, supporting typical CAD edit workflows. |
| Layer & drawing management | create_layer, set_current_layer, new_drawing, open_drawing, close_drawing, save_drawing |
Organise work on separate layers and handle DWG/DXF files without opening the CAD UI. |
| Block operations | create_block, insert_block, list_blocks |
Re‑use grouped geometry as CAD blocks. |
| Command passthrough | send_command |
Send any raw CAD command string for cases not covered by the predefined tools. |
| Legacy NLP interface | process_command |
A simple parser that turns free‑form text into the above tool calls (kept for backward compatibility). |
How it works under the hood
- MCP server –
src/server.pyruns a FastMCP server that can communicate via two transports:stdio– local, single‑client mode (default).streamable‑http– HTTP endpoint (/mcp) that allows multiple remote clients to share one CAD instance.
- COM bridge –
cad_controller.pyuses the Windowspywin32COM interface to talk to the installed CAD program, issuing commands and reading entity data. - Structured output – Each tool returns a JSON object that conforms to an
outputSchemadefined inmodels.py. The schema includes fields likestructuredContent,readOnlyHint, anddestructiveHintso the client can automatically decide whether to ask the user for confirmation. - Progress notifications – Long operations (e.g., CAD startup, file save) emit incremental messages that MCP clients can display as a progress bar.
- Legacy NLP processor –
nlp_processor.pyextracts colors, shape keywords, and action verbs from natural‑language strings to populate the tool parameters when the olderprocess_commandtool is used.
Getting started (from the README)
# Clone the repo, install editable
pip install -e .
# Run the server (default stdio mode)
python src/server.py
# Or run with HTTP transport for remote clients
python src/server.py --transport streamable-http --port 8000
Add the server command to any MCP‑compatible client configuration (Claude Desktop, Cursor, etc.) and start issuing commands.
Typical use cases
- Rapid prototyping – Sketch a floor plan by describing rooms in plain English; the LLM generates the sequence of
draw_*andcreate_layercalls. - Automated inspection – An LLM can query the model (
list_entities,get_entity_properties) and verify design rules, then ask the user to approve corrective edits. - Batch drawing – Generate many similar drawings (e.g., component layouts) by looping over a list of natural‑language specifications.
- Teaching / demo – Show newcomers how CAD commands map to visual results without manually clicking UI tools.
Limitations & requirements
- Windows‑only – Relies on the COM interface (
pywin32) and therefore runs only on Windows with a supported CAD product installed. - CAD software must be present – AutoCAD, GstarCAD, or ZWCAD need to be installed and licensed.
- Python 3.10+ – The project uses modern typing (
pydantic>=2). - No built‑in AI model – The server does not contain an LLM; it expects an external MCP client (Claude, Cursor, etc.) to generate the tool calls.
- Legacy NLP is simple keyword matching – For complex language understanding you should rely on the full MCP tool set rather than
process_command.
License
MIT – free to use, modify, and embed in commercial workflows.
Related
- Project
- Project
- Project
- Project