Skip to main content
Glama
autocad-mcp

autocad-mcp

by geongyeelee

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)

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)

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

Or via Codex CLI:

codex mcp add autocad -- /path/to/autocad-mcp/.venv/bin/autocad-mcp

Related MCP server: AutoCAD MCP Ultra

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


Reliability & Unified Diagnostic Fields (v0.2.0)

Every tool response includes 17 unified diagnostic fields for full observability across both Live GUI and Headless AcCoreConsole modes:

requested_mode / actual_mode / fallback_reason
request_id / elapsed_ms / execution_stage
active_document / command_names / busy / modal_dialog
script_success / command_success
output_exists / output_size / reopen_verified
error_code / raw_log_path

Key v0.2.0 hardening highlights:

  • Granular Live Readiness: Separates bridge_online, drawing_ready, and command_executable, inspecting [NSApp modalWindow], CMDACTIVE (interactive bits 1|2|8), and CMDNAMES on the Cocoa main thread with a bounded timeout.

  • Anti-Reentrancy & Event-Loop Wakeup: Prevents main-thread stalls by waking the Cocoa runloop with NSEventTypeApplicationDefined, waiting briefly (~600ms) for trailing commands to unwind, and explicitly rejecting or cancelling (CANCELCMD) when busy (COMMAND_ACTIVE_BUSY / MODAL_DIALOG_ACTIVE).

  • Verified DWG Persistence: save_as_dwg and export_drawing verify file existence, non-empty size, AC10... header magic, and headless reopen verification (reopen_verified: true) before returning saved_dwg.

  • Full UTF-8 / CJK Path & Output Support: Uses (open path mode "utf8") in AutoLISP and multi-encoding fallback (utf-8 → utf-16-le → gb18030) with raw byte logs preserved at /tmp/autocad_mcp_logs/<request_id>.log.

  • Strict Live Mode (require_live): Disables silent fallback to a blank headless Drawing1.dwg when querying or modifying the foreground drawing unless allow_headless_fallback=True or input_dwg is specified.

  • Verified Document Open: inspect_or_create_dxf(open_in_autocad=True) separates open_dispatched from document_loaded_verified and confirms loaded_entity_count in the newly opened document.


Running Tests

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

License

MIT

Available Tools

20 tools
add_dimensionA

Add a linear or aligned dimension between point1 and point2.

Args: point1: First extension line origin [x, y]. point2: Second extension line origin [x, y]. dim_line_point: Point specifying the dimension line location [x, y]. dim_type: 'aligned' or 'linear'. layer: Optional layer name for the dimension.

Inputs: point1 (required), point2 (required), dim_line_point (required), layer, +1 more. Returns: result

draw_arcA

Draw a circular arc counter-clockwise from start_angle_deg to end_angle_deg.

Args: center: [x, y] or [x, y, z] center coordinates. radius: Arc radius (> 0). start_angle_deg: Start angle in degrees. end_angle_deg: End angle in degrees. layer: Optional layer name. color: Optional ACI color (1-255).

Inputs: center (required), radius (required), end_angle_deg (required), start_angle_deg (required), +2 more. Returns: result

draw_circleB

Draw a circle in AutoCAD 2027.

Args: center: [x, y] or [x, y, z] center coordinates. radius: Circle radius (> 0). layer: Optional layer name. color: Optional ACI color (1-255).

Inputs: center (required), radius (required), color, layer. Returns: result

draw_hatchA

Create a HATCH inside a closed entity specified by its handle.

Args: boundary_handle: Hex handle of the closed boundary entity (e.g. from draw_rectangle, draw_polyline, or draw_circle). pattern: Hatch pattern name (e.g. 'SOLID', 'ANSI31', 'ANSI37', 'NET'). scale: Hatch pattern scale (ignored for SOLID). angle_deg: Hatch pattern angle in degrees. layer: Optional layer name. color: Optional ACI color (1-255).

Inputs: boundary_handle (required), color, layer, scale, +2 more. Returns: result

draw_lineB

Draw a line between two 2D/3D points in AutoCAD 2027.

