Skip to main content
Glama
Christancho-co

solidworks-mcp

solidworks-mcp

一个 MCP 服务器,用于驱动本地 SOLIDWORKS 安装,以构建和修改参数化实体模型。

已在 SOLIDWORKS 2026 SP0(修订版 34.0.0)上于 Windows 11 验证通过。

工作原理

MCP client  ──stdio──►  solidworks-mcp  ──COM──►  SLDWORKS.exe

SOLIDWORKS 暴露了经典的 COM 自动化 API。服务器会附加到正在运行的实例(或启动一个实例),每个工具都映射到该 API 上。

所有长度单位均为毫米,所有角度单位均为度。 SOLIDWORKS API 内部使用公制 SI 单位;转换发生在工具边界处。

Related MCP server: solidworks-mcp

要求

  • 在同一台机器上安装并授权 SOLIDWORKS。

  • Python 3.12+,64 位——必须与 SOLIDWORKS 的架构匹配,否则 COM 无法绑定。

  • 使用 uv 进行依赖管理。

安装

uv sync

注册到 MCP 客户端

对于 Claude Code:

claude mcp add solidworks -- uv --directory E:\solid run solidworks-mcp

对于读取 JSON 配置的客户端:

{
  "mcpServers": {
    "solidworks": {
      "command": "uv",
      "args": ["--directory", "E:\\solid", "run", "solidworks-mcp"]
    }
  }
}

工具

会话与文档solidworks_statusnew_partopen_partsave_partclose_part

草图绘制list_planesstart_sketchstart_sketch_on_facesketch_linesketch_centerlinesketch_circlesketch_rectanglesketch_arcsketch_polygonsketch_ellipseadd_sketch_dimensionadd_sketch_relationfinish_sketch

特征extrudecut_extruderevolvefilletselect_entityclear_selection

参数化控制list_featureslist_dimensionsset_dimensionadd_equationlist_equationsrebuild

检查get_measurementscapture_view

一个完整的示例

构建一个 80 × 50 × 10 mm 的带孔板,然后进行参数化驱动:

new_part
start_sketch(plane="front")
sketch_rectangle(0, 0, 80, 50)
add_sketch_dimension(entities=[[40, 0]], value=80)   -> "D1@Croquis1"
add_sketch_dimension(entities=[[0, 25]], value=50)   -> "D2@Croquis1"
finish_sketch
extrude(depth=10)

start_sketch(plane="front")
sketch_circle(40, 25, 8)
finish_sketch
cut_extrude(depth=10, end_condition="through_all", reverse=True)

fillet(radius=5, edges=[[0,0,5], [80,0,5], [80,50,5], [0,50,5]])

set_dimension("D1@Croquis1", 120)   -> the solid rebuilds to 120 mm wide
get_measurements                    -> bounding box 120 x 50 x 10 mm
capture_view("isometric")

值得了解的事项

通过 API 创建的草图没有尺寸。 SOLIDWORKS 只会在你要求时添加驱动尺寸,因此仅用 sketch_* 绘制的草图没有任何可驱动的内容。如果你打算之后修改几何体,请在草图仍处于打开状态时调用 add_sketch_dimension

切除方向遵循草图法线。 在前视基准面上绘制草图,切除一个沿远离该面方向拉伸的实体时,需要 reverse=True,否则切除会进入空白空间并失败。

参考基准面名称是本地化的。 西班牙语安装会将特征命名为 Croquis1Saliente-Extruir1。工具接受逻辑别名 front/top/right,并通过特征树中的位置来解析它们,因此无论 UI 语言如何都能正常工作。list_planes 会报告真实名称。

SOLIDWORKS 必须正在运行。 没有受支持的无头模式。如果应用程序尚未打开,服务器会启动它。

模态对话框会使 COM 死锁。 add_sketch_dimension 会临时禁用"输入尺寸值"首选项(否则会弹出模态框并挂起调用),并在之后恢复它。

实现说明

pywin32 的两种行为塑造了代码结构,且很容易踩坑:

  • 零参数的 COM 成员在属性访问时会被自动调用。 在后期绑定下,doc.GetTitle 返回标题字符串;doc.GetTitle() 会抛出 TypeError: 'str' object is not callable。带有一个或多个参数的成员则正常调用。

  • 类型化空值和输入/输出参数需要显式的 VARIANT。 可选的接口参数会拒绝裸 None 并报"类型不匹配",需要 VARIANT(VT_DISPATCH, None);错误和警告输出参数需要 VARIANT(VT_BYREF | VT_I4, 0),结果从 .value 读回。

COM 对象位于单线程单元中,因此 com_bridge.py 将所有调用汇集到一个专用线程中。constants.py 中的枚举值是从 swconst.tlb 读取的,而不是从文档中抄录的,因为有些值与常见引用值不同——swEndCondThroughAllBoth 是 9,而不是 8。

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables 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
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI (e.g., Claude) to control SolidWorks via natural language, automating part creation, sketching, and feature operations through the Model Context Protocol.
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server for controlling a live SOLIDWORKS session through the Windows COM API, enabling native CAD operations like sketches, features, bodies, views, and exports, plus transactional plans and vectorization.
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • Agent-first CAD: editable .kcad.ts source, deterministic review, OpenCASCADE kernel.

  • Convert Revit files to XKT, IFC, or DWG and query BIM data via natural language.

  • Revit model query + APS Design Automation runner.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Christancho-co/solidworks-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server