CAD MCP Server

CAD MCP Server

Enables reading, analyzing, and editing CAD files (DXF and DWG) via natural language, including entity queries, layer management, and safe copy-based edits.

Category
访问服务器

README

CAD MCP Server

Python License: MIT MCP Built with ezdxf Formats: DXF · DWG

An MCP server that lets Claude (and any other MCP client) read, analyze, and edit CAD files — both DXF and DWG — powered by ezdxf.

It runs as a small local Python process over stdio. Your CAD files never leave your machine.

  • DXF — read and edit directly, no extra setup.
  • DWG — Autodesk's proprietary binary format. ezdxf cannot parse it alone, so DWG is converted to DXF automatically via the free ODA File Converter (one-time install). Once installed, DWG works everywhere DXF does.

Quick start (easiest — no clone, no pip)

If you have uv installed, you don't clone anything or manage dependencies — uvx fetches and runs the server for you.

Install uv once:

# Windows (PowerShell):
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# macOS / Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh

Then add the server in one line:

# Claude Code:
claude mcp add cad -- uvx --from git+https://github.com/Codemod3/cad-mcp cad-mcp

For Claude Desktop, drop this into your config (see paths below) — no clone, no paths to edit:

{
  "mcpServers": {
    "cad": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Codemod3/cad-mcp", "cad-mcp"]
    }
  }
}

That's it. First run downloads deps automatically; later runs are instant. Restart the client and the tools appear. (DWG still needs the free ODA File Converter; DXF works immediately.)

Prefer to clone and manage Python yourself? See Manual install.


What it can do

Read / analyze (never modifies files)

Tool What it does
dxf_summary Overview — version, units, layers, entity counts, extents
dxf_list_layers All layers with color, linetype, on/frozen/locked state
dxf_get_layer_entities All entities on a specific layer
dxf_get_entities_by_type Filter by type (LINE, CIRCLE, TEXT, …), optional layer filter
dxf_get_text Extract all TEXT and MTEXT annotations
dxf_get_dimensions Extract all DIMENSION annotations
dxf_get_blocks List named block definitions
dxf_get_block_detail Inspect entities inside a block

Edit (writes to a copy — your original is never touched)

Tool What it does
cad_create_editable_copy Copy the original DXF/DWG to <name>_edited.dxf. Run this first.
cad_add_line Draw a line
cad_add_circle Draw a circle
cad_add_arc Draw an arc
cad_add_text Add a text label
cad_add_polyline Draw connected segments (LWPOLYLINE), optionally closed
cad_add_layer Create a layer
cad_delete_entity Delete one entity by its handle
cad_export_dwg Convert the edited .dxf back to .dwg (needs ODA File Converter)

Editing model — safe by design:

  1. Call cad_create_editable_copy on your original → it returns the copy's path.
  2. Pass that copy path to every edit tool. Edits save in place and stack, so keep drawing on the same file.
  3. Your original is never modified.
  4. DWG can't be written directly, so edits always happen on the .dxf copy; run cad_export_dwg at the end if you need a .dwg back.

Requirements

  • Python 3.10+ (only for the manual install; uvx handles this for you)
  • The Python packages in requirements.txt (installed below)
  • DWG only: the free ODA File Converter

Check your Python:

python --version      # must be 3.10 or newer (try python3 on macOS/Linux)

Manual install

Use this if you'd rather clone the repo and manage Python yourself.

1. Get the code

git clone https://github.com/Codemod3/cad-mcp.git
cd cad-mcp

2. Install dependencies

Recommended — use a virtual environment so nothing pollutes your system Python:

python -m venv .venv
# Windows (PowerShell):
.venv\Scripts\Activate.ps1
# macOS / Linux:
source .venv/bin/activate

pip install -r requirements.txt

Or install as a proper command (cad-mcp) via pip:

pip install .

3. Verify it runs

python server.py

It should print a startup line to stderr and then wait silently (it's listening for an MCP client over stdio). Press Ctrl+C to stop. If you see no import errors, you're ready to connect a client.


Connect to a client

Point your MCP client at server.py. Use the full absolute path to the file, and the same Python that has the dependencies installed.

Claude Desktop

Edit the config file:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "cad": {
      "command": "python",
      "args": ["C:\\full\\path\\to\\cad-mcp\\server.py"]
    }
  }
}

On macOS/Linux use "python3" and a /full/path/to/cad-mcp/server.py. If you used a virtualenv, point command at that venv's python, e.g. C:\\path\\to\\cad-mcp\\.venv\\Scripts\\python.exe.

Restart Claude Desktop. The CAD tools appear automatically.

Claude Code (CLI)

Easiest — no clone (needs uv):

claude mcp add cad -- uvx --from git+https://github.com/Codemod3/cad-mcp cad-mcp

If you cloned the repo instead:

claude mcp add cad -- python "C:\full\path\to\cad-mcp\server.py"

Scope (where the server is available):

claude mcp add cad --scope user  -- uvx --from git+https://github.com/Codemod3/cad-mcp cad-mcp   # all your projects
claude mcp add cad --scope project -- uvx --from git+https://github.com/Codemod3/cad-mcp cad-mcp  # writes .mcp.json for teammates

The repo also ships a ready .mcp.json — run Claude Code inside the project folder and the server loads automatically, no command needed.

Verify with /mcp, then just ask Claude to read or edit a CAD file. Remove with claude mcp remove cad.


DWG support

DWG files need the free ODA File Converter installed once:

  1. Download for your OS: https://www.opendesign.com/guestfiles/oda_file_converter
  2. Install it. Default Windows path: C:\Program Files\ODA\ODAFileConverter <version>\ODAFileConverter.exe
  3. Ensure it's on your PATH, or leave it at the default location where ezdxf finds it automatically.

Then use .dwg files exactly like .dxf — conversion is automatic. If the converter is missing, DWG tools return a clear error and DXF keeps working.


Usage examples

Once connected, just talk to Claude:

  • "Summarize this DXF file: C:\drawings\floor_plan.dxf"
  • "What layers are in site_plan.dwg?"
  • "Extract all the text annotations from my drawing."
  • "Make an editable copy of plan.dxf, then add a circle radius 5 at (10,10) on a new layer called NOTES."
  • "Draw the outline of a 20×10 room as a closed polyline, then export it to DWG."

Supported entity types (read)

LINE, CIRCLE, ARC, LWPOLYLINE, TEXT, MTEXT, INSERT (block refs), DIMENSION, LEADER, ELLIPSE, SPLINE — all other types are still captured with their common attributes (layer, color, handle).


Development

Run the test suite (offline, DXF only — no ODA converter needed):

pip install -r requirements.txt pytest pytest-asyncio
python -m pytest

Troubleshooting

Symptom Fix
Tools don't appear in the client Use the absolute path to server.py; fully restart the client.
ModuleNotFoundError: ezdxf / fastmcp The command python isn't the one with deps. Point it at your venv's python, or pip install -r requirements.txt for that interpreter.
DWG tools error about ODA Install the ODA File Converter and make sure it's on PATH.
"Cannot edit a .dwg file in place" Expected — run cad_create_editable_copy first, edit the .dxf copy, then cad_export_dwg.
Client shows a broken/empty connection Something printed to stdout. This server logs only to stderr; if you added prints, remove them — stdout is the MCP protocol channel.

License

MIT — see LICENSE.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选