solidworks-mcp
Drive a local SOLIDWORKS install via COM to build parametric parts, sanity-check printability, and hand models to Bambu Studio for FDM printing.
Check connection (
sw_status): report whether SOLIDWORKS is running, the active document, and body count.Build a plate (
sw_plate): create a centered rectangular plate (default 60×40×5 mm) extruded along +Z, rebuilding the model and clearing existing holes.Add holes (
sw_hole): place a through-hole at an x/y offset from the plate center, the whole model rebuilding each time.Clear holes (
sw_holes_clear): wipe all holes and rebuild.Check printability (
sw_check_printability): get 0.4 mm-nozzle warnings (wall thickness, hole diameter, edge distance).Save the part (
sw_save_part): write an .SLDPRT (default<out>/agent_part.SLDPRT).Export STL (
sw_export_stl): produce an STL (default<out>/agent_part.STL), clearing selection first so the whole body exports.Open in Bambu Studio (
sw_open_in_bambu): launch the Bambu Studio GUI with the STL for manual slicing and printing.
Note: the README also describes extra tools not in this schema (sw_phone_stand, sw_part, sw_export_3mf, and overwrite flags on save/export). Everything runs locally; only SOLIDWORKS itself is required under your own license.
Drives a local SOLIDWORKS installation via COM to perform parametric CAD modeling, including creating plates and holes, building phone-stand parts, checking FDM printability, saving .SLDPRT files, and exporting STL/3MF models.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@solidworks-mcp 建一块60×40×5的板,中心开8mm孔,检查可打印性,导出STL并打开Bambu Studio"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
solidworks-mcp
通过 COM 驱动本机 SOLIDWORKS 做参数化建模,衔接 Bambu Studio 做 FDM 3D 打印的 MCP Server。
面向场景:在 DSH / Claude / Cursor 等 MCP 客户端里,用自然语言说「建一块 60×40×5 的板,中心开 8mm 孔,检查可打印性,导出 STL 并打开 Bambu Studio」,agent 调用本服务的工具完成建模、检查、导出与交付。
环境要求
Windows 10/11 x64
本机安装并已授权 SOLIDWORKS(2024 已验证,COM 自动激活
SldWorks.Application)。SOLIDWORKS 是 Dassault Systèmes 的商业软件,需要你自己的有效许可——本插件不提供、也不绕过它。Python ≥ 3.10(由
uvx自动提供即可)(可选)Bambu Studio:仅用于最后一步打开模型,人工切片打印。Bambu Studio 是独立第三方应用,遵循其自身发布许可。
Related MCP server: solidworks-mcp
安装(固定版本)
本包目前通过 git 源分发(未发布到 PyPI)。请固定到版本标签,避免引用移动分支:
# uvx 直接运行(推荐;从固定 tag 安装,依赖自动解析)
uvx --from "https://github.com/wangruiyu070802/solidworks-mcp@v0.2.0" solidworks-mcp
# 或先安装成命令再启动
uv tool install "https://github.com/wangruiyu070802/solidworks-mcp@v0.2.0"
solidworks-mcp安装过程需要联网下载依赖与源码;运行阶段只在本机操作,不上传任何模型。
启动(MCP stdio 模式):
solidworks-mcp自测(会真实拉起 SOLIDWORKS 建模;只新建/关闭本服务自己创建的临时文档,从不关闭你的其他文档。请在无未保存工作的 SOLIDWORKS 会话里跑):
solidworks-mcp --selftest接入 MCP 客户端
DSH「MCP连接器」市场中搜 solidworks 一键连接(上架后),或手动配置 stdio:
{
"mcpServers": {
"solidworks": {
"command": "uvx",
"args": ["--from", "https://github.com/wangruiyu070802/solidworks-mcp@v0.2.0", "solidworks-mcp"],
"transport": "stdio"
}
}
}Claude Desktop / Cursor 等价配置:command: solidworks-mcp(已 uv tool install 时)或 uvx --from ...@v0.2.0 solidworks-mcp。
工具一览
工具 | 作用 |
| 连接体检:SW 版本、活动文档、实体数、模型参数(可能通过 COM 启动 SOLIDWORKS) |
| 建平板(原点居中,+Z 拉伸),清空已有孔,重建并替换本服务自己的模型 |
| 加通孔(相对板中心偏移),模型整体重建 |
| 清空所有孔 |
| 一体打印手机支架(真实零件,见下) |
| 建 4 件套「贴地 V 叉 + 单脊柱」手机支架的任意一件 |
| 0.4 喷嘴打印可行性建议(壁厚/孔径/孔边距,返回 WARN 而非强制拦截) |
| 保存 .SLDPRT(默认不覆盖,先写临时文件再原子替换) |
| 导出 STL(默认不覆盖,附网格统计与包围盒) |
| 从 STL 重打包成规范 3MF(单位 mm、顶点去重),Bambu 可直接打开 |
| 启动 Bambu Studio GUI 加载模型,人工切片/打印 |
所有长度单位均为毫米(mm)。
副作用与安全边界
本服务会真实操作本机 SolidWorks,调用前请了解这些副作用:
文档:建模/加孔/换零件会重建并替换本服务自己创建的模型文档。服务通过标题跟踪自己创建的文档,
_close_owned只关闭这些文档——从不枚举关闭你的其他文档,因此不会丢失你未保存的工作。状态与日志:写
model_state.json与server_debug.log到输出目录(默认<cwd>/out)。产物文件:导出 STL/SLDPRT/3MF 默认不覆盖已存在文件(需显式
overwrite=true),且先写临时文件再原子替换——导出失败不会破坏原文件。输出路径默认限定在输出目录内(设SOLIDWORKS_ALLOW_EXTERNAL_OUTPUT=1才允许任意路径)。GUI:
sw_open_in_bambu会拉起 Bambu Studio 窗口。SOLIDWORKS 启动:
sw_status、以及任何需要连接 COM 的工具,在 SolidWorks 未运行时可能通过 COM 激活启动它。串行:COM 会话不是线程安全的,工具调用需串行执行。
手机支架(sw_phone_stand)
第一个真实零件,也是「多块矩形拉伸」原语的样板:模型由一串 立在底板上的竖直棱柱拼成,重叠部分自动并成一个实体, 因此零悬垂、零支撑、零装配。
结构:
底板 120×70×3,深度按倾角自动算(
depth_mm=0)前挡筋 分左右两段,中间留 22mm 充电通道 —— 线插着也能直接放进去, 插头从通道落到板面、线往前出走
靠背棱(默认 z=28、z=80 两片):顶角共线于同一倾角, 手机背面同时压在两条棱上(两条线定一个面,不是刀尖平衡)
关键结论(推过几何才确认,别绕回去):刚性一体件只能有一个倾角。 手机背面那条线之后不能有任何材料,否则挡住 —— 支撑必须是那个方向上最外侧 的表面,角度就被钉死了。要多角度只能换参数重打一个,或者上铰链/卡齿结构 (那就不是「零装配」了)。
产物示例:out/phone_stand_30deg.{3mf,STL,SLDPRT}、
out/phone_stand_45deg.{3mf,STL,SLDPRT}(30° 看视频 / 45° 躺床上仰看),
out/phone_stand_designs.html(8 种支架设计的可视化对比与取舍分析)。
打印可行性建议(0.4 喷嘴)
最小壁厚 0.8mm(2 道外墙)
最小孔径 1.2mm(更小会缩孔,建议打印后钻孔)
孔距板边最小 0.8mm(否则破边)
配合间隙建议 0.15mm/侧
sw_check_printability 在建模阶段就返回 WARN(建议性告警),而不是等切片失败。
这些是启发式建议,不是强制执行,PASS 也不构成制造安全保证——最终切片、
材料与打印参数请以 Bambu Studio 与你的打印机实测为准。
环境变量(可选)
变量 | 作用 |
| .prtdot 零件模板路径(默认自动探测,含中文版 |
| Bambu Studio 可执行文件路径(默认探测常见安装位置) |
| 产物目录(默认 |
| 设为 |
许可与第三方依赖
本插件:MIT(见
LICENSE)。SOLIDWORKS:Dassault Systèmes 的商业软件,运行它需要你自己的有效许可。
Bambu Studio:独立第三方应用,遵循其自身发布许可;仅由
sw_open_in_bambu拉起。「免费」仅指本插件的 MIT 授权,不含 SOLIDWORKS 授权与 Bambu Studio。
已知限制
Bambu Studio 命令行切片:部分版本(实测 02.09.01.70)二进制无 CLI 参数字符串,调用即静默退出。已降级为「自动打开 GUI + 人工点切片/打印」。
工具调用需串行:并行调用会争用 COM 会话导致失败。
仅 Windows:依赖 SOLIDWORKS COM。
文档所有权按标题跟踪:服务通过文档标题(如
Part1)识别自己创建的文档;若跨进程重启后 SOLIDWORKS 复用了相同标题给其他文档,存在极小概率的误判,请勿在关键未保存工作旁运行。
本机 COM 关键经验(开发踩坑记录)
该构建下
GetFeatureCount/FirstFeature/GetTypeName2等成员全部以属性暴露,不能加括号调用SelectByID2晚绑定必报类型不匹配 → 一律特征树遍历 +Feature.Select2拉伸前必须先选中草图,否则
FeatureExtrusion2返回 NoneFeatureCut4任何参数个数都报DISP_E_PARAMNOTOPTIONAL→ 方案改为「矩形+圆同一草图一次拉伸」,绕开切除保存/导出只能用
ModelDoc2.SaveAs(path)导出 STL 前必须
ClearSelection2(True),否则只导出选中面
开发
pip install -e .[dev]
python -m unittest discover -s tests -v # 纯函数单测,不依赖 SOLIDWORKS
solidworks-mcp --selftest # 集成自测,真实操作 SOLIDWORKS发布
上架 DSH MCP 连接器市场:见 docs/PUBLISHING.md,卡片 Descriptor 见 connectors/solidworks-cad.json。
License
MIT
Available Tools
8 toolssw_check_printabilityA
检查当前模型是否适合 0.4 喷嘴 FDM 打印,返回硬护栏告警。
Inputs: no named parameters.
sw_export_stlA
导出 STL(默认 /agent_part.STL)。导出前清空选择,避免只导出选中面。
Inputs: path.
sw_holeB
在平板上加一个通孔(孔心相对板中心偏移 x/y)。模型会整体重建。
Inputs: x_mm, y_mm, diameter_mm.
sw_holes_clearA
清空所有孔并重建模型。
Inputs: no named parameters.
sw_open_in_bambuB
把 STL 交给 Bambu Studio 界面打开,供人工切片与打印。
部分 Bambu Studio 版本(如 02.09.01.70)无命令行切片能力,因此采用 「自动打开 GUI + 人工点切片/打印」的半自动方案。
Inputs: stl_path.
sw_plateA
建一块长方形平板(原点居中,厚度沿 +Z 拉伸)。会重建模型并清空已有孔。
Inputs: width_mm, length_mm, thickness_mm.
sw_save_partB
保存 .SLDPRT 到磁盘(默认 /agent_part.SLDPRT)。
Inputs: path.
sw_statusA
检查 SolidWorks 连接状态:是否在运行、当前文档、实体数量。
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools have clearly distinct roles (status, plate creation, hole addition, printability check, save, export, open-in-slicer). The only overlap is between sw_holes_clear and sw_plate, which also clears holes, but descriptions make the distinction workable.
All tools use a consistent sw_ prefix and snake_case, with verb-oriented suffixes like check_printability, save_part, export_stl, open_in_bambu. Minor deviation: sw_holes_clear uses a noun-first form and sits oddly next to the singular sw_hole.
Eight tools is well-scoped for a parametric plate/hole CAD pipeline: create, modify, validate, persist, export, and hand off to a slicer. Each tool earns its place with no filler.
The create-plate → add-hole → check → save → export → open workflow is fully covered. Gaps exist around editing individual holes (no remove-one or resize/reposition after creation) and no geometry query beyond status, but agents can work around these by rebuilding.
Related MCP Connectors
Parametric 3D CAD for AI agents: build print-ready parts, check them, export STL, 3MF or STEP.
Text-to-CAD: build exact STEP or 3MF/STL on the server, each stated requirement measured.
CAD in ChatGPT and Claude: editable parts, STEP/STL/drawings, in-chat 3D, automatic checks.
Design 3D-printable parts by chatting: create, edit, render and publish parametric forges.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to automate SolidWorks (open/save parts, modify dimensions, export STEP) via COM, and optionally generate geometry using build123d code-CAD with PNG previews.MIT
- FlicenseNot gradedqualityBmaintenanceDrives SolidWorks 2022 on Windows via COM to perform CAD operations like sketching, features, dimensioning, and mass property inspection from AI assistants.2-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to build, measure, verify, and correct parametric SolidWorks parts and assemblies locally via the COM API, supporting operations like sketching, extruding, modeling, dimensioning, material assignment, export, and assembly mating.MIT
- AlicenseAqualityBmaintenanceEnables generating parametric 3D-printable parts from OpenSCAD/CadQuery models, exporting STL/3MF files, running DFM checks, and retrieving Bambu X1 Carbon starting profile notes.8MIT