Args: start_point: [x, y] or [x, y, z] start coordinates. end_point: [x, y] or [x, y, z] end coordinates. layer: Optional layer name (automatically created if it does not exist). color: Optional AutoCAD Color Index (ACI 1=Red, 2=Yellow, 3=Green, 4=Cyan, 5=Blue, 6=Magenta, 7=White).

Inputs: end_point (required), start_point (required), color, layer. Returns: result

draw_polylineB

Draw a lightweight polyline (LWPOLYLINE) through a sequence of vertices.

Args: vertices: List of [x, y] vertices (at least 2 points). closed: Whether the polyline should be closed. width: Constant global width of the polyline segments. layer: Optional layer name (auto-created if missing). color: Optional ACI color (1-255).

Inputs: vertices (required), color, layer, width, +1 more. Returns: result

draw_rectangleA

Draw an axis-aligned rectangle (as a closed LWPOLYLINE) from two opposite corners.

Args: corner1: First corner [x1, y1]. corner2: Opposite corner [x2, y2]. width: Optional line width. layer: Optional layer name. color: Optional ACI color (1-255).

Inputs: corner1 (required), corner2 (required), color, layer, +1 more. Returns: result

draw_textA

Create single-line TEXT or multiline MTEXT in AutoCAD 2027.

Args: position: Insertion point [x, y] or [x, y, z]. text: Text string content. height: Text height. rotation_deg: Rotation angle in degrees. multiline: If True, creates MTEXT; otherwise creates TEXT. layer: Optional layer name. color: Optional ACI color (1-255).

Inputs: text (required), position (required), color, layer, +3 more. Returns: result

eval_autolispA

Evaluate arbitrary AutoLISP code in AutoCAD 2027 and return the serialized result.

Args: code: AutoLISP expression(s) to evaluate, e.g. '(getvar "ACADVER")' or '(mcp:make-line ...)'. prefer_live: Use the live AutoCAD 2027 GUI window if available; falls back to headless AcCoreConsole if False or if input_dwg is provided. timeout_ms: Execution timeout in milliseconds. input_dwg: Optional path to an existing .dwg file to process in headless AcCoreConsole mode. save_as_dwg: Optional path to save the resulting .dwg file when running in headless mode.

Inputs: code (required), input_dwg, timeout_ms, prefer_live, +1 more. Returns: result

export_drawingC

Save or export the active AutoCAD 2027 drawing to DWG, DXF, PDF, or PNG.

Args: output_path: Target file path (e.g. '/tmp/output.dwg', '/tmp/output.dxf', '/tmp/output.pdf', '/tmp/preview.png'). format: One of 'dwg', 'dxf', 'pdf', 'png'.

Inputs: output_path (required), format. Returns: result

get_connection_statusA

Check AutoCAD 2027 GUI process, live TCP bridge (127.0.0.1:9877), and AcCoreConsole status.

Args: auto_bootstrap: If True and the live bridge is not yet connected, automatically open a workspace drawing in AutoCAD 2027 to load the native bridge.

Inputs: auto_bootstrap. Returns: result

get_drawing_infoA

Get metadata, system variables, bounds, and entity count of the active drawing (or a file via input_dwg).

Inputs: input_dwg. Returns: result

get_selectionA

Get all currently or previously selected entities in the active AutoCAD 2027 drawing.

Inputs: no named parameters. Returns: result

inspect_or_create_dxfA

High-speed offline DXF inspection or creation using ezdxf, with optional handoff to AutoCAD 2027.

Args: dxf_path: Path to the .dxf file to inspect or create. action: 'inspect' to read layers/entities summary of an existing DXF, or 'create' to generate a new DXF from entities_spec. entities_spec: For action='create', a list of dicts describing entities, e.g. [{'type': 'LINE', 'start': [0,0], 'end': [100,0], 'layer': 'WALL'}, {'type': 'CIRCLE', 'center': [50,50], 'radius': 20}]. open_in_autocad: If True, opens the DXF file in the AutoCAD 2027 GUI after completion.

Inputs: dxf_path (required), action, entities_spec, open_in_autocad. Returns: result

manage_blockB

List blocks, create a new block definition from entity handles, or insert a block reference.

