dwg-mcp
Local Model Context Protocol (MCP) gateway for Autodesk AutoCAD 2022-2027.
English | Tiếng Việt | 简体中文 | 日本語
## Overview
`dwg-mcp` connects MCP-capable AI clients (Claude, Antigravity, Codex, Grok Build, Pi, OpenCode, Devin, Kilo, Hermes, OpenClaw, and other stdio MCP clients) directly to a local Autodesk AutoCAD 2022-2027 session through its native ObjectARX .NET API. Query entities, layers, and blocks, draft and edit DWG geometry, capture views, export DXF, update annotations, and run C# scripts locally with no cloud relay.
| Aspect | Details |
|---|---|
| Host application | Autodesk AutoCAD 2022-2027 (Windows) |
| Architecture | .NET 10 MCP stdio server + in-process per-year AutoCAD plugin |
| Local transport | Loopback TCP (2022-2024) and Named Pipe (2025-2027), token-authenticated |
| Tool surface | 78 typed tools across 10 toolsets (54 bare default), plus C# scripting and ToolBaker |
| Safety controls | `--read-only` mode (29 read-only tools), PID/document pinning, atomic batching, LISP blocked |
| MCP protocol | MCP stdio (Tools, Prompts, explicit permission annotations, response budgets) |
| License | Apache-2.0 |
## Capabilities
| Area | What you can do |
|---|---|
| Query and audit | Profile large DWG files, partition dense regions into bands, filter and page entities by layer, type, or WCS bounding box. |
| Drafting and modify | Create lines, circles, arcs, polylines, rectangles, ellipses, points, and raster images; move, rotate, scale, copy, offset, erase, or run `atomic=true` batches. |
| Blocks, annotations, dimensions | List, insert, explode, and edit block attributes; create DBText, MText, MLeaders, tables, and linear, aligned, radial, and diameter dimensions. |
| Drawings and export | List recent and open drawings, open or activate DWGs, read/set allowlisted system variables, save, purge with `dry_run`, and export DXF. |
| Visual inspection | Zoom extents, window, or entity; capture native viewport images via `CapturePreviewImage`, inspect sub-regions, and restore the camera. |
| Text and Unicode formatting | Spatially cluster technical text, normalize SHX fonts to `Bimwright_Unicode`, scale text heights, and batch-rewrite DBText/MText in one transaction. |
| C# scripting and ToolBaker | Run synchronous Roslyn C# snippets with structured JSON `data` and `compile_only` diagnostics; turn repeated workflows into baked tools. |
| Host UI and change history | Monitor live activity toasts (`MCPTOAST`), inspect session history (`MCPHISTORY`), open reports with clickable `dwg:` links (`MCPREPORTS`), and track per-drawing SQLite history. |
## Showcase
[](.github/assets/showcase/autocad-engineering-sheet.png)
*Native AutoCAD 2025 ISO A1 sheet (494 native entities: blocks with attributes, hatches, dimensions, native BOM table, and attached logo) generated via `dwg_send_code`, `dwg_attach_image`, and `dwg_capture_view_image`. Click to inspect at full resolution (`3308 x 2337`).*
Verified across all 78 tools on AutoCAD 2025 ([benchmark record](docs/benchmarks/2026-11-23-autocad-2025.md)) and 220 production calls on construction drawings.
Example prompts you can run immediately:
- "Profile this DWG, list the heaviest layers in model space, and report findings with clickable AutoCAD links."
- "Survey impact on handles `7F5AD` and `7F5AE`, move them to layer `A-NOTE`, and verify the updated properties."
- "Insert block `VALVE-CHECK` at `(1200, 450)`, set tag attribute `V-104`, and capture a view image of that area."
- "Add linear dimensions along the grid lines on layer `A-DIM`, preview unused objects with `dry_run=true`, and export the drawing to DXF."
## Quick Start
### Option 1: Agent-assisted install
Paste this prompt into an AI agent with local terminal access (Claude, Antigravity, Codex, Grok Build, Pi, OpenCode, Devin, Kilo, Hermes, OpenClaw, ...):
```text
Check the current version of AutoCAD in this PC and install the BIMwright dwg-mcp latest release for me
```
### Option 2: Manual install (PowerShell Setup ZIP)
1. **Download latest release:** open [GitHub Releases](https://github.com/bimwright/dwg-mcp/releases/latest), download `DwgMcp.Setup--win-x64.zip`, and extract it.
2. **Run the installer:** close AutoCAD, open PowerShell in the extracted folder, preview with `-WhatIf`, then install:
```powershell
powershell -ExecutionPolicy Bypass -File .\install.ps1 -WhatIf
powershell -ExecutionPolicy Bypass -File .\install.ps1
```
3. **Or install from source:** clone this repository, build, and run the local install script for your AutoCAD year:
```powershell
git clone https://github.com/bimwright/dwg-mcp.git
cd dwg-mcp
dotnet build src/Bimwright.Dwg.sln
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1 -Years 2024
```
**Verify:** restart your AI client, open a DWG in AutoCAD, and ask your agent to run `dwg_get_drawing_info`.
Full setup details (upgrade, uninstall, NuGet, Claude Desktop MCPB, per-client wiring): [docs/install.md](docs/install.md) | [docs/mcp-client-wiring.md](docs/mcp-client-wiring.md).
## Architecture
```text
AI Client (Claude / Antigravity / Codex / Grok Build / Pi / OpenCode / ...)
| MCP over stdio
v
Bimwright.Dwg.Server (.NET 10 console gateway)
| Loopback TCP (2022-2024) or Named Pipe (2025-2027) + session token
v
Bimwright.Dwg.Plugin (AutoCAD 2022-2027 shells)
| Application.Idle dispatch + Document.LockDocument()
v
Autodesk AutoCAD .NET API (ObjectARX 2022-2027)
```
- Two local processes: the server has zero AutoCAD SDK references and builds/tests without AutoCAD installed.
- Main-thread safe: `DwgApiExecutor` and `MainThreadExecutor` serialize requests onto `Application.Idle` before locking the active document.
- Full threading, discovery, Roslyn isolation, and protocol specification: [ARCHITECTURE.md](ARCHITECTURE.md).
## Supported Versions
| Version | ObjectARX | Plugin TFM | Transport | Notes |
|---|---|---|---|---|
| AutoCAD 2022-2024 | 24.1-24.3 | `net48` | Loopback TCP | Per-year shells compiled from shared source |
| AutoCAD 2025-2026 | 25.0-25.1 | `net8.0-windows` | Named Pipe | Avoids Windows loopback firewall prompt |
| AutoCAD 2027 | 26.0 | `net10.0-windows` | Named Pipe | Native .NET 10 host target |
Release Setup ZIPs pack prebuilt plugins for all 6 AutoCAD years (`2022-2027`), verified in `manifest.json`.
## Tools
| Toolset | Default | Read-only | Count | Examples |
|---|---:|---:|---:|---|
| `query` | Yes | 12 | 12 | `dwg_health`, `dwg_get_drawing_profile`, `dwg_query_entities`, `dwg_cluster_bands`, `dwg_inspect_lisp` |
| `modify` | Yes | 0 | 21 | `dwg_create_layer`, `dwg_create_line`, `dwg_create_polyline`, `dwg_move_entities`, `dwg_erase_entities` |
| `meta` (`code`) | Yes | 8 | 15 | `dwg_switch_target`, `dwg_open_drawing`, `dwg_survey_change_impact`, `dwg_batch_execute`, `dwg_send_code` |
| `view` | Yes | 3 | 6 | `dwg_zoom_extents`, `dwg_zoom_to_entity`, `dwg_capture_view_image`, `dwg_inspect_view_region`, `dwg_restore_view` |
| `toolbaker` | Optional | 3 | 6 | `dwg_list_baked_tools`, `dwg_run_baked_tool`, `dwg_list_bake_suggestions`, `dwg_accept_bake_suggestion` |
| `annotation` | Optional | 0 | 4 | `dwg_create_text`, `dwg_create_mtext`, `dwg_create_leader`, `dwg_create_table` |
| `block` | Optional | 2 | 5 | `dwg_list_blocks`, `dwg_get_block_attributes`, `dwg_insert_block`, `dwg_set_block_attributes`, `dwg_explode_block` |
| `dimension` | Optional | 0 | 4 | `dwg_create_linear_dimension`, `dwg_create_aligned_dimension`, `dwg_create_radial_dimension`, `dwg_create_diameter_dimension` |
| `export` | Optional | 0 | 1 | `dwg_export_dxf` |
| `drawing` | Optional | 1 | 4 | `dwg_get_variables`, `dwg_set_system_variable`, `dwg_save_drawing`, `dwg_purge_drawing` |
Bare startup enables 54 tools (23 read-only). `install.ps1` seeds `"toolsets": ["all"]` for all 78 tools (29 read-only under `--read-only`).
Complete tool catalog: [docs/tools.md](docs/tools.md). Benchmark: [docs/benchmarks/2026-11-23-autocad-2025.md](docs/benchmarks/2026-11-23-autocad-2025.md).
## Safety and Permissions
- Local-only loopback transport authenticated by a per-session random GUID token.
- Explicit PID and active-document confirmation required before writes (`dwg_switch_target`).
- `--read-only` strips all write and code-execution tools at registration time.
- Third-party AutoLISP scripts carry a long history of unreviewed side effects and security risks, so `dwg_run_lisp` is always blocked. Use `dwg_inspect_lisp` to inspect legacy `.lsp` logic without running it, and let the agent re-implement workflows deliberately using typed tools or controlled, synchronous C# via `dwg_send_code` (`--disable-send-code`, `MCPDISABLECODE`).
- Never approve broad `mcp__dwg-mcp__*` wildcards; use the test-verified 29-tool read-only allowlist in [docs/safety.md](docs/safety.md).
- Detailed security, auto mode, response budgets, and opt-in logging: [docs/safety.md](docs/safety.md) | [docs/configuration.md](docs/configuration.md).
## Documentation
| Document | Topic |
|---|---|
| [ARCHITECTURE.md](ARCHITECTURE.md) | Process model, threading, discovery, Roslyn scripting, wire protocol |
| [AGENTS.md](AGENTS.md) | Agent installation and operating instructions |
| [docs/install.md](docs/install.md) | Setup ZIP, upgrades, uninstall, NuGet, Claude Desktop MCPB, build from source |
| [docs/mcp-client-wiring.md](docs/mcp-client-wiring.md) | Configuration for Claude, Antigravity, Codex, Grok Build, Pi, OpenCode, Devin, Kilo, Hermes, OpenClaw |
| [docs/tools.md](docs/tools.md) | Full reference for all 78 MCP tools, spatial paging, and path policies |
| [docs/configuration.md](docs/configuration.md) | CLI flags, environment variables, response budgets, output artifacts, call logging |
| [docs/safety.md](docs/safety.md) | Target pinning, read-only allowlist, permissions, C# scripting, LISP policy, health |
| [docs/host-ui.md](docs/host-ui.md) | Activity toast, session history, Reports window, per-drawing change history |
| [docs/workflows.md](docs/workflows.md) | Large drawing audit, safe edits, Unicode text rewriting, and smoke checklist |
| [docs/benchmarks/2026-11-23-autocad-2025.md](docs/benchmarks/2026-11-23-autocad-2025.md) | Public 78-tool benchmark on AutoCAD 2025 |
| [CHANGELOG.md](CHANGELOG.md) | Version history and release notes |
## The bimwright Family
| Repository | Scope | License |
|---|---|---|
| [rvt-mcp](https://github.com/bimwright/rvt-mcp) | Autodesk Revit 2022-2027 MCP gateway | Apache-2.0 |
| [dwg-mcp](https://github.com/bimwright/dwg-mcp) | Autodesk AutoCAD 2022-2027 MCP gateway (this repository) | Apache-2.0 |
| [nwd-mcp](https://github.com/bimwright/nwd-mcp) | Autodesk Navisworks Manage 2022-2027 MCP gateway | Apache-2.0 |
| [ipt-mcp](https://github.com/bimwright/ipt-mcp) | Autodesk Inventor 2022-2027 MCP gateway | Apache-2.0 |
| [bim-wiki](https://github.com/bimwright/bim-wiki) | Bilingual BIM knowledge base (ISO 19650 and Vietnam BIM regulations) | CC-BY-SA 4.0 |
## License
[Apache License 2.0](LICENSE). Third-party notices: [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). Autodesk, AutoCAD, and DWG are trademarks of Autodesk, Inc.; bimwright is an independent open-source project.