ZWCAD MCP
中望CAD(ZWCAD)MCP 服务。让大模型通过 MCP 协议 直接操控中望CAD 平台与中望机械CAD,完成绘图、标注、图层/块/样式管理, 以及图框、标题栏、明细表(BOM)等机械操作。
共计 40 个工具:平台 27 个(不依赖机械环境)+ 机械 11 个(需中望机械CAD)+ 诊断 2 个。
走 npm 渠道或离线包时是 41 个——启动器会额外注入
zwcad_wait_ready, 用于等待 Python 运行时就绪。PyPI 版直接跑 Python,没有这一层。
安装
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 客户端
三条渠道的对比
同一个服务共发布三处,工具集与版本号完全一致,区别只在启动方式:
| 渠道 | 启动 | 需要 Python | 需要 Node | 需要联网 |
|---|---|---|---|---|
| PyPI(本页) | python -m zwcad2d |
3.10+ 自备 | ❌ | 安装时需要 |
| npm | npx -y zwcad-mcp |
启动器自动准备 | 18+ | 首次需要 |
| 离线包 | node bridge.js |
❌ 自带 | 推荐 18+ | ❌ 不需要 |
如果你的机器已经有可用的 Python 环境,本页这套更轻:没有中间层,启动即用。
如果你的机器不能联网、没有 Python、也不允许自行安装,用离线包:
从 Releases 下载
zwcad-mcp-<版本>-win-x64-offline.zip,解压即用。
源码与反馈
License
MIT
Metadata
Release files for zwcad-mcp 0.3.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zwcad_mcp-0.3.11.tar.gz | 45.7 kB | With provenance | Details for zwcad_mcp-0.3.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zwcad_mcp-0.3.11-py3-none-any.whl | Python 3 | none | any | Details for zwcad_mcp-0.3.11-py3-none-any.whl |
Total release size: 95.9 kB
Release files / zwcad_mcp-0.3.11.tar.gz
| Download URL | zwcad_mcp-0.3.11.tar.gz |
|---|---|
| Size | 45.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
855cd230a3728d63abf6c7b38b7f864fd618b359972ec2006d9716fcc9cd1935
|
|
BLAKE2b-256 checksum How to use checksums |
4567d66f8688e5c0ed0993d8e681694d10672f406caabb6fe980f09584be712c
|
| 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 6, 2026.
Transparency logRelease files / zwcad_mcp-0.3.11-py3-none-any.whl
| Download URL | zwcad_mcp-0.3.11-py3-none-any.whl |
|---|---|
| Size | 50.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03b7a9ca3150363a9f921085b5845507d18c62b419bf76835b1debb9530d5eea
|
|
BLAKE2b-256 checksum How to use checksums |
30e82e7fde3d97dd40f6ada1ebd7000c68273f6e8bedf1c3b86cbb3a27b39a16
|
| 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 6, 2026.
Transparency logSecurity for zwcad-mcp 0.3.11
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.
Attestation for zwcad_mcp-0.3.11.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 6, 2026.
Transparency logA 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.