autocad-mcp
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 draw a line from 0,0 to 10,10"
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
Máy chủ MCP cho tự động hóa AutoCAD LT và tạo DXF headless.
Hai backend, một API:
Backend | Runtime | Cần AutoCAD? | Screenshot |
File IPC | Windows Python | Có — AutoCAD LT 2024+ (Windows) | Win32 PrintWindow |
ezdxf | Mọi nền tảng | Không (headless) | matplotlib render |
Server cung cấp 8 công cụ chính (drawing, entity, layer, block, annotation, pid, view, system) thông qua MCP stdio transport.
Một MCP client (Claude Desktop, Claude Code, v.v.) có thể kết nối và điều khiển AutoCAD bằng yêu cầu ngôn ngữ tự nhiên.
Prerequisites (Backend File IPC)
Yêu cầu:
Windows 10/11
(Backend File IPC dùng Win32 API để gửi message tới cửa sổ mà không cần focus)AutoCAD LT 2024 trở lên
AutoLISP được hỗ trợ từ LT 2024 trên Windows.⚠ AutoCAD LT cho Mac không hỗ trợ AutoLISP.
Python 3.10+
(Python chạy native trên Windows — không dùng WSL Python)uv package manager
Cài đặt:
https://docs.astral.sh/uv/getting-started/installation/
💡 Backend ezdxf headless chạy được trên:
Linux
macOS
WSL
và không cần AutoCAD, chỉ dùng để tạo file DXF offline.
Quick Start
1. Clone và cài đặt
git clone https://github.com/ks40-academy/autocad-mcp.git
cd autocad-mcp
uv sync2. Load LISP dispatcher trong AutoCAD LT
Mở AutoCAD LT và load file:
mcp_dispatch.lsp
bằng lệnh APPLOAD
Các bước:
Gõ
APPLOADtrong command lineChọn file
<repo>/lisp-code/mcp_dispatch.lspNhấn Load
Nếu thành công sẽ thấy:
=== MCP Dispatch v3.1 loaded ===
Ready for commands via (c:mcp-dispatch)💡 Mẹo
Thêm file này vào Startup Suite trong APPLOAD để AutoCAD tự load khi mở bản vẽ.
3. Cấu hình MCP client
Ví dụ cấu hình trong:
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" }
}
}
}Lưu ý quan trọng
commandphải trỏ tới Windows Python trong venvKhông dùng WSL Python
Chạy từ WSL
Nếu MCP client chạy trong WSL (ví dụ Claude Code):
khởi động server thông qua cmd.exe
{
"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. Kiểm tra hoạt động
Từ MCP client gọi:
system(operation="status")Kết quả:
backend: "file_ipc"nếu AutoCAD đang chạy
hoặc
backend: "ezdxf"nếu chạy chế độ headless.
Tools
Related MCP server: CDT AutoCAD Provider
drawing — Quản lý file bản vẽ
Operation | Mô tả | File IPC | ezdxf |
create | Reset bản vẽ sạch | Yes | Yes |
open | Mở bản vẽ | Yes | Yes (DXF) |
info | Thông tin entity và layer | Yes | Yes |
save | Lưu bản vẽ | Yes | Yes |
save_as_dxf | Xuất DXF | Yes | Yes |
plot_pdf | Xuất PDF | Yes | No |
purge | Xóa đối tượng không dùng | Yes | Yes |
get_variables | Lấy biến hệ thống | Yes | Yes |
undo | Hoàn tác | Yes | No |
redo | Làm lại | Yes | No |
entity — Quản lý đối tượng
Tạo
create_line
create_circle
create_polyline
create_rectangle
create_arc
create_ellipse
create_mtext
create_hatch
Đọc
list
count
get
Chỉnh sửa
copy
move
rotate
scale
mirror
offset*
array
fillet*
chamfer*
erase
⚠ offset, fillet, chamfer chỉ dùng với File IPC.
layer — Quản lý layer
list
create
set_current
set_properties
freeze
thaw
lock
unlock
block — Thao tác block
Operation | File IPC | ezdxf |
list | Yes | Yes |
insert | Yes | Yes |
insert_with_attributes | Yes | Yes |
get_attributes | Yes | Yes |
update_attribute | Yes | Yes |
define | No | Yes |
annotation — Chú thích
create_text
create_dimension_linear
create_dimension_aligned
create_dimension_angular
create_dimension_radius
create_leader
pid — P&ID
Thư viện ký hiệu CTO.
Các lệnh:
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
⚠ Cần cài thư viện:
https://www.cadtoolsonline.com/
vào thư mục
C:\PIDv4-CTO\view — Viewport & Screenshot
Operation | Mô tả |
zoom_extents | Zoom toàn bộ |
zoom_window | Zoom theo cửa sổ |
get_screenshot | Chụp ảnh AutoCAD |
File IPC dùng:
PrintWindow (Win32)Có thể chụp ngay cả khi AutoCAD bị minimize.
ezdxf dùng:
matplotlib rendersystem — Quản lý server
status
health
get_backend
runtime
init
execute_lisp
execute_lisp
Chạy AutoLISP bất kỳ:
Ví dụ
(+ 1 2)Gửi:
data: {code: "(+ 1 2)"}Biến server thành nền tảng automation mở rộng.
Architecture
MCP Client (Claude)
│
│ stdio (JSON-RPC)
▼
Python MCP Server (autocad_mcp)
│
├── File IPC Backend
│ │
│ └── C:/temp/*.json
│ │
│ ▼
│ mcp_dispatch.lsp (AutoCAD)
│
└── ezdxf Backend
│
▼
in-memory DXFFile IPC gửi keystrokes tới AutoCAD bằng:
PostMessageW(WM_CHAR)Ưu điểm:
Không cướp focus cửa sổ
Có thể làm việc ứng dụng khác song song.
Environment Variables
Variable | Default | Mô tả |
AUTOCAD_MCP_BACKEND | auto | chọn backend |
AUTOCAD_MCP_IPC_DIR | C:/temp | thư mục IPC |
AUTOCAD_MCP_IPC_TIMEOUT | 10 | timeout |
AUTOCAD_MCP_ONLY_TEXT | false | tắt screenshot |
⚠ Nếu đổi:
AUTOCAD_MCP_IPC_DIRphải sửa luôn biến:
*mcp-ipc-dir*trong file
mcp_dispatch.lspDevelopment
uv sync
uv run pytest tests/ -vAutoCAD LT AutoLISP Compatibility
AutoLISP được thêm vào AutoCAD LT 2024 (Windows).
Hỗ trợ | Không hỗ trợ |
.lsp | VLIDE |
vl-* functions | vlax-* |
File I/O | Express Tools |
entget | 3D operations |
selection sets | AutoLISP trên Mac |
What's New v3.1
Các cập nhật chính:
execute_lisp
undo / redo
open drawing
create drawing reset
save path
get_variables fix
polyline fix
ESC prefix
UTF8 fallback
IPC timeout config
thread-safe init
License
MIT
Available Tools
8 toolsannotationA
Annotation: text, dimensions, and leaders.
Operations: create_text — data: {x, y, text, height?, rotation?, layer?} create_dimension_linear — data: {x1, y1, x2, y2, dim_x, dim_y} create_dimension_aligned — data: {x1, y1, x2, y2, offset} create_dimension_angular — data: {cx, cy, x1, y1, x2, y2} create_dimension_radius — data: {cx, cy, radius, angle} create_leader — data: {points: [[x,y],...], text}
Inputs: operation (required), data, include_screenshot. Returns: result
blockA
Block definition, insertion, and attribute management.
Operations: list — List all block definitions. insert — data: {name, x, y, scale?, rotation?, block_id?} insert_with_attributes — data: {name, x, y, scale?, rotation?, attributes: {tag: value}} get_attributes — data: {entity_id} update_attribute — data: {entity_id, tag, value} define — data: {name, entities: [{type, ...}]}
Inputs: operation (required), data, include_screenshot. Returns: result
drawingA
Drawing file management.
Operations: create — Create a new empty drawing. data: {name?} open — Open an existing drawing. data: {path} info — Get drawing extents, entity count, layers, blocks. save — Save current drawing. data: {path?} (saves to path if given, else QSAVE) save_as_dxf — Export as DXF. data: {path} plot_pdf — Plot to PDF. data: {path} purge — Purge unused objects. get_variables — Get system variables. data: {names: [...]} undo — Undo last operation. redo — Redo last undone operation.
Inputs: operation (required), data, include_screenshot. Returns: result
entityA
Entity creation, querying, and modification.
Create operations: create_line — x1, y1, x2, y2, layer? create_circle — data: {cx, cy, radius}, layer? create_polyline — points: [[x,y],...], data: {closed?}, layer? create_rectangle — x1, y1, x2, y2, layer? create_arc — data: {cx, cy, radius, start_angle, end_angle}, layer? create_ellipse — data: {cx, cy, major_x, major_y, ratio}, layer? create_mtext — data: {x, y, width, text, height?}, layer? create_hatch — entity_id, data: {pattern?}
Read operations: list — layer? → list entities count — layer? → count entities get — entity_id → entity details
Modify operations: copy — entity_id, data: {dx, dy} move — entity_id, data: {dx, dy} rotate — entity_id, data: {cx, cy, angle} scale — entity_id, data: {cx, cy, factor} mirror — entity_id, x1, y1, x2, y2 offset — entity_id, data: {distance} array — entity_id, data: {rows, cols, row_dist, col_dist} fillet — data: {id1, id2, radius} chamfer — data: {id1, id2, dist1, dist2} erase — entity_id
Inputs: operation (required), x1, x2, y1, +6 more. Returns: result
layerA
Layer creation and management.
Operations: list — List all layers with properties. create — data: {name, color?, linetype?} set_current — data: {name} set_properties — data: {name, color?, linetype?, lineweight?} freeze — data: {name} thaw — data: {name} lock — data: {name} unlock — data: {name}
Inputs: operation (required), data, include_screenshot. Returns: result
pidA
P&ID drawing with CTO symbol library.
Operations: setup_layers — Create standard P&ID layers. insert_symbol — data: {category, symbol, x, y, scale?, rotation?} list_symbols — data: {category} draw_process_line — data: {x1, y1, x2, y2} connect_equipment — data: {x1, y1, x2, y2} add_flow_arrow — data: {x, y, rotation?} add_equipment_tag — data: {x, y, tag, description?} add_line_number — data: {x, y, line_num, spec} insert_valve — data: {x, y, valve_type, rotation?, attributes?} insert_instrument — data: {x, y, instrument_type, rotation?, tag_id?, range_value?} insert_pump — data: {x, y, pump_type, rotation?, attributes?} insert_tank — data: {x, y, tank_type, scale?, attributes?}
Inputs: operation (required), data, include_screenshot. Returns: result
systemBRead-only
Server status and management.
Operations: status — Backend info, capabilities, health check. health — Quick health check (ping backend). get_backend — Return current backend name and capabilities. runtime — Return process/runtime details for spawn diagnostics. init — Re-initialize the backend. execute_lisp — Execute arbitrary AutoLISP code (File IPC only). data: {code}
Inputs: operation (required), data, include_screenshot. Returns: result
viewARead-only
Viewport control and screenshot capture.
Operations: zoom_extents — Zoom to show all entities. zoom_window — Zoom to window: x1, y1, x2, y2 get_screenshot — Capture current view as PNG image.
Inputs: operation (required), x1, x2, y1, +1 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct domain (layers, drawings, entities, blocks, annotations, P&ID symbols, views, system). The only minor overlap is between entity create_mtext and annotation create_text, but they are clearly differentiated as multi-line vs single-line text.
All tool names follow a consistent lowercase noun pattern, with operations nested as verbs underneath. No mixed conventions, camelCase, or unpredictable verbs; the naming is uniform and intuitive.
8 tools is well-scoped for an AutoCAD automation server, each covering a major functional area without unnecessary overlap. The count fits squarely in the ideal 3-15 range and avoids redundancy.
The tool set provides thorough coverage of drawing lifecycle (create, open, save, plot, purge), entity creation/editing, block management, layer management, annotation, and even specialized P&ID workflows. There are no obvious missing operations that would cause agent failures.
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.
Floor plans as code: compile, lint and repair ArchLang (.arch) floor plans to SVG, DXF and PDF.
Read official Autodesk documentation for 110+ products. No key required.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI agents to automate AutoCAD LT and create DXF files headless, with tools for drawing, entity, layer, block, annotation, PID, and system operations.16MIT
- AlicenseAqualityBmaintenanceEnables MCP-based interaction with AutoCAD and DXF/DWG drawings, supporting document lifecycle, entities, layers, blocks, layouts, viewports, zoom, screenshot capture, and PDF export via ezdxf or live Windows AutoCAD COM backends.87MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to drive live AutoCAD through COM on Windows or run headless DXF automation via ezdxf from one typed contract. It covers drafting, P&ID, mechanical, architectural, standards and takeoff workflows, with ISO GD&T and dimension-tolerance validation plus tools for reading, critiquing and diffing existing drawings.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to drive production-grade CAD automation either live through COM on Windows or headlessly via ezdxf on any platform, using one typed contract across both engines. It covers drawing creation, P&ID, mechanical and architectural drafting, ISO GD&T and dimension-tolerance validation, takeoffs, and drawing understanding.-