AutoCAD MCP Server
Provides tools for automating AutoCAD LT and generating DXF drawings. Supports drawing management, entity creation and modification, layer and block operations, annotations, P&ID symbol insertion, viewport screenshots, and execution of AutoLISP commands. The File IPC backend controls AutoCAD LT 2024+ on Windows, while the ezdxf backend enables headless DXF generation without AutoCAD.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AutoCAD MCP ServerCreate a new drawing, draw a 10x10 rectangle, and save it as DXF"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AutoCAD MCP Server
Maintainer: Street Parkour Zombie (@StreetParkourZombie)
MCP server for AutoCAD LT automation and headless DXF generation.
Two backends, one API:
Backend | Runtime | Requires AutoCAD? | Screenshot |
File IPC | Windows Python | Yes — AutoCAD LT 2024+ (Windows) | Win32 PrintWindow |
ezdxf | Any platform | No (headless) | matplotlib render |
The server exposes 8 consolidated tools (drawing, entity, layer, block, annotation, pid, view, system) over the MCP stdio transport. An MCP client (Claude Desktop, Claude Code, Antigravity, etc.) connects and drives AutoCAD through natural-language requests.
Docs: INDEX.MD · Met_Errors.md (integration errors & fixes) · System_Context.md (runtime environment)
Prerequisites (File IPC backend)
Windows 10/11 (the File IPC backend uses Win32 APIs: desktop switching, focus click,
SendInput)AutoCAD LT 2024 or newer — AutoLISP support was added in LT 2024 for Windows. AutoCAD LT for Mac exists but does not support AutoLISP.
Python 3.10+ (Windows native — not WSL Python)
uv package manager (install guide)
The ezdxf headless backend works on any platform (Linux, macOS, WSL) for offline DXF generation without AutoCAD installed.
Related MCP server: AutoCAD MCP Server
Quick Start
1. Clone and install
git clone https://github.com/StreetParkourZombie/AutoCAD-MCP-Server.git
cd AutoCAD-MCP-Server
uv sync2. Load the LISP dispatcher in AutoCAD LT
Open AutoCAD LT and load mcp_dispatch.lsp using APPLOAD:
Type
APPLOADin the AutoCAD command lineBrowse to
<repo>/lisp-code/mcp_dispatch.lspClick Load
You should see:
=== MCP Dispatch v3.1 loaded ===andReady for commands via (c:mcp-dispatch)
Tip: Add the file to your AutoCAD Startup Suite (in the APPLOAD dialog) so it loads automatically with every drawing.
Secure Load: If AutoCAD prints
File load canceled, the lisp directory is not trusted yet. The backend auto-trusts and auto-loads on firstinitialize()(appends toTRUSTEDPATHS, then(load ...)). Or add the folder permanently: AutoCAD Options → Security → Trusted Paths. See docs/Met_Errors.md §2.
3. Configure your MCP client
Add to your MCP client configuration (e.g. Claude Desktop claude_desktop_config.json):
{
"mcpServers": {
"autocad-mcp": {
"command": "C:\\path\\to\\autocad-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "autocad_mcp"],
"env": { "AUTOCAD_MCP_BACKEND": "auto" }
}
}
}Key points:
The
commandmust point to the Windows Python inside the project venv (not WSL python).AUTOCAD_MCP_BACKENDcan beauto(default — tries File IPC, falls back to ezdxf),file_ipc(requires AutoCAD), orezdxf(headless only).
Running from WSL
If your MCP client runs in WSL (e.g. Claude Code), launch the server through cmd.exe so it runs as a native Windows process:
{
"mcpServers": {
"autocad-mcp": {
"type": "stdio",
"command": "cmd.exe",
"args": ["/d", "/s", "/c", "cd /d C:\\path\\to\\autocad-mcp && .venv\\Scripts\\python.exe -m autocad_mcp"],
"env": { "AUTOCAD_MCP_BACKEND": "auto" }
}
}
}4. Verify
From your MCP client, call:
system(operation="status")You should see backend: "file_ipc" if AutoCAD is running, or backend: "ezdxf" for headless mode.
CLI bypass (no MCP client needed)
Call the server directly over stdio — for scripts, pipelines, or when an MCP client's bridge misbehaves:
# list tools
.venv\Scripts\python.exe <path>\mcp_cli.py --list
# drawing info
.venv\Scripts\python.exe <path>\mcp_cli.py drawing info
# with data payload
.venv\Scripts\python.exe <path>\mcp_cli.py layer create --data '{"name":"WALLS","color":"1"}'Exit code 0 = ok, 1 = tool error, 2 = bad usage.
Tools
drawing — File/drawing management
Operation | Description | File IPC | ezdxf |
| Reset to clean drawing (erase all + purge) | Yes | Yes |
| Open an existing drawing | Yes | Yes (DXF) |
| Get entity count and layers | Yes | Yes |
| Save current drawing (to path if given) | Yes | Yes |
| Export as DXF | Yes | Yes |
| Plot to PDF | Yes | No |
| Purge unused objects | Yes | Yes |
| Get system variables by name | Yes | Yes |
| Undo last operation | Yes | No |
| Redo last undone operation | Yes | No |
entity — Entity CRUD + modification
Create: create_line, create_circle, create_polyline, create_rectangle, create_arc, create_ellipse, create_mtext, create_hatch
Read: list, count, get — all three report each entity's ACI colour
Modify: copy, move, rotate, scale, mirror, offset*, array, fillet*, chamfer*, erase, set_color
Batch delete: delete_by, delete_all
*
offset,fillet,chamferare File IPC only (not supported in ezdxf headless backend).
Entity colour
Every create operation takes an optional color, and set_color changes it on
an existing entity. Accepts a name, an ACI index, or a by-state keyword:
Value | ACI |
| 1–8 |
| 0 |
| 256 |
any integer | passed through |
Unrecognised names fall back to 7 (white) rather than raising.
Omittingcolor leaves the entity BYLAYER, so it inherits its layer's colour.
Setting an explicit colour breaks that inheritance — the entity no longer
follows the layer. Pass bylayer to restore it.
// a red line on the WALLS layer
{ "operation": "create_line", "x1": 0, "y1": 0, "x2": 100, "y2": 0,
"layer": "WALLS", "data": { "color": "red" } }
// recolour later
{ "operation": "set_color", "entity_id": "2F", "data": { "color": "green" } }Batch delete
delete_by matches on any combination of selectors — they are ANDed together,
so passing two narrows the result. At least one selector is required; a call
with none is refused rather than treated as "delete everything".
// every entity on one layer
{ "operation": "delete_by", "data": { "layer": "TEMP" } }
// all red text, nothing else
{ "operation": "delete_by", "data": { "color": "red", "type": "TEXT" } }
// an explicit list
{ "operation": "delete_by", "data": { "handles": ["2F", "31"] } }
// the two most recent entities
{ "operation": "delete_by", "data": { "last_n": 2 } }The response reports matched and deleted separately, so a partial delete is
visible rather than swallowed:
{ "ok": true, "payload": { "matched": 7, "deleted": 7, "handles": ["2F", "31"] } }delete_all wipes the drawing and requires confirm: true. It is the only
irreversible operation in this tool — drawing → undo is the way back, and
only while the undo stack holds it.
{ "operation": "delete_all", "data": { "confirm": true } }layer — Layer management
list, create, set_current, set_properties, freeze, thaw, lock, unlock
block — Block operations
Operation | File IPC | ezdxf |
| Yes | Yes |
| Yes | Yes |
| Yes | Yes |
| Yes | Yes |
| Yes | Yes |
| No | Yes |
annotation — Text, dimensions, leaders
create_text, create_dimension_linear, create_dimension_aligned, create_dimension_angular, create_dimension_radius, create_leader
pid — P&ID operations (CTO symbol library)
setup_layers, insert_symbol, list_symbols, draw_process_line, connect_equipment, add_flow_arrow, add_equipment_tag, add_line_number, insert_valve, insert_instrument, insert_pump, insert_tank
P&ID symbol insertion requires the CAD Tools Online (CTO) P&ID Symbol Library installed at
C:\PIDv4-CTO\. The ezdxf backend has built-in CTO library support. For the File IPC backend, some P&ID operations require additional LISP helpers — see the P&ID section in the wiki for setup details.
view — Viewport and screenshot
Operation | Description |
| Zoom to show all entities |
| Zoom to a specified window |
| Capture current AutoCAD view as PNG |
Screenshots use PrintWindow (Win32) for the File IPC backend — works even when AutoCAD is minimized or in the background. The ezdxf backend renders via matplotlib.
system — Server management
status, health, get_backend, runtime, init, execute_lisp, acad_command
execute_lispruns arbitrary AutoLISP code (File IPC only). Passdata: {code: "(+ 1 2)"}. This turns the server into an extensible automation platform — any valid AutoLISP expression can be executed.
acad_command — run any AutoCAD command (File IPC only)
The ~60 commands wrapped with typed parameters elsewhere in this API are only the commands that were convenient to expose. acad_command removes that ceiling: any AutoCAD command that has a command-line (script) form becomes reachable — which is most of the ribbon. TRIM, EXTEND, JOIN, BLOCK, SPLINE, MIRROR3D, ARRAY, OFFSET, and thousands more.
{
"operation": "acad_command",
"data": { "args": ["_.TRIM", "", "_F", "", ""] }
}Token format:
Tokens are passed to AutoLISP's
commandverbatim, in order. An empty string is a bare Enter, which is how a prompt is accepted without input (""= accept default,_F= pick theFoption of an English command).Prefix commands with
_for the English name regardless of UI language —_.TRIM, not_.CẮT. Add.for the global variant (_.LINE).A space inside a token is encoded as
~by the Python side and decoded back before dispatch, so a token can carry a value containing spaces (a file path, a text style) without colliding with anything.
Security policy — a denylist, not an allowlist:
An allowlist would reintroduce the coverage limit this feature exists to remove, so the gate blocks three specific classes of command and allows everything else:
Class | Commands refused | Why |
Arbitrary code injection |
| Would let a caller run any LISP, which is equivalent to bypassing the whole policy |
Process escape |
| Would let a caller launch other programs |
Security reconfiguration |
| Would let a caller disable Secure Load or rewrite the profile |
Everything else stays reachable, including destructive-but-normal CAD commands such as ERASE, SAVE, NEW, and SAVEAS. Those are no more dangerous than a person typing them by hand, and blocking them would make the tool unusable for real work. Callers are expected to be an automated agent driving a human's own drawing, not an untrusted tenant.
execute_lisp has no such denylist — it runs arbitrary AutoLISP by design. The acad_command denylist is a guardrail against accidental or careless calls, not a security boundary. If an untrusted party can reach this MCP server, they can already reach execute_lisp.
A refused command returns an error rather than doing nothing:
acad-command: refused by policy: _.SHELLArchitecture
MCP Client (Claude)
│ stdio (JSON-RPC)
▼
Python MCP Server (autocad_mcp)
│
├── File IPC Backend ──► C:/temp/*.json ──► mcp_dispatch.lsp (AutoCAD LT)
│ PostMessageW(WM_CHAR) to MDIClient — no focus steal
│
└── ezdxf Backend ──► in-memory DXF (headless, no AutoCAD needed)Input chain (AutoCAD 2026 full / WPF CLI): posted WM_CHAR is ignored by the WPF command line, so the backend switches to WinSta0\Default, raises the main window above overlapping helper windows (e.g. Help), clicks the CLI Palette input row to move focus, then injects real keystrokes via SendInput, triggering (c:mcp-dispatch) in AutoLISP. Focus returns to your app automatically (no permanent focus steal). On AutoCAD LT the CLI is a classic MDIClient edit — the same code path works.
All desktop-sensitive calls (EnumWindows, IsWindow, SetCursorPos, SendInput) run while the thread is on the Default desktop; MCP servers launched by Antigravity otherwise run on a private agy-* desktop where foreign windows are invisible. See docs/System_Context.md.
Environment Variables
Variable | Default | Description |
|
| Backend selection: |
|
| Directory for IPC command/result JSON files (must match on both Python and LISP sides) |
|
| IPC command timeout in seconds (1-300) |
|
| Disable screenshot capture (text feedback only) |
Note: If you change
AUTOCAD_MCP_IPC_DIR, you must also update the*mcp-ipc-dir*variable inmcp_dispatch.lspto match.
Troubleshooting
Symptom | Likely cause | See |
| Secure Load — path not in | |
Typed commands do nothing | WPF CLI ignores posted messages; wrong hwnd | |
Clicks hit the wrong window | Help window overlaying the CLI Palette | |
| Stale handle or cross-desktop | |
IPC timeout although cmd file was consumed | Unparseable result (Vietnamese | |
MCP client: | Client bridge sends | |
| Command is on the denylist (by design) | |
A |
| |
| AutoLISP |
Ground truth for "did AutoCAD get it?": press F2 and read the Text Window (command echo + LISP errors).
The hardest failures are the ones that appear in neither place — the operation returns ok: true and simply does the wrong thing:
Symptom | Likely cause | See |
|
| |
|
| |
| AutoLISP treats only | |
|
| |
| handle captured after | |
Two live test runs report failures individually-passing tests | both share |
Development
uv sync
uv run pytest tests/ -vmcp_dispatch.lsp is plain text that AutoCAD loads at runtime — pytest never executes it. The suite asserts structure (paren balance, unique defuns, a handler per cond branch, colour-table agreement). A green run proves the dispatcher is well-formed, not that it works: six AutoLISP defects shipped with 213 passing tests and were only found by driving a live AutoCAD.
After editing the LISP, reload it and exercise the affected path against a throwaway layer. See docs/Met_Errors.md §15–§21 for the AutoLISP traps — last is unary, nth returns an element, 0 is true, an indirect call needs apply, and a bare entmod list does nothing.
AutoCAD LT AutoLISP Compatibility
AutoLISP was added to AutoCAD LT in the 2024 release (Windows only). AutoCAD LT for Mac does not support AutoLISP.
Supported (LT 2024+ Windows) | Not Supported |
| VLIDE (Visual LISP IDE) |
All |
|
File I/O ( | Express Tools |
Entity access ( | 3D operations |
Selection sets | AutoLISP on Mac |
The mcp_dispatch.lsp dispatcher is fully compatible with LT 2024+.
What's New in v3.3
Entity colour - Every
entitycreate operation takes an optionalcolor,set_colorrecolours an existing entity, andlist/getnow report each entity's ACI colour. Accepts names (red,cyan, ...), ACI indices, andbylayer/byblock. Setting an explicit colour breaks the entity's inherit-from-layer behaviour;bylayerrestores it.Batch delete -
delete_byremoves every entity matching any combination oflayer,type,color,handles, orlast_n(ANDed; at least one required).delete_allwipes the drawing behind aconfirm: trueguard. Both reportmatchedanddeletedseparately so a partial delete is visible.Dispatcher syntax tests -
tests/test_lisp_dispatcher.pywalks the AutoLISP source with a string-aware scanner and asserts parenthesis balance, unique defun names, that everycondbranch has a handler, and the exact AutoLISP shapes behind six defects found by live testing (indirect call viaapply, colour appended toentget, no two-argumentlast, nonthused as a tail, an explicit> 0guard, empty strings decoding tonil).Live-verified colour and batch delete - both paths were exercised against a running AutoCAD LT on a throwaway
MCPTESTlayer: coloured create,set_colorto cyan and back tobylayer,delete_by(color=…), and both refusal guards. Six AutoLISP bugs surfaced in the process — a missingapply, a bareentmodthat returned success while changing nothing, two Common Lisp list idioms, and two truthiness traps. See Met_Errors §15–§21.
What's New in v3.2
acad_commandpassthrough — Run any AutoCAD command that has a command-line form, not just the ~60 wrapped with typed parameters. This removes the coverage ceiling: TRIM, EXTEND, JOIN, MIRROR3D, ARRAY and the rest of the ribbon become reachable without adding a wrapper per command. Gated by a policy denylist (seesystem.acad_command).Numeric command tokens —
acad_commandaccepts["_.CIRCLE", "x,y", "1"]; tokens are coerced to string, so a radius that arrives as a JSON number no longer crashes with'int' object has no attribute 'replace'.
What's New in v3.1
execute_lisp— Run arbitrary AutoLISP code via temp file pattern. Turns the server from a fixed command set into an extensible automation platform.Undo / Redo — Single-step undo and redo via
drawingtool.Drawing open — Open existing
.dwgfiles programmatically (FILEDIA suppressed).Drawing create — Now resets current drawing (erase all + purge) instead of
_.NEW, preserving the LISP dispatcher namespace.Drawing save with path —
savewith apathparameter uses SAVEAS; without path uses QSAVE.get_variablesfix — Respects thenamesparameter; returns requested variables with proper type handling.Polyline/leader fix — Point arrays properly encoded via semicolon-delimited format.
ESC prefix — Sends 2x ESC before each dispatch to cancel stale pending commands from prior timeouts.
UTF-8/cp1252 fallback — Handles non-ASCII characters in LISP result files (AutoCAD writes Windows-1252).
Configurable IPC timeout —
AUTOCAD_MCP_IPC_TIMEOUTenv var (1–300 seconds, default 10).Thread-safe backend init —
asyncio.Lockprevents parallel initialization races.
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Headless CAD engine & MCP server for 2D/3D drafting, solids, DXF/SVG export, and automation.
DXF and PDF/X-4 for AI agents: structured facts, PNG renders, an interactive in-chat viewer.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
MCP CAD services; bundles with SmartScale (measure to CAD).
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables automated CAD operations via natural language, supporting both AutoCAD LT on Windows and headless DXF generation on any platform.8MIT
- AlicenseNot gradedqualityCmaintenanceEnables natural-language control of AutoCAD LT for automation and headless DXF generation, supporting drawing, entity, layer, block, annotation, P&ID, and system operations via an MCP interface.MIT
- AlicenseAqualityCmaintenanceMCP server for AutoCAD LT automation and headless DXF generation, exposing tools for drawing, entities, layers, blocks, annotations, P&ID, and view operations via natural language.8MIT
- AlicenseAqualityCmaintenanceAn MCP server that enables natural-language control of AutoCAD via file IPC or headless DXF generation, with tools for drawing, entities, layers, blocks, annotations, P&ID, views, and system operations.8MIT