hp-mcp-autocad
This MCP server lets Claude control AutoCAD—or fall back to ezdxf—to create, edit, inspect, save, and export CAD drawings with safety confirmations.
Manage drawings: create/open/info/save, export DXF, plot PDF A3, purge, undo/redo, read system variables.
Draw and edit entities: line, circle, polyline, rectangle, arc, ellipse, mtext, hatch; list/count/get; copy, move, rotate, scale, mirror, offset, array, fillet, chamfer, erase.
Manage layers: list, create, set current, set properties, freeze/thaw, lock/unlock.
Work with blocks: list, insert, insert with attributes, get/update attributes, define blocks.
Add annotations: text, linear/aligned/angular/radius dimensions, leaders.
Create P&ID drawings: setup layers, insert symbols, process lines, equipment connections, flow arrows, tags, line numbers, valves, instruments, pumps, tanks (requires CTO library).
Control views: zoom extents/window and capture PNG screenshots.
Use system tools: status/health/backend/runtime/init, execute AutoLISP (File IPC), and batch multiple commands in one undo group.
Safety gates block destructive actions—erasing all entities, overwriting files, erase/purge operations—unless explicit confirmation is provided.
Controls an open AutoCAD instance to create and modify drawings, draw and edit entities, manage layers and blocks, add annotations and dimensions, capture screenshots, save drawings, export DXF/PDF, run LISP, and perform batch operations. Also supports a no-AutoCAD DXF mode via ezdxf.
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., "@hp-mcp-autocad Vẽ hình chữ nhật 5000x3000 mm và ghi kích thước hai cạnh"
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.
HP MCP AutoCAD
Máy chủ MCP cho phép Claude (Claude Desktop, Claude Code) điều khiển AutoCAD đang mở: vẽ, sửa, ghi kích thước, chèn block, chụp màn hình, lưu và xuất PDF. Không có AutoCAD thì vẫn tạo được file DXF ở chế độ ezdxf.
Bản này do Nguyễn Hữu Phúc biên soạn, sửa đổi. Giấy phép MIT; nguồn gốc và bản quyền gốc: xem NOTICE.md và LICENSE. Ghi công chi tiết: NOTICE.md.
Khác gì bản gốc
Mục | Bản gốc | Bản HP |
| Xóa toàn bộ đối tượng và purge ngay | Từ chối nếu bản vẽ đang có đối tượng, trừ khi người dùng xác nhận |
Lưu, xuất DXF, in PDF | Ghi đè nếu file đã có | Không ghi đè; gợi ý tên mới |
| Chạy mọi đoạn LISP | Chặn đoạn có lệnh xóa (ERASE, entdel, vl-file-delete, PURGE...) khi chưa xác nhận |
| Nhận mọi lệnh trong danh sách cho phép | Không nhận lệnh xóa sạch, LISP tùy ý, batch lồng nhau; lệnh xóa đối tượng cần xác nhận |
Bản vẽ mới (ezdxf) | Không đặt đơn vị | Đơn vị mm, hệ mét |
Layer tên tiếng Việt | Treo, báo Timeout | Đọc đúng ( |
In PDF | Khổ Letter inch, lệch prompt, báo thành công dù không ra file | Khổ A3 ngang, mm, in theo CTB, kiểm tra file PDF đã tạo |
Tài liệu | Tiếng Anh | Tiếng Việt |
Chi tiết: CHANGELOG.md.
Related MCP server: vn-autocad-claude
Yêu cầu
Windows 10/11
AutoCAD bản đầy đủ, hoặc AutoCAD LT 2024 trở lên trên Windows (LT có AutoLISP từ bản 2024)
Python 3.10 trở lên (Python Windows, không dùng Python trong WSL)
uv và Git
Chế độ ezdxf (không cần AutoCAD) chạy được trên mọi hệ điều hành.
Cài đặt
1. Tải mã và cài thư viện
git clone https://github.com/HuuPhucGL/HP-MCP-Autocad.git
cd HP-MCP-Autocad
uv syncNên đặt thư mục repo ở đường dẫn không dấu, ví dụ
C:\HP-MCP-Autocad. AutoLISP nạp file từ đường dẫn có chữ tiếng Việt có dấu dễ lỗi.
2. Nạp file trung gian vào AutoCAD
Mở AutoCAD, tạo một bản vẽ mới.
Gõ
APPLOAD, chọnlisp-code/mcp_dispatch.lsp, bấm Load.Dòng lệnh báo
=== MCP Dispatch v3.1 loaded ===là xong.Thêm file vào Startup Suite trong hộp thoại APPLOAD để lần sau AutoCAD tự nạp.
3. Khai báo MCP cho Claude
Tạo file .mcp.json ở thư mục gốc dự án (Claude Code, tab Code của Claude Desktop):
{
"mcpServers": {
"hp-mcp-autocad": {
"command": "C:\\duong-dan\\HP-MCP-Autocad\\.venv\\Scripts\\python.exe",
"args": ["-m", "autocad_mcp"],
"env": { "AUTOCAD_MCP_BACKEND": "auto" }
}
}
}Thay C:\\duong-dan\\ bằng đường dẫn thật. Hoặc dùng lệnh:
claude mcp add hp-mcp-autocad -- C:\duong-dan\HP-MCP-Autocad\.venv\Scripts\python.exe -m autocad_mcpAUTOCAD_MCP_BACKEND: auto (mặc định, có AutoCAD thì dùng, không thì chuyển ezdxf),
file_ipc (bắt buộc AutoCAD), ezdxf (không cần AutoCAD).
4. Kiểm tra
Thoát hẳn Claude rồi mở lại, mở phiên mới và hỏi:
Kiểm tra kết nối MCP với AutoCAD: đang mở bản vẽ nào, đơn vị gì, đang chạy chế độ nào.
Kết nối đúng thì Claude báo backend: file_ipc.
Chốt an toàn
Mỗi khi gặp chốt, máy chủ trả về lỗi [HP an toàn] kèm hướng dẫn, để Claude dừng lại hỏi người dùng.
Thao tác | Khi nào bị chặn | Mở khóa (chỉ khi người dùng đồng ý) |
| Bản vẽ đang có đối tượng |
|
| Luôn chặn (sẽ lưu đè bản vẽ đang mở) |
|
| File đích đã tồn tại |
|
| Đoạn LISP có lệnh xóa |
|
| Có |
|
| Có | Không mở khóa; gọi riêng từng công cụ |
Biến môi trường HP_MCP_TAT_AN_TOAN=1 tắt toàn bộ chốt. Không khuyến khích.
Nên ghi thêm vào CLAUDE.md của dự án:
Chỉ vẽ đúng phần tôi yêu cầu. Không xóa đối tượng có sẵn trong bản vẽ. Trước khi sửa bản vẽ có sẵn, lưu bản sao vào _backup.
Công cụ
Công cụ | Việc làm được |
| Tạo, mở, xem thông tin, lưu, xuất DXF, in PDF, purge, đọc biến hệ thống, undo, redo |
| Vẽ line, circle, polyline, rectangle, arc, ellipse, mtext, hatch; liệt kê, đếm, đọc; copy, move, rotate, scale, mirror, offset, array, fillet, chamfer, erase |
| Liệt kê, tạo, đặt hiện hành, đổi thuộc tính, freeze, thaw, lock, unlock |
| Liệt kê, chèn, chèn kèm thuộc tính, đọc và sửa thuộc tính, định nghĩa block (ezdxf) |
| Chữ, kích thước thẳng, xiên, góc, bán kính, đường dẫn ghi chú |
| Sơ đồ công nghệ đường ống (cần thư viện CTO) |
| Zoom toàn bộ, zoom cửa sổ, chụp màn hình bản vẽ |
| Trạng thái, kiểm tra, khởi tạo lại, |
Cách hoạt động
Claude
│ MCP qua stdio
▼
Máy chủ Python (autocad_mcp) ── chốt an toàn hp_an_toan
│
├── file_ipc ──► C:/temp/*.json ──► mcp_dispatch.lsp trong AutoCAD
└── ezdxf ──► tạo DXF trong bộ nhớ, không cần AutoCADBiến môi trường
Biến | Mặc định | Ý nghĩa |
|
|
|
|
| Thư mục trao đổi file lệnh (phải khớp phía LISP) |
|
| Thời gian chờ mỗi lệnh, giây (1–300) |
|
| Tắt chụp màn hình |
| tắt |
|
|
| File CTB dùng khi in PDF (in theo màu) |
In PDF
drawing plot_pdf in không gian Model ra PDF khổ A3 ngang, đơn vị mm, phạm vi Extents, Fit, căn giữa,
in theo CTB. Muốn dùng CTB riêng, đặt biến HP_MCP_CTB (ví dụ HP-KT-A3.ctb) và để file CTB trong thư mục
Plot Styles của AutoCAD. Máy chủ chỉ báo thành công khi file PDF thực sự được tạo.
Lưu ý đơn vị
Bản vẽ mới tạo từ mẫu acad.dwt dùng đơn vị inch. Nên tạo bản vẽ từ acadiso.dwt hoặc file .dwt hệ mét
của công ty, để chữ và kích thước đúng tỷ lệ mm.
Lỗi hay gặp
Hiện tượng | Cách xử lý |
Claude chờ rất lâu | AutoCAD chưa mở, chưa nạp |
Luôn ra | Yêu cầu Claude khởi tạo lại kết nối ( |
Ảnh chụp bản vẽ toàn màu đen | Cửa sổ AutoCAD đang thu nhỏ |
Claude không thấy | Chưa mở phiên mới, hoặc |
Đã chạy thử
AutoCAD 2023 bản đầy đủ trên Windows 11 (08/11/2026): kết nối, đọc bản vẽ có layer tiếng Việt, vẽ line, polyline, chữ tiếng Việt, kích thước, batch, lưu file mới, in PDF A3, zoom, chụp màn hình và các chốt an toàn đều đạt. Chưa thử AutoCAD LT và AutoCAD for Mac.
AutoCAD for Mac
Bản gốc có hỗ trợ thử nghiệm AutoCAD bản đầy đủ trên Mac (không phải LT). Xem hướng dẫn của bản gốc (đường dẫn trong NOTICE.md). Bản HP chưa thử trên Mac.
Phát triển
uv sync
uv run pytest tests/ -vGiới hạn
Không thay kỹ sư: kết quả vẽ phải được kiểm tra, đo lại trước khi dùng.
Chốt an toàn lọc theo mẫu lệnh, không chặn được mọi cách xóa; vẫn cần CLAUDE.md và thư mục
_backup.execute_lispvẫn chạy được AutoLISP tùy ý khi không có lệnh xóa; chỉ dùng với yêu cầu rõ ràng.
Giấy phép
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.
HP safety rules (ask the user before unlocking): create erases ALL entities: refused on a non-empty drawing unless data.xac_nhan_xoa = true. save / save_as_dxf / plot_pdf never overwrite an existing file (or QSAVE over the open drawing) unless data.ghi_de = true; a new "YYMMDD - name" path is suggested instead.
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} batch — Run many commands in one round-trip + one UNDO group (File IPC only). data: {commands: [{command, params}, ...]} e.g. {"commands": [ {"command": "create-line", "params": {"x1":0,"y1":0,"x2":100,"y2":0}}, {"command": "create-text", "params": {"x":10,"y":10,"text":"Phòng ngủ","height":25}} ]} Far faster than one call per entity; use for bulk drawing.
HP safety rules (ask the user before unlocking): execute_lisp with erase/delete/purge code is refused unless data.cho_phep_xoa = true. batch never accepts drawing-create, execute-lisp, drawing-purge or nested batch; batch with entity-erase needs data.cho_phep_xoa = true.
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
Several operations overlap: insert_symbol(category) vs insert_valve/insert_instrument/insert_pump/insert_tank, and block.insert also places symbols; connect_equipment vs draw_process_line vs entity.create_line all draw lines; create_text vs create_mtext vs add_equipment_tag all place text. Grouping helps, but an agent must guess which layer of abstraction to use for the same visual result.
Most names follow verb_noun snake_case (create_line, insert_symbol, zoom_extents, set_current), and namespacing by group keeps bare nouns like list/get/count unambiguous. Minor deviations: bare verb operations (create, open, info, save, undo) and kebab-case in the batch examples (create-line, create-text) drift from the tool naming convention.
Eight groups is tidy, but the actual operation surface is roughly 70 commands, well past the comfortable range for one server. The domain breadth justifies much of it, yet P&ID-specific inserts duplicate generic entity/block operations and could be trimmed.
Coverage is broad: entity CRUD plus transforms, layers, blocks with attributes, dimensions/leaders, drawing file lifecycle, plotting, viewport screenshots, and a batch escape hatch. Gaps remain in modifying or deleting P&ID-specialized items (tags, line numbers, valves) and no layer delete or text-edit operation.
Maintenance
Related MCP Connectors
- AutoMEPDeprecatedapp.automep
Edit AutoCAD and Revit MEP drawings from Claude or ChatGPT in plain English.
Read, query, edit and render DWG drawings with AI. No AutoCAD required.
CAD in ChatGPT and Claude: editable parts, STEP/STL/drawings, in-chat 3D, automatic checks.
DXF and PDF/X-4 for AI agents: structured facts, PNG renders, an interactive in-chat viewer.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables users to control AutoCAD, GstarCAD, or ZWCAD through natural language via Claude Desktop. It provides tools for drawing geometric shapes, adding text and dimensions, and managing CAD files using the Windows COM interface.8MIT
- AlicenseAqualityCmaintenanceEnables Claude to control AutoCAD—draw, edit, query, layers, blocks, annotations, screenshots, plot to PDF—using plain language.814MIT
- FlicenseNot gradedqualityDmaintenanceEnables Claude Web to control a local AutoCAD instance via MCP, exposing 149 tools for CAD operations with dual COM/ezdxf backend support.-
- AlicenseNot gradedqualityBmaintenanceConnects Claude Desktop to a running AutoCAD instance over local Windows COM, letting users query, draw, edit, organize layers, measure areas, take off quantities, and export sheets to PDF using plain language. Every action is undoable, logged, and optionally restricted to read-only mode with no network exposure.MIT