Skip to main content
Glama
geongyeelee

autocad-mcp

by geongyeelee
README.md
# AutoCAD 2027 for Mac MCP Server (`autocad-mcp`)

A native **Model Context Protocol (MCP)** server for **AutoCAD 2027 for Mac (`26.0.60.171`, Apple Silicon & Intel)**, featuring a **Dual-Mode Hybrid Architecture**:

1. **Real-Time Live GUI Mode (`autocad_mcp_bridge.crx` + `mcp_helpers.lsp`)**
   - Native Objective-C++ Core Runtime Extension (`.crx`) loaded automatically into the running AutoCAD 2027 GUI process via `acaddoc.lsp`.
   - Exposes a local JSON-RPC over TCP endpoint (`127.0.0.1:9877`) and dispatches AutoLISP evaluation & command execution directly onto AutoCAD's Cocoa main thread (`libaccore.dylib` / `acedPostCommand` / `acedEvaluateLisp`).
2. **Headless Batch & Offline Mode (`AcCoreConsole` + `ezdxf`)**
   - Seamless fallback and batch DWG processing using AutoCAD 2027's built-in `/Applications/Autodesk/AutoCAD 2027/AutoCAD 2027.app/Contents/Helpers/AcCoreConsole.app/Contents/MacOS/AcCoreConsole`.
   - High-speed offline DXF creation and inspection via `ezdxf`.

---

## Quick Start (macOS)

```bash
git clone https://github.com/GeongyeeLee/autocad-mcp.git
cd autocad-mcp
chmod +x install_mac.sh
./install_mac.sh
```

### Register in OpenAI Codex (`~/.codex/config.toml`)

```toml
[mcp_servers.autocad]
command = "/path/to/autocad-mcp/.venv/bin/autocad-mcp"
```

Or via Codex CLI:
```bash
codex mcp add autocad -- /path/to/autocad-mcp/.venv/bin/autocad-mcp
```

---

## Available MCP Tools (20 Tools)

| Category | Tool Name | Description |
| :--- | :--- | :--- |
| **Core & Scripting** | `get_connection_status` | Check AutoCAD 2027 GUI, live TCP bridge (`127.0.0.1:9877`), and `AcCoreConsole` status; auto-bootstraps live bridge if needed |
| | `eval_autolisp` | Evaluate arbitrary AutoLISP expressions in live GUI or headless `AcCoreConsole` and return serialized JSON results |
| | `send_command` | Post raw AutoCAD commands directly to the active command line (e.g. `_.ZOOM _E`, `_.REGEN`) |
| | `get_drawing_info` | Get active drawing metadata, bounds (`EXTMIN`/`EXTMAX`), system variables, and entity count |
| **2D/3D Geometry** | `draw_line` | Draw a `LINE` entity (via `entmakex`, immune to `OSMODE` snapping issues) |
| | `draw_polyline` | Draw a lightweight polyline (`LWPOLYLINE`) with vertices, closed flag, and width |
| | `draw_circle` | Draw a `CIRCLE` entity |
| | `draw_arc` | Draw an `ARC` entity from start/end angles in degrees |
| | `draw_rectangle` | Draw a closed rectangular `LWPOLYLINE` |
| | `draw_text` | Create single-line `TEXT` or multiline `MTEXT` |
| | `add_dimension` | Add linear or aligned dimensions (`DIMLINEAR` / `DIMALIGNED`) |
| | `draw_hatch` | Create a `HATCH` inside a closed boundary entity handle |
| **Editing & Organization** | `modify_entities` | Move, copy, rotate, scale, mirror, erase, or change layer/color of entities by handle |
| | `manage_layer` | List, create, switch current layer, or toggle on/off/freeze/lock states |
| | `manage_block` | List block definitions, create a block from entity handles, or insert a block reference (`INSERT`) |
| **Inspection & Export** | `get_selection` | Retrieve currently selected entities and their DXF properties |
| | `query_entities` | Query entities in the drawing by DXF type and layer |
| | `export_drawing` | Save or export the active drawing to `DWG`, `DXF`, `PDF`, or `PNG` |
| **Batch & Offline** | `run_accoreconsole_script` | Run batch AutoLISP or `.scr` scripts in headless `AcCoreConsole` |
| | `inspect_or_create_dxf` | Fast offline DXF creation and inspection via `ezdxf` with optional AutoCAD 2027 handoff |

---

## Running Tests

```bash
./.venv/bin/python tests/test_autocad_mcp.py
```

## License

MIT

TDQS

B3.4/5.0

Scored across 20 tools

Disambiguation4/5

Most tools have clearly distinct purposes: drawing primitives, layer/block management, querying, and export are easy to separate. The main ambiguity is among eval_autolisp, send_command, and run_accoreconsole_script, which all execute code or commands in different contexts, though the descriptions help distinguish live GUI execution from headless batch execution.

Naming Consistency4/5

The set uses consistent snake_case and mostly follows a verb_noun pattern such as draw_line, get_drawing_info, and modify_entities. Minor deviations include multiplexed manage_layer/manage_block tools and the compound inspect_or_create_dxf name.

Tool Count3/5

At 20 tools, the surface is borderline heavy, though the CAD domain legitimately requires many drawing, query, and execution operations. Some overlap among eval_autolisp, send_command, and run_accoreconsole_script, plus get_selection versus query_entities, keeps it from feeling fully tight.

Completeness4/5

The surface covers core CAD workflows: drawing primitives, dimensions, hatches, modification, layers, blocks, querying, export, and headless scripting. Minor gaps such as explicit new-drawing creation, undo/redo, and richer entity property editing can likely be handled through eval_autolisp or send_command.

Maintenance

ActivityMaintained
ResponsivenessNo issues