Args: action: One of 'list', 'create', 'insert'. block_name: Name of the block (required for 'create' and 'insert'). point: Base point (for 'create') or insertion point (for 'insert'). handles: List of entity handles to group into the block (required for 'create'). scale_x: X scale factor for 'insert'. scale_y: Y scale factor for 'insert'. scale_z: Z scale factor for 'insert'. rotation_deg: Rotation angle in degrees for 'insert'. layer: Optional layer name for 'insert'. color: Optional ACI color for 'insert'.

Inputs: color, layer, point, action, +6 more. Returns: result

manage_layerB

List, create, switch, or change properties of AutoCAD layers.

Args: action: One of 'list', 'create', 'set_current', 'on', 'off', 'freeze', 'thaw', 'lock', 'unlock'. name: Layer name (required for all actions except 'list'). color: Optional ACI color (1-255) when creating or updating a layer. linetype: Optional linetype name (e.g. 'Continuous', 'DASHED', 'CENTER').

Inputs: name, color, action, linetype. Returns: result

modify_entitiesA

Modify one or more entities identified by their handles.

Args: handles: List of entity hex handles (e.g. ['2DA', '2DB']). action: One of 'move', 'copy', 'rotate', 'scale', 'mirror', 'erase', 'set_layer', 'set_color'. base_point: Base point [x, y, z] for move/copy/rotate/scale/mirror. target_point: Target point [x, y, z] for move/copy or second mirror point. rotation_deg: Rotation angle in degrees (for action='rotate'). scale_factor: Scale factor (for action='scale'). layer: Target layer name (for action='set_layer'). color: Target ACI color 1-255 (for action='set_color').

Inputs: action (required), handles (required), color, layer, +4 more. Returns: result

query_entitiesA

Query entities in the active drawing (or a DWG file) with optional type and layer filters.

Args: entity_type: Optional DXF entity type filter (e.g. 'LINE', 'LWPOLYLINE', 'CIRCLE', 'ARC', 'TEXT', 'MTEXT', 'INSERT', 'DIMENSION', 'HATCH'). layer: Optional layer name filter. limit: Maximum number of entity records to return (default 100). input_dwg: Optional path to a .dwg file to inspect in headless mode.

Inputs: layer, limit, input_dwg, entity_type. Returns: result

run_accoreconsole_scriptA

Run a batch AutoLISP or .scr script in AutoCAD 2027's headless AcCoreConsole.

Args: script_or_lisp: AutoLISP expressions (if is_lisp=True) or raw AutoCAD .scr script lines (if is_lisp=False). is_lisp: Whether script_or_lisp is AutoLISP code (True) or raw .scr commands (False). input_dwg: Optional input .dwg file path to open in AcCoreConsole. save_as_dwg: Optional output .dwg file path to save after execution. timeout_sec: Maximum execution time in seconds.

Inputs: script_or_lisp (required), is_lisp, input_dwg, save_as_dwg, +1 more. Returns: result

send_commandC

Send a raw command string directly to the active AutoCAD 2027 command line.

Args: command: Raw AutoCAD command sequence (e.g. '_.ZOOM E' or '.REGEN').

Inputs: command (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    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 recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      A
      maintenance
      Production-grade AutoCAD automation server enabling real-time CAD control via COM and headless DXF operations through 87 tools, including drawing creation, entity modification, layer management, and batch processing, designed for AI agent integration via the Model Context Protocol.
      243
      5,506 PyPI
      297
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI agents to drive AutoCAD 2024+ and AutoCAD LT through live COM and AutoLISP engines, with support for headless DXF processing, ISO GD&T, P&ID drafting, and Rhino.Inside Grasshopper battery workflows.
      162
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI assistants to read, modify, and verify AutoCAD 2027 drawings using transactional, safety-checked CAD tools, with optional headless DXF/PNG/PDF drawing and preview when AutoCAD is unavailable.
      41
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to drive a live AutoCAD session over stdio with transactional, serialized writes: inspecting and saving documents, managing layers, creating and editing line/circle/arc/polyline/rectangle/text entities, querying selections, setting checkpoints, and exporting DXF. Every request is validated against strict schemas with document revision checks and save-reopen geometry readback, and a headless backend is available when no AutoCAD instance is running.
      MIT