Skip to main content

ZWCAD MCP

中望CAD(ZWCAD)MCP 服务。让大模型通过 MCP 协议 直接操控中望CAD 平台与中望机械CAD,完成绘图、标注、图层/块/样式管理, 以及图框、标题栏、明细表(BOM)等机械操作。

共计 41 个工具:平台 27 个(不依赖机械环境)+ 机械 11 个(需中望机械CAD)+ 诊断 2 个。

安装

pip install zwcad-mcp

依赖 fastmcp、pyzwcad、pyzwcadmech、comtypes、pywin32,pip 会自动安装。

运行

python -m zwcad2d

这是一个 stdio 方式的 MCP 服务,通常由客户端拉起,不需要你手动执行。

环境要求

  • Windows 10/11 x64
  • Python 3.10+
  • 中望CAD 或 中望机械CAD 已启动,且至少打开一张 DWG

接入客户端

把下面整段放进客户端的 MCP 配置文件(Claude Desktop 的 claude_desktop_config.json、 Cursor 的 .cursor/mcp.json 等):

{
  "mcpServers": {
    "zwcad-2d": {
      "command": "python",
      "args": ["-m", "zwcad2d"],
      "env": { "PYTHONUTF8": "1" }
    }
  }
}

如果用的是虚拟环境,把 python 换成该环境的完整路径,例如 D:\\project\\.venv\\Scripts\\python.exe。

也可以用 uvx 免预装拉起:

{
  "mcpServers": {
    "zwcad-2d": {
      "command": "uvx",
      "args": ["zwcad-mcp"],
      "env": { "PYTHONUTF8": "1" }
    }
  }
}

验证是否可用

服务启动后,让 AI 调用诊断工具:

zwcad_diagnose(probe_cad: true)

返回里 platform.available 为 true 表示已连上 ZWCAD。

排障

现象 处理
ModuleNotFoundError: No module named 'zwcad2d' 确认 pip install zwcad-mcp 与运行用的是同一个 Python
报「未找到可用的 Python」或导入依赖失败 补装依赖:pip install fastmcp pyzwcad pyzwcadmech comtypes pywin32
platform.available=false ZWCAD 未启动,或未打开 DWG。启动后重连客户端
机械工具报 TYPELIB_NOT_LOADED 需中望机械CAD 已启动;平台工具不受影响

关于 -2147312566(加载类型库/DLL 时出错)

这是机械类型库的已知情况,不是文件缺失或权限问题。根因:ZwmToolKit.tlb 内部引用了另一个仅在 ZWCAD 进程运行时才可解析的类型库。

  • ZwmToolKit.tlb 本身可被正常加载,14 个类型中仅 ZwmBalloonWrapper 的第二个基类型解析失败
  • 该接口自身 cFuncs=0、cVars=0,是无方法的空壳,跳过不损失功能
  • 处置:确保 ZWCAD 已启动并打开 DWG,然后完全重启 MCP 客户端

与 npm 版的区别

同一个服务也发布在 npm(npx -y zwcad-mcp)。两者的工具集与版本号完全一致,区别在启动方式:

PyPI 版(本页) npm 版
启动 python -m zwcad2d npx -y zwcad-mcp
Python 环境 需要你自备 3.10+ 启动器自动探测并准备隔离 venv
Node.js 不需要 需要 18+
首次启动耗时 即时 约 30~60 秒(后台装依赖),握手仅约 120 ms
内置诊断 zwcad_diagnose 额外提供 zwcad_wait_ready 与启动器视角诊断

如果你的机器已经有可用的 Python 环境,本页这套更轻:没有中间层,启动即用。

源码与反馈

License

MIT

Metadata

Release files for zwcad-mcp 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zwcad-mcp 0.3.5
File Size Uploaded Provenance Actions
zwcad_mcp-0.3.5.tar.gz 44.7 kB With provenance Details for zwcad_mcp-0.3.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zwcad-mcp 0.3.5
File Interpreter ABI Platform Actions
zwcad_mcp-0.3.5-py3-none-any.whl Python 3 none any Details for zwcad_mcp-0.3.5-py3-none-any.whl

Total release size: 93.8 kB

Release files / zwcad_mcp-0.3.5.tar.gz

Download URL zwcad_mcp-0.3.5.tar.gz
Size 44.7 kB
Tags Source
SHA-256 checksum
How to use checksums
47c402cd0ab3b1e19021b0f0f46e3c5492400ed62a92ca2531ff437276a90d53
BLAKE2b-256 checksum
How to use checksums
b3f61412dc39847ce7a023ed3bb6806202c2cb18deabb837329248ff4537e58f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / zwcad_mcp-0.3.5-py3-none-any.whl

Download URL zwcad_mcp-0.3.5-py3-none-any.whl
Size 49.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6809a6aa260d3f5881466e83487aec67ffbbe6c94e5286b349cfae7cda80b84
BLAKE2b-256 checksum
How to use checksums
7c2077f1c1b38b5211a6dbdc94fa9df0b5dd51cd46bf4f87504d6f79704e3c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for zwcad-mcp 0.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zwcad_mcp-0.3.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page