Greenloom CAD MCP Server

Greenloom CAD MCP Server

Enables automated CAD operations via natural language, supporting both AutoCAD LT on Windows and headless DXF generation on any platform.

Category
访问服务器

README

Greenloom CAD MCP Server

MCP server for AutoCAD LT automation and headless DXF generation.

Two backends, one API:

Backend Runtime Requires AutoCAD? Screenshot
File IPC Windows Python Yes — AutoCAD LT 2024+ (Windows) Win32 PrintWindow
ezdxf Any platform No (headless) matplotlib render

The server exposes 8 consolidated tools (drawing, entity, layer, block, annotation, pid, view, system) over the MCP stdio transport. An MCP client (Claude Desktop, Claude Code, etc.) connects and drives AutoCAD through natural-language requests.

Prerequisites (File IPC backend)

  • Windows 10/11 (the File IPC backend uses Win32 APIs for focus-free window messaging)
  • AutoCAD LT 2024 or newer — AutoLISP support was added in LT 2024 for Windows. AutoCAD LT for Mac exists but does not support AutoLISP.
  • Python 3.10+ (Windows native — not WSL Python)
  • uv package manager (install guide)

The ezdxf headless backend works on any platform (Linux, macOS, WSL) for offline DXF generation without AutoCAD installed.

Quick Start

1. Clone and install

git clone https://github.com/Greenmint-labs/greenloom_CAD_MCP.git
cd greenloom_CAD_MCP
uv sync

2. Load the LISP dispatcher in AutoCAD LT

Open AutoCAD LT and load mcp_dispatch.lsp using APPLOAD:

  1. Type APPLOAD in the AutoCAD command line
  2. Browse to <repo>/lisp-code/mcp_dispatch.lsp
  3. Click Load
  4. You should see: === MCP Dispatch v3.1 loaded === and Ready for commands via (c:mcp-dispatch)

Tip: Add the file to your AutoCAD Startup Suite (in the APPLOAD dialog) so it loads automatically with every drawing.

3. Configure your MCP client

Add to your MCP client configuration (e.g. Claude Desktop claude_desktop_config.json):

{
  "mcpServers": {
    "greenloom-cad-mcp": {
      "command": "C:\\path\\to\\greenloom-cad-mcp\\.venv\\Scripts\\python.exe",
      "args": ["-m", "greenloom_cad_mcp"],
      "env": { "GREENLOOM_CAD_BACKEND": "auto" }
    }
  }
}

Key points:

  • The command must point to the Windows Python inside the project venv (not WSL python).
  • GREENLOOM_CAD_BACKEND can be auto (default — tries File IPC, falls back to ezdxf), file_ipc (requires AutoCAD), or ezdxf (headless only).

Running from WSL

If your MCP client runs in WSL (e.g. Claude Code), launch the server through cmd.exe so it runs as a native Windows process:

{
  "mcpServers": {
    "greenloom-cad-mcp": {
      "type": "stdio",
      "command": "cmd.exe",
      "args": ["/d", "/s", "/c", "cd /d C:\\path\\to\\greenloom-cad-mcp && .venv\\Scripts\\python.exe -m greenloom_cad_mcp"],
      "env": { "GREENLOOM_CAD_BACKEND": "auto" }
    }
  }
}

4. Verify

From your MCP client, call:

system(operation="status")

You should see backend: "file_ipc" if AutoCAD is running, or backend: "ezdxf" for headless mode.

Tools

drawing — File/drawing management

Operation Description File IPC ezdxf
create Reset to clean drawing (erase all + purge) Yes Yes
open Open an existing drawing Yes Yes (DXF)
info Get entity count and layers Yes Yes
save Save current drawing (to path if given) Yes Yes
save_as_dxf Export as DXF Yes Yes
plot_pdf Plot to PDF Yes No
purge Purge unused objects Yes Yes
get_variables Get system variables by name Yes Yes
undo Undo last operation Yes No
redo Redo last undone operation Yes No

entity — Entity CRUD + modification

Create: create_line, create_circle, create_polyline, create_rectangle, create_arc, create_ellipse, create_mtext, create_hatch

Read: list, count, get

Modify: copy, move, rotate, scale, mirror, offset*, array, fillet*, chamfer*, erase

* offset, fillet, chamfer are File IPC only (not supported in ezdxf headless backend).

layer — Layer management

list, create, set_current, set_properties, freeze, thaw, lock, unlock

block — Block operations

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 — Text, dimensions, leaders

create_text, create_dimension_linear, create_dimension_aligned, create_dimension_angular, create_dimension_radius, create_leader

pid — P&ID operations (CTO symbol library)

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

P&ID symbol insertion requires the CAD Tools Online (CTO) P&ID Symbol Library installed at C:\PIDv4-CTO\. The ezdxf backend has built-in CTO library support. For the File IPC backend, some P&ID operations require additional LISP helpers — see the P&ID section in the wiki for setup details.

view — Viewport and screenshot

Operation Description
zoom_extents Zoom to show all entities
zoom_window Zoom to a specified window
get_screenshot Capture current AutoCAD view as PNG

Screenshots use PrintWindow (Win32) for the File IPC backend — works even when AutoCAD is minimized or in the background. The ezdxf backend renders via matplotlib.

system — Server management

status, health, get_backend, runtime, init, execute_lisp

execute_lisp runs arbitrary AutoLISP code (File IPC only). Pass data: {code: "(+ 1 2)"}. This turns the server into an extensible automation platform — any valid AutoLISP expression can be executed.

Architecture

MCP Client (Claude)
    │  stdio (JSON-RPC)
    ▼
Python MCP Server (greenloom_cad_mcp)
    │
    ├── File IPC Backend ──► C:/temp/*.json ──► mcp_dispatch.lsp (AutoCAD LT)
    │   PostMessageW(WM_CHAR) to MDIClient — no focus steal
    │
    └── ezdxf Backend ──► in-memory DXF (headless, no AutoCAD needed)

The File IPC backend sends keystrokes to AutoCAD's MDIClient window via PostMessageW(WM_CHAR), triggering the (c:mcp-dispatch) AutoLISP command. This approach does not steal window focus — you can continue working in other applications while automation runs.

Environment Variables

Variable Default Description
GREENLOOM_CAD_BACKEND auto Backend selection: auto, file_ipc, ezdxf
GREENLOOM_CAD_IPC_DIR C:/temp Directory for IPC command/result JSON files (must match on both Python and LISP sides)
GREENLOOM_CAD_IPC_TIMEOUT 10.0 IPC command timeout in seconds (1-300)
GREENLOOM_CAD_ONLY_TEXT false Disable screenshot capture (text feedback only)

Note: If you change GREENLOOM_CAD_IPC_DIR, you must also update the *mcp-ipc-dir* variable in mcp_dispatch.lsp to match.

Development

uv sync
uv run pytest tests/ -v

AutoCAD LT AutoLISP Compatibility

AutoLISP was added to AutoCAD LT in the 2024 release (Windows only). AutoCAD LT for Mac does not support AutoLISP.

Supported (LT 2024+ Windows) Not Supported
.lsp / .fas / .vlx / .dcl VLIDE (Visual LISP IDE)
All vl-* utility functions vlax-* (ActiveX/COM)
File I/O (open, read-line, etc.) Express Tools
Entity access (entget, entmod, etc.) 3D operations
Selection sets AutoLISP on Mac

The mcp_dispatch.lsp dispatcher is fully compatible with LT 2024+.

What's New in v3.1

  • execute_lisp — Run arbitrary AutoLISP code via temp file pattern. Turns the server from a fixed command set into an extensible automation platform.
  • Undo / Redo — Single-step undo and redo via drawing tool.
  • Drawing open — Open existing .dwg files programmatically (FILEDIA suppressed).
  • Drawing create — Now resets current drawing (erase all + purge) instead of _.NEW, preserving the LISP dispatcher namespace.
  • Drawing save with pathsave with a path parameter uses SAVEAS; without path uses QSAVE.
  • get_variables fix — Respects the names parameter; returns requested variables with proper type handling.
  • Polyline/leader fix — Point arrays properly encoded via semicolon-delimited format.
  • ESC prefix — Sends 2x ESC before each dispatch to cancel stale pending commands from prior timeouts.
  • UTF-8/cp1252 fallback — Handles non-ASCII characters in LISP result files (AutoCAD writes Windows-1252).
  • Configurable IPC timeoutGREENLOOM_CAD_IPC_TIMEOUT env var (1–300 seconds, default 10).
  • Thread-safe backend initasyncio.Lock prevents parallel initialization races.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选