solidworks-mcp 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- solidworks_mcp-0.2.1/LICENSE +21 -0
- solidworks_mcp-0.2.1/PKG-INFO +306 -0
- solidworks_mcp-0.2.1/README.md +281 -0
- solidworks_mcp-0.2.1/pyproject.toml +46 -0
- solidworks_mcp-0.2.1/setup.cfg +4 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/__init__.py +8 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/binding.py +96 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/com_worker.py +99 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/constants.py +106 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/errors.py +9 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/server.py +507 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/session.py +2522 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp/units.py +21 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp.egg-info/PKG-INFO +306 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp.egg-info/SOURCES.txt +23 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp.egg-info/dependency_links.txt +1 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp.egg-info/entry_points.txt +2 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp.egg-info/requires.txt +5 -0
- solidworks_mcp-0.2.1/src/solidworks_mcp.egg-info/top_level.txt +1 -0
- solidworks_mcp-0.2.1/tests/test_assembly.py +243 -0
- solidworks_mcp-0.2.1/tests/test_binding.py +84 -0
- solidworks_mcp-0.2.1/tests/test_features.py +382 -0
- solidworks_mcp-0.2.1/tests/test_logic.py +295 -0
- solidworks_mcp-0.2.1/tests/test_packaging.py +37 -0
- solidworks_mcp-0.2.1/tests/test_units.py +28 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Henk Jan Baard
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: solidworks-mcp
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: MCP server that drives a local SolidWorks instance over COM for parametric part modelling.
|
|
5
|
+
Author: Henk Jan Baard
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/hjbaard/SolidWorks-MCP
|
|
8
|
+
Project-URL: Repository, https://github.com/hjbaard/SolidWorks-MCP
|
|
9
|
+
Project-URL: Changelog, https://github.com/hjbaard/SolidWorks-MCP/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issues, https://github.com/hjbaard/SolidWorks-MCP/issues
|
|
11
|
+
Keywords: solidworks,mcp,cad,com,parametric,3d-printing
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: pywin32>=306
|
|
21
|
+
Requires-Dist: mcp<2,>=1.26
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# SolidWorks MCP
|
|
27
|
+
|
|
28
|
+
Let an AI agent (Claude, or any other MCP client) model real parametric parts and
|
|
29
|
+
assemblies in **your own SolidWorks** — and **check its own work**. Every
|
|
30
|
+
modelling call returns the measured volume, mass and bounding box, so the agent
|
|
31
|
+
can compare the result with the spec and correct itself instead of guessing that
|
|
32
|
+
it "looks about right".
|
|
33
|
+
|
|
34
|
+
<!-- mcp-name: io.github.hjbaard/solidworks-mcp -->
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="https://raw.githubusercontent.com/hjbaard/SolidWorks-MCP/main/Docs/images/bracket.png" width="32%" alt="3D-print mounting bracket with counterbored holes, bolt circle and cable slot">
|
|
38
|
+
<img src="https://raw.githubusercontent.com/hjbaard/SolidWorks-MCP/main/Docs/images/vase.png" width="32%" alt="Revolved and shelled vase">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/hjbaard/SolidWorks-MCP/main/Docs/images/pipe.png" width="32%" alt="Swept pipe with rounded bends">
|
|
40
|
+
</p>
|
|
41
|
+
<p align="center"><sub>Built by the tools themselves: a mounting bracket (every step checked against a hand calculation), a revolved + shelled vase, a swept pipe.</sub></p>
|
|
42
|
+
|
|
43
|
+
## Why this server
|
|
44
|
+
|
|
45
|
+
- **It verifies, not just generates.** Features report measured geometry;
|
|
46
|
+
dimensions and mates are measured back after the rebuild.
|
|
47
|
+
- **Real CAD, not just primitives.** Extrude, revolve, sweep, loft and splines;
|
|
48
|
+
holes, counterbores, slots and pockets on any face; fillets, chamfers, shells,
|
|
49
|
+
patterns, equations and materials. Assemblies with mates and interference
|
|
50
|
+
checks. STEP/STL/3MF export and screenshots. 45 tools in total.
|
|
51
|
+
- **It fails loud.** A call that cannot do what was asked returns
|
|
52
|
+
`{ok: false, error}` with the cause, never silently wrong geometry.
|
|
53
|
+
- **A fixed, typed tool surface.** There is no "run arbitrary code" tool; the
|
|
54
|
+
agent can only do what the tools allow.
|
|
55
|
+
- **Tested against real SolidWorks.** 175 tests; each feature's integration test
|
|
56
|
+
compares the result with a hand calculation.
|
|
57
|
+
- **Local.** It talks to your running SolidWorks over COM; the server itself
|
|
58
|
+
makes no network calls.
|
|
59
|
+
|
|
60
|
+
## Quickstart
|
|
61
|
+
|
|
62
|
+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/).
|
|
63
|
+
2. **Start SolidWorks** and leave it open (the server attaches to the running
|
|
64
|
+
instance — it does not launch one).
|
|
65
|
+
3. Register the server with your MCP client.
|
|
66
|
+
|
|
67
|
+
**Claude Code:**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
claude mcp add solidworks -- uvx --from git+https://github.com/hjbaard/SolidWorks-MCP solidworks-mcp
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Claude Desktop** (`claude_desktop_config.json`) or any other client:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"mcpServers": {
|
|
78
|
+
"solidworks": {
|
|
79
|
+
"command": "uvx",
|
|
80
|
+
"args": ["--from", "git+https://github.com/hjbaard/SolidWorks-MCP", "solidworks-mcp"]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
4. Ask for a part, for example:
|
|
87
|
+
|
|
88
|
+
> Design a 100 × 80 × 8 mm mounting plate with a Ø16 mm centre bore, four
|
|
89
|
+
> counterbored M5 holes 12 mm from the corners and R5 corners. Check the
|
|
90
|
+
> volume against your own calculation, then export a fine STL.
|
|
91
|
+
|
|
92
|
+
## Requirements and compatibility
|
|
93
|
+
|
|
94
|
+
- Windows, with SolidWorks installed, licensed and **running**.
|
|
95
|
+
- Python 3.11+ (uv fetches one if needed).
|
|
96
|
+
- **Tested on SOLIDWORKS 2026** (3DEXPERIENCE R2026x). The API calls it uses
|
|
97
|
+
exist since SOLIDWORKS 2020 SP2, so 2020–2025 should work, but that is
|
|
98
|
+
**untested**. Tried another version? Please
|
|
99
|
+
[open an issue](https://github.com/hjbaard/SolidWorks-MCP/issues) with the
|
|
100
|
+
result, whether it worked or not.
|
|
101
|
+
|
|
102
|
+
**Status: early (v0.2).** It works end-to-end, but tool names and conventions
|
|
103
|
+
may still change. See [CHANGELOG.md](https://github.com/hjbaard/SolidWorks-MCP/blob/main/CHANGELOG.md).
|
|
104
|
+
|
|
105
|
+
## Troubleshooting
|
|
106
|
+
|
|
107
|
+
- **"Geen draaiende SolidWorks gevonden" / connection fails** — SolidWorks must be
|
|
108
|
+
*running* before you start the server or run a script; it attaches to the active
|
|
109
|
+
instance via `GetActiveObject` and does not launch one.
|
|
110
|
+
- **First call is slow or `EnsureModule` errors** — the first COM call generates the
|
|
111
|
+
makepy typelib wrappers under your temp `gen_py` folder. Let it finish; if it gets
|
|
112
|
+
into a bad state, delete the `gen_py` cache and retry. Early binding is mandatory on
|
|
113
|
+
this build (see [Architecture](#architecture)).
|
|
114
|
+
- **A feature returns `{ok: false, error: ...}`** — that is by design: every tool
|
|
115
|
+
fails loud with a readable (Dutch) message rather than silently producing wrong
|
|
116
|
+
geometry. Read the message; it names the likely cause.
|
|
117
|
+
- **Only tested against SOLIDWORKS 2026 (3DEXPERIENCE R2026x).** On other builds the
|
|
118
|
+
verified enum values or method signatures may differ — re-run
|
|
119
|
+
`scripts/introspect_api.py` to inspect your installed typelib.
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
Clone the repository, then install it editable into a venv:
|
|
124
|
+
|
|
125
|
+
```powershell
|
|
126
|
+
python -m venv .venv
|
|
127
|
+
.\.venv\Scripts\python.exe -m pip install -e .[dev]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
To run the MCP server from this checkout instead of via uvx, point your client
|
|
131
|
+
at the venv's Python:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"mcpServers": {
|
|
136
|
+
"solidworks": {
|
|
137
|
+
"command": "C:\\path\\to\\SolidWorks-MCP\\.venv\\Scripts\\python.exe",
|
|
138
|
+
"args": ["-m", "solidworks_mcp.server"]
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Run the verification scripts
|
|
145
|
+
|
|
146
|
+
With SolidWorks open:
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
.\.venv\Scripts\python.exe scripts\probe_connection.py # M0
|
|
150
|
+
.\.venv\Scripts\python.exe scripts\m1_block.py # M1
|
|
151
|
+
.\.venv\Scripts\python.exe scripts\m2_parametric.py # M2
|
|
152
|
+
.\.venv\Scripts\python.exe scripts\test_mcp_server.py # M3 (full MCP loop over stdio)
|
|
153
|
+
.\.venv\Scripts\python.exe scripts\m5_demo_bracket.py # M5 (3D-print bracket, every step verified)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`scripts/introspect_api.py` regenerates/inspects the installed typelib and prints
|
|
157
|
+
verified enum values — run it if SolidWorks is upgraded and signatures change.
|
|
158
|
+
|
|
159
|
+
### Tests
|
|
160
|
+
|
|
161
|
+
```powershell
|
|
162
|
+
.\.venv\Scripts\python.exe -m pytest # all tests
|
|
163
|
+
.\.venv\Scripts\python.exe -m pytest -m "not solidworks" # fast unit layer, no SolidWorks
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Two layers: **pure unit tests** (units, selector/direction parsing, polygon
|
|
167
|
+
cleaning, the component-placement maths, and that every MCP tool forwards its
|
|
168
|
+
arguments to the right session method) run anywhere; **integration tests**
|
|
169
|
+
(`solidworks` marker) drive a running SolidWorks and verify each feature's
|
|
170
|
+
volume — or each component's placement — against a hand calc. They auto-skip if
|
|
171
|
+
SolidWorks isn't reachable.
|
|
172
|
+
|
|
173
|
+
## Tools
|
|
174
|
+
|
|
175
|
+
The server speaks MCP over **stdio**.
|
|
176
|
+
|
|
177
|
+
### Part tools
|
|
178
|
+
|
|
179
|
+
| Tool | Purpose |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `get_status` | Is SolidWorks reachable? revision + active/current part |
|
|
182
|
+
| `new_part` | Create a new empty part (becomes current) |
|
|
183
|
+
| `add_box(width_mm, height_mm, depth_mm, name)` | Sketch rectangle + extrude; returns mass properties |
|
|
184
|
+
| `add_cylinder(diameter_mm, height_mm, name)` | Cylinder by revolving a profile 360° about an axis (Y axis) |
|
|
185
|
+
| `add_disc(diameter_mm, thickness_mm, name)` | Disc/puck/flange: circle extruded along +Z (holes/patterns compose) |
|
|
186
|
+
| `add_cone(bottom_diameter_mm, top_diameter_mm, height_mm, name)` | Cone/frustum by revolve (top Ø = 0 → full cone) |
|
|
187
|
+
| `add_revolved_profile(profile_mm, angle_deg, name)` | Revolve any closed `(radius, height)` profile about the axis (shafts, vases, rings) |
|
|
188
|
+
| `add_swept_pipe(path_mm, diameter_mm, bend_radius_mm, name)` | Sweep a round profile along a 2D path with rounded bends (pipes, tubes, rods) |
|
|
189
|
+
| `add_swept_profile(profile_mm, path_mm, bend_radius_mm, name)` | Sweep any closed cross-section along a 2D path (rails, gaskets, trim, channels) |
|
|
190
|
+
| `add_lofted_solid(profiles_mm, heights_mm, name)` | Loft/blend 2+ polygon profiles on stacked parallel planes (transitions, adapters) |
|
|
191
|
+
| `add_extruded_profile(points_mm, depth_mm, name)` | Extrude any closed polygon `[[x,y],…]` (brackets, sections) |
|
|
192
|
+
| `add_extruded_spline(points_mm, depth_mm, name)` | Extrude a smooth closed spline through points (free-form/organic outlines) |
|
|
193
|
+
| `add_hole(diameter_mm, x_mm, y_mm, name)` | Cut a circular through-hole at (x, y) through the depth axis |
|
|
194
|
+
| `add_counterbore_hole(clearance_diameter_mm, cbore_diameter_mm, cbore_depth_mm, x_mm, y_mm, name)` | Counterbored screw hole (flush cap-head / heat-set insert) on +Z |
|
|
195
|
+
| `add_hole_on_face(diameter_mm, face, x_mm, y_mm, z_mm, name)` | Through-hole on ANY planar face at a 3D point (side holes, etc.) |
|
|
196
|
+
| `cut_profile(points_mm, depth_mm, name)` | Cut a polygon pocket/slot from the +Z face (blind or through) |
|
|
197
|
+
| `cut_profile_on_face(points_mm, face, depth_mm, name)` | Cut a polygon pocket on ANY face (3D points on the face) |
|
|
198
|
+
| `cut_slot(length_mm, width_mm, x_mm, y_mm, angle_deg, depth_mm, name)` | Cut a straight slotted hole (obround) on the +Z face at any angle |
|
|
199
|
+
| `add_fillet(radius_mm, edges, name)` | Round edges (`edges`: `all`, axis `x`/`y`/`z`, or indices `"2,5"`) |
|
|
200
|
+
| `add_chamfer(distance_mm, edges, name)` | Chamfer edges at 45° (`edges`: `all`, axis, or indices) |
|
|
201
|
+
| `add_shell(thickness_mm, open_face)` | Hollow to a wall thickness; open a face (`+z`/…) or `none` |
|
|
202
|
+
| `add_linear_pattern(count, spacing_mm, direction, feature_name)` | Repeat a feature N times along `+x`/`-x`/… |
|
|
203
|
+
| `add_circular_pattern(count, center_x_mm, center_y_mm, feature_name)` | Repeat a feature N times around an axis (bolt circle) |
|
|
204
|
+
| `set_dimension(dimension_name, value_mm)` | Change a named driving dim (e.g. `D1@BlockExtrude`), rebuild, remeasure |
|
|
205
|
+
| `set_equation(equation)` | Add a global equation linking dims (e.g. `"D1@BlockExtrude" = 25`) |
|
|
206
|
+
| `set_material(name, database)` | Assign a material (e.g. `6061 Alloy`) so mass/density are real |
|
|
207
|
+
| `rebuild(top_only)` | Force rebuild, report errors |
|
|
208
|
+
| `get_mass_properties` | Volume, mass, density, surface area, centre of mass, bounding box |
|
|
209
|
+
| `get_bounding_box` | Tight part bounding box (min/max/size, mm) |
|
|
210
|
+
| `list_faces` / `list_edges` | Inspect faces (normal/area/centre) and edges (type/axis/length) by index |
|
|
211
|
+
| `export(path, file_format, quality, deviation_mm, angle_deg)` | STEP/STL/IGES/Parasolid/3MF (silent; verifies file). STL/3MF tessellation: `quality` `coarse`/`fine`, or explicit `deviation_mm`+`angle_deg` |
|
|
212
|
+
| `screenshot(path)` | Isometric, zoom-to-fit PNG/BMP/JPG |
|
|
213
|
+
| `save_part(path)` / `open_part(path)` | Save to / open a native `.sldprt` |
|
|
214
|
+
| `close_part(save)` | Close the current part or assembly |
|
|
215
|
+
|
|
216
|
+
### Assembly tools
|
|
217
|
+
|
|
218
|
+
| Tool | Purpose |
|
|
219
|
+
|---|---|
|
|
220
|
+
| `new_assembly` | Create a new empty assembly (becomes the current document) |
|
|
221
|
+
| `open_assembly(path)` / `save_assembly(path)` | Open / save a native `.sldasm` |
|
|
222
|
+
| `insert_component(path, x_mm, y_mm, z_mm, fixed)` | Insert a part with its **origin** at (x, y, z); the first component is fixed by default |
|
|
223
|
+
| `list_components` | Name, path, fixed, position, rotation and bounding box of every component |
|
|
224
|
+
| `set_component_transform(name, x_mm, y_mm, z_mm, rx_deg, ry_deg, rz_deg)` | Move/rotate a component; the transform is read back and verified |
|
|
225
|
+
| `add_mate(comp_a, face_a, comp_b, face_b, mate_type, distance_mm, flip)` | Mate two planar faces: `coincident`, `distance`, `parallel`, `perpendicular` — measured back from the geometry afterwards |
|
|
226
|
+
| `check_interference` | Component pairs whose solids overlap, with the volume in mm³ (touching faces don't count) |
|
|
227
|
+
| `get_assembly_bounding_box` | Bounding box of the whole assembly (min/max/size, mm) |
|
|
228
|
+
|
|
229
|
+
`export` and `screenshot` work on assemblies too.
|
|
230
|
+
|
|
231
|
+
Faces are selected by direction in the component's **own** frame (`+x`, `-z`, …),
|
|
232
|
+
so a selector keeps meaning the same face however the component is turned. Add
|
|
233
|
+
`:inner` (e.g. `+y:inner`) for the cavity side of a hollow part — the inside of a
|
|
234
|
+
room wall instead of its outer skin.
|
|
235
|
+
|
|
236
|
+
All linear dimensions are **millimetres**; the server converts to/from the
|
|
237
|
+
SolidWorks-internal metre/radian units at the boundary.
|
|
238
|
+
|
|
239
|
+
## Architecture
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
src/solidworks_mcp/
|
|
243
|
+
binding.py early-binding plumbing (wrap raw dispatches in generated classes)
|
|
244
|
+
com_worker.py one dedicated STA thread; all COM calls serialised through it
|
|
245
|
+
session.py SolidWorks operations (must run on the COM thread)
|
|
246
|
+
server.py FastMCP tools that delegate to session via the worker
|
|
247
|
+
constants.py enum values read from the installed typelib (verified)
|
|
248
|
+
units.py mm<->m, deg<->rad
|
|
249
|
+
errors.py SolidWorksError -> agent-facing {ok:false,error}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Two non-obvious design decisions, both load-bearing:
|
|
253
|
+
|
|
254
|
+
1. **Early binding is mandatory.** On this build `GetActiveObject` returns a
|
|
255
|
+
dispatch whose `GetTypeInfo()` fails, so `EnsureDispatch`/`CastTo` cannot infer
|
|
256
|
+
types and pure late binding breaks (`IModelDoc2.FirstFeature` →
|
|
257
|
+
`DISP_E_MEMBERNOTFOUND`). We generate makepy wrappers from the installed
|
|
258
|
+
typelib and wrap each raw dispatch in the right interface class; calls then go
|
|
259
|
+
by dispid via `InvokeTypes`, bypassing name resolution. See `binding.py`.
|
|
260
|
+
|
|
261
|
+
2. **A dedicated COM thread.** COM is STA and thread-affine. The MCP server runs
|
|
262
|
+
on asyncio, so all COM work is pinned to one worker thread (`com_worker.py`)
|
|
263
|
+
that handlers post to and await — actively enforcing the "one COM session,
|
|
264
|
+
single-threaded" rule that does not hold automatically in an async server.
|
|
265
|
+
|
|
266
|
+
## Status and roadmap
|
|
267
|
+
|
|
268
|
+
Proven end-to-end against **SOLIDWORKS 2026 (3DEXPERIENCE R2026x)**:
|
|
269
|
+
|
|
270
|
+
| Milestone | What it proves | State |
|
|
271
|
+
|---|---|---|
|
|
272
|
+
| M0 | COM connection to a running SolidWorks | ✅ |
|
|
273
|
+
| M1 | new part → sketch rectangle → extrude → mass properties (volume matches hand calc) | ✅ |
|
|
274
|
+
| M2 | change a named dimension → rebuild → volume changes predictably | ✅ |
|
|
275
|
+
| M3 | full agent loop via the MCP server: build → measure → correct → export STEP/STL + screenshot | ✅ |
|
|
276
|
+
| M4 | revolve, sweep, loft, profiles, holes/pockets/counterbores, slots, fillet/chamfer, shell, patterns, equations, materials, save/open | 🚧 ongoing |
|
|
277
|
+
| M5 | end-to-end 3D-print part: build a functional mounting bracket through the full loop → verify every dimension → export a fine STL ([scripts/m5_demo_bracket.py](https://github.com/hjbaard/SolidWorks-MCP/blob/main/scripts/m5_demo_bracket.py)) | ✅ |
|
|
278
|
+
| M6 | assemblies: insert and position components, mate them, check interference — every placement and mate measured back ([tests/test_assembly.py](https://github.com/hjbaard/SolidWorks-MCP/blob/main/tests/test_assembly.py)) | ✅ |
|
|
279
|
+
|
|
280
|
+
See [Docs/PROGRESS.md](https://github.com/hjbaard/SolidWorks-MCP/blob/main/Docs/PROGRESS.md) for the detailed log and roadmap.
|
|
281
|
+
Feedback and contributions are welcome.
|
|
282
|
+
|
|
283
|
+
## Known limitations
|
|
284
|
+
|
|
285
|
+
- Geometry so far: **boxes**, **cylinders/cones** (revolve), **arbitrary
|
|
286
|
+
extruded profiles**, **holes**, **polygon pockets/slots** (`cut_profile`),
|
|
287
|
+
**fillets**, **chamfers**, **shells**, **linear + circular patterns** (bolt
|
|
288
|
+
circles); plus **equations**, **materials**, geometry **inspection**, and
|
|
289
|
+
**save/open** of `.sldprt`, **holes + pockets on any planar face**
|
|
290
|
+
(model→sketch transform), **round flanges** (disc + bore + bolt circle), and
|
|
291
|
+
**slotted holes** (`cut_slot`, obround at any angle — the first arc-based sketch),
|
|
292
|
+
**general revolves** (`add_revolved_profile`: any `(r,z)` profile → shafts,
|
|
293
|
+
vases, rings), **swept pipes/tubes** (`add_swept_pipe`: a round profile along
|
|
294
|
+
a rounded 2D path), and **lofts** (`add_lofted_solid`: blend stacked polygon
|
|
295
|
+
profiles → transitions/adapters), **free-form extrusions**
|
|
296
|
+
(`add_extruded_spline`: a smooth closed spline → organic/aesthetic outlines), and
|
|
297
|
+
**non-circular sweeps** (`add_swept_profile`: any cross-section along a path →
|
|
298
|
+
rails, gaskets, trim). Mirror is shelved — both routes fail
|
|
299
|
+
on this build; an AI mirrors by placing features symmetrically.
|
|
300
|
+
- Selection: plane walk, face-by-normal/direction (`_planar_face_by_normal`,
|
|
301
|
+
`+z`/…, with `:inner` for the cavity side of a hollow part), and edge selection
|
|
302
|
+
by axis **or explicit index** (`_select_edges`). `list_faces`/`list_edges` let
|
|
303
|
+
an agent inspect geometry before selecting.
|
|
304
|
+
- Assemblies (M6): components, transforms, mates and interference detection.
|
|
305
|
+
Component patterns, in-context features, configurations, drawings and
|
|
306
|
+
Simulation (FEA) are out of scope.
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# SolidWorks MCP
|
|
2
|
+
|
|
3
|
+
Let an AI agent (Claude, or any other MCP client) model real parametric parts and
|
|
4
|
+
assemblies in **your own SolidWorks** — and **check its own work**. Every
|
|
5
|
+
modelling call returns the measured volume, mass and bounding box, so the agent
|
|
6
|
+
can compare the result with the spec and correct itself instead of guessing that
|
|
7
|
+
it "looks about right".
|
|
8
|
+
|
|
9
|
+
<!-- mcp-name: io.github.hjbaard/solidworks-mcp -->
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://raw.githubusercontent.com/hjbaard/SolidWorks-MCP/main/Docs/images/bracket.png" width="32%" alt="3D-print mounting bracket with counterbored holes, bolt circle and cable slot">
|
|
13
|
+
<img src="https://raw.githubusercontent.com/hjbaard/SolidWorks-MCP/main/Docs/images/vase.png" width="32%" alt="Revolved and shelled vase">
|
|
14
|
+
<img src="https://raw.githubusercontent.com/hjbaard/SolidWorks-MCP/main/Docs/images/pipe.png" width="32%" alt="Swept pipe with rounded bends">
|
|
15
|
+
</p>
|
|
16
|
+
<p align="center"><sub>Built by the tools themselves: a mounting bracket (every step checked against a hand calculation), a revolved + shelled vase, a swept pipe.</sub></p>
|
|
17
|
+
|
|
18
|
+
## Why this server
|
|
19
|
+
|
|
20
|
+
- **It verifies, not just generates.** Features report measured geometry;
|
|
21
|
+
dimensions and mates are measured back after the rebuild.
|
|
22
|
+
- **Real CAD, not just primitives.** Extrude, revolve, sweep, loft and splines;
|
|
23
|
+
holes, counterbores, slots and pockets on any face; fillets, chamfers, shells,
|
|
24
|
+
patterns, equations and materials. Assemblies with mates and interference
|
|
25
|
+
checks. STEP/STL/3MF export and screenshots. 45 tools in total.
|
|
26
|
+
- **It fails loud.** A call that cannot do what was asked returns
|
|
27
|
+
`{ok: false, error}` with the cause, never silently wrong geometry.
|
|
28
|
+
- **A fixed, typed tool surface.** There is no "run arbitrary code" tool; the
|
|
29
|
+
agent can only do what the tools allow.
|
|
30
|
+
- **Tested against real SolidWorks.** 175 tests; each feature's integration test
|
|
31
|
+
compares the result with a hand calculation.
|
|
32
|
+
- **Local.** It talks to your running SolidWorks over COM; the server itself
|
|
33
|
+
makes no network calls.
|
|
34
|
+
|
|
35
|
+
## Quickstart
|
|
36
|
+
|
|
37
|
+
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/).
|
|
38
|
+
2. **Start SolidWorks** and leave it open (the server attaches to the running
|
|
39
|
+
instance — it does not launch one).
|
|
40
|
+
3. Register the server with your MCP client.
|
|
41
|
+
|
|
42
|
+
**Claude Code:**
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
claude mcp add solidworks -- uvx --from git+https://github.com/hjbaard/SolidWorks-MCP solidworks-mcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Claude Desktop** (`claude_desktop_config.json`) or any other client:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"mcpServers": {
|
|
53
|
+
"solidworks": {
|
|
54
|
+
"command": "uvx",
|
|
55
|
+
"args": ["--from", "git+https://github.com/hjbaard/SolidWorks-MCP", "solidworks-mcp"]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
4. Ask for a part, for example:
|
|
62
|
+
|
|
63
|
+
> Design a 100 × 80 × 8 mm mounting plate with a Ø16 mm centre bore, four
|
|
64
|
+
> counterbored M5 holes 12 mm from the corners and R5 corners. Check the
|
|
65
|
+
> volume against your own calculation, then export a fine STL.
|
|
66
|
+
|
|
67
|
+
## Requirements and compatibility
|
|
68
|
+
|
|
69
|
+
- Windows, with SolidWorks installed, licensed and **running**.
|
|
70
|
+
- Python 3.11+ (uv fetches one if needed).
|
|
71
|
+
- **Tested on SOLIDWORKS 2026** (3DEXPERIENCE R2026x). The API calls it uses
|
|
72
|
+
exist since SOLIDWORKS 2020 SP2, so 2020–2025 should work, but that is
|
|
73
|
+
**untested**. Tried another version? Please
|
|
74
|
+
[open an issue](https://github.com/hjbaard/SolidWorks-MCP/issues) with the
|
|
75
|
+
result, whether it worked or not.
|
|
76
|
+
|
|
77
|
+
**Status: early (v0.2).** It works end-to-end, but tool names and conventions
|
|
78
|
+
may still change. See [CHANGELOG.md](https://github.com/hjbaard/SolidWorks-MCP/blob/main/CHANGELOG.md).
|
|
79
|
+
|
|
80
|
+
## Troubleshooting
|
|
81
|
+
|
|
82
|
+
- **"Geen draaiende SolidWorks gevonden" / connection fails** — SolidWorks must be
|
|
83
|
+
*running* before you start the server or run a script; it attaches to the active
|
|
84
|
+
instance via `GetActiveObject` and does not launch one.
|
|
85
|
+
- **First call is slow or `EnsureModule` errors** — the first COM call generates the
|
|
86
|
+
makepy typelib wrappers under your temp `gen_py` folder. Let it finish; if it gets
|
|
87
|
+
into a bad state, delete the `gen_py` cache and retry. Early binding is mandatory on
|
|
88
|
+
this build (see [Architecture](#architecture)).
|
|
89
|
+
- **A feature returns `{ok: false, error: ...}`** — that is by design: every tool
|
|
90
|
+
fails loud with a readable (Dutch) message rather than silently producing wrong
|
|
91
|
+
geometry. Read the message; it names the likely cause.
|
|
92
|
+
- **Only tested against SOLIDWORKS 2026 (3DEXPERIENCE R2026x).** On other builds the
|
|
93
|
+
verified enum values or method signatures may differ — re-run
|
|
94
|
+
`scripts/introspect_api.py` to inspect your installed typelib.
|
|
95
|
+
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
Clone the repository, then install it editable into a venv:
|
|
99
|
+
|
|
100
|
+
```powershell
|
|
101
|
+
python -m venv .venv
|
|
102
|
+
.\.venv\Scripts\python.exe -m pip install -e .[dev]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
To run the MCP server from this checkout instead of via uvx, point your client
|
|
106
|
+
at the venv's Python:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"mcpServers": {
|
|
111
|
+
"solidworks": {
|
|
112
|
+
"command": "C:\\path\\to\\SolidWorks-MCP\\.venv\\Scripts\\python.exe",
|
|
113
|
+
"args": ["-m", "solidworks_mcp.server"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Run the verification scripts
|
|
120
|
+
|
|
121
|
+
With SolidWorks open:
|
|
122
|
+
|
|
123
|
+
```powershell
|
|
124
|
+
.\.venv\Scripts\python.exe scripts\probe_connection.py # M0
|
|
125
|
+
.\.venv\Scripts\python.exe scripts\m1_block.py # M1
|
|
126
|
+
.\.venv\Scripts\python.exe scripts\m2_parametric.py # M2
|
|
127
|
+
.\.venv\Scripts\python.exe scripts\test_mcp_server.py # M3 (full MCP loop over stdio)
|
|
128
|
+
.\.venv\Scripts\python.exe scripts\m5_demo_bracket.py # M5 (3D-print bracket, every step verified)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`scripts/introspect_api.py` regenerates/inspects the installed typelib and prints
|
|
132
|
+
verified enum values — run it if SolidWorks is upgraded and signatures change.
|
|
133
|
+
|
|
134
|
+
### Tests
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
.\.venv\Scripts\python.exe -m pytest # all tests
|
|
138
|
+
.\.venv\Scripts\python.exe -m pytest -m "not solidworks" # fast unit layer, no SolidWorks
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Two layers: **pure unit tests** (units, selector/direction parsing, polygon
|
|
142
|
+
cleaning, the component-placement maths, and that every MCP tool forwards its
|
|
143
|
+
arguments to the right session method) run anywhere; **integration tests**
|
|
144
|
+
(`solidworks` marker) drive a running SolidWorks and verify each feature's
|
|
145
|
+
volume — or each component's placement — against a hand calc. They auto-skip if
|
|
146
|
+
SolidWorks isn't reachable.
|
|
147
|
+
|
|
148
|
+
## Tools
|
|
149
|
+
|
|
150
|
+
The server speaks MCP over **stdio**.
|
|
151
|
+
|
|
152
|
+
### Part tools
|
|
153
|
+
|
|
154
|
+
| Tool | Purpose |
|
|
155
|
+
|---|---|
|
|
156
|
+
| `get_status` | Is SolidWorks reachable? revision + active/current part |
|
|
157
|
+
| `new_part` | Create a new empty part (becomes current) |
|
|
158
|
+
| `add_box(width_mm, height_mm, depth_mm, name)` | Sketch rectangle + extrude; returns mass properties |
|
|
159
|
+
| `add_cylinder(diameter_mm, height_mm, name)` | Cylinder by revolving a profile 360° about an axis (Y axis) |
|
|
160
|
+
| `add_disc(diameter_mm, thickness_mm, name)` | Disc/puck/flange: circle extruded along +Z (holes/patterns compose) |
|
|
161
|
+
| `add_cone(bottom_diameter_mm, top_diameter_mm, height_mm, name)` | Cone/frustum by revolve (top Ø = 0 → full cone) |
|
|
162
|
+
| `add_revolved_profile(profile_mm, angle_deg, name)` | Revolve any closed `(radius, height)` profile about the axis (shafts, vases, rings) |
|
|
163
|
+
| `add_swept_pipe(path_mm, diameter_mm, bend_radius_mm, name)` | Sweep a round profile along a 2D path with rounded bends (pipes, tubes, rods) |
|
|
164
|
+
| `add_swept_profile(profile_mm, path_mm, bend_radius_mm, name)` | Sweep any closed cross-section along a 2D path (rails, gaskets, trim, channels) |
|
|
165
|
+
| `add_lofted_solid(profiles_mm, heights_mm, name)` | Loft/blend 2+ polygon profiles on stacked parallel planes (transitions, adapters) |
|
|
166
|
+
| `add_extruded_profile(points_mm, depth_mm, name)` | Extrude any closed polygon `[[x,y],…]` (brackets, sections) |
|
|
167
|
+
| `add_extruded_spline(points_mm, depth_mm, name)` | Extrude a smooth closed spline through points (free-form/organic outlines) |
|
|
168
|
+
| `add_hole(diameter_mm, x_mm, y_mm, name)` | Cut a circular through-hole at (x, y) through the depth axis |
|
|
169
|
+
| `add_counterbore_hole(clearance_diameter_mm, cbore_diameter_mm, cbore_depth_mm, x_mm, y_mm, name)` | Counterbored screw hole (flush cap-head / heat-set insert) on +Z |
|
|
170
|
+
| `add_hole_on_face(diameter_mm, face, x_mm, y_mm, z_mm, name)` | Through-hole on ANY planar face at a 3D point (side holes, etc.) |
|
|
171
|
+
| `cut_profile(points_mm, depth_mm, name)` | Cut a polygon pocket/slot from the +Z face (blind or through) |
|
|
172
|
+
| `cut_profile_on_face(points_mm, face, depth_mm, name)` | Cut a polygon pocket on ANY face (3D points on the face) |
|
|
173
|
+
| `cut_slot(length_mm, width_mm, x_mm, y_mm, angle_deg, depth_mm, name)` | Cut a straight slotted hole (obround) on the +Z face at any angle |
|
|
174
|
+
| `add_fillet(radius_mm, edges, name)` | Round edges (`edges`: `all`, axis `x`/`y`/`z`, or indices `"2,5"`) |
|
|
175
|
+
| `add_chamfer(distance_mm, edges, name)` | Chamfer edges at 45° (`edges`: `all`, axis, or indices) |
|
|
176
|
+
| `add_shell(thickness_mm, open_face)` | Hollow to a wall thickness; open a face (`+z`/…) or `none` |
|
|
177
|
+
| `add_linear_pattern(count, spacing_mm, direction, feature_name)` | Repeat a feature N times along `+x`/`-x`/… |
|
|
178
|
+
| `add_circular_pattern(count, center_x_mm, center_y_mm, feature_name)` | Repeat a feature N times around an axis (bolt circle) |
|
|
179
|
+
| `set_dimension(dimension_name, value_mm)` | Change a named driving dim (e.g. `D1@BlockExtrude`), rebuild, remeasure |
|
|
180
|
+
| `set_equation(equation)` | Add a global equation linking dims (e.g. `"D1@BlockExtrude" = 25`) |
|
|
181
|
+
| `set_material(name, database)` | Assign a material (e.g. `6061 Alloy`) so mass/density are real |
|
|
182
|
+
| `rebuild(top_only)` | Force rebuild, report errors |
|
|
183
|
+
| `get_mass_properties` | Volume, mass, density, surface area, centre of mass, bounding box |
|
|
184
|
+
| `get_bounding_box` | Tight part bounding box (min/max/size, mm) |
|
|
185
|
+
| `list_faces` / `list_edges` | Inspect faces (normal/area/centre) and edges (type/axis/length) by index |
|
|
186
|
+
| `export(path, file_format, quality, deviation_mm, angle_deg)` | STEP/STL/IGES/Parasolid/3MF (silent; verifies file). STL/3MF tessellation: `quality` `coarse`/`fine`, or explicit `deviation_mm`+`angle_deg` |
|
|
187
|
+
| `screenshot(path)` | Isometric, zoom-to-fit PNG/BMP/JPG |
|
|
188
|
+
| `save_part(path)` / `open_part(path)` | Save to / open a native `.sldprt` |
|
|
189
|
+
| `close_part(save)` | Close the current part or assembly |
|
|
190
|
+
|
|
191
|
+
### Assembly tools
|
|
192
|
+
|
|
193
|
+
| Tool | Purpose |
|
|
194
|
+
|---|---|
|
|
195
|
+
| `new_assembly` | Create a new empty assembly (becomes the current document) |
|
|
196
|
+
| `open_assembly(path)` / `save_assembly(path)` | Open / save a native `.sldasm` |
|
|
197
|
+
| `insert_component(path, x_mm, y_mm, z_mm, fixed)` | Insert a part with its **origin** at (x, y, z); the first component is fixed by default |
|
|
198
|
+
| `list_components` | Name, path, fixed, position, rotation and bounding box of every component |
|
|
199
|
+
| `set_component_transform(name, x_mm, y_mm, z_mm, rx_deg, ry_deg, rz_deg)` | Move/rotate a component; the transform is read back and verified |
|
|
200
|
+
| `add_mate(comp_a, face_a, comp_b, face_b, mate_type, distance_mm, flip)` | Mate two planar faces: `coincident`, `distance`, `parallel`, `perpendicular` — measured back from the geometry afterwards |
|
|
201
|
+
| `check_interference` | Component pairs whose solids overlap, with the volume in mm³ (touching faces don't count) |
|
|
202
|
+
| `get_assembly_bounding_box` | Bounding box of the whole assembly (min/max/size, mm) |
|
|
203
|
+
|
|
204
|
+
`export` and `screenshot` work on assemblies too.
|
|
205
|
+
|
|
206
|
+
Faces are selected by direction in the component's **own** frame (`+x`, `-z`, …),
|
|
207
|
+
so a selector keeps meaning the same face however the component is turned. Add
|
|
208
|
+
`:inner` (e.g. `+y:inner`) for the cavity side of a hollow part — the inside of a
|
|
209
|
+
room wall instead of its outer skin.
|
|
210
|
+
|
|
211
|
+
All linear dimensions are **millimetres**; the server converts to/from the
|
|
212
|
+
SolidWorks-internal metre/radian units at the boundary.
|
|
213
|
+
|
|
214
|
+
## Architecture
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
src/solidworks_mcp/
|
|
218
|
+
binding.py early-binding plumbing (wrap raw dispatches in generated classes)
|
|
219
|
+
com_worker.py one dedicated STA thread; all COM calls serialised through it
|
|
220
|
+
session.py SolidWorks operations (must run on the COM thread)
|
|
221
|
+
server.py FastMCP tools that delegate to session via the worker
|
|
222
|
+
constants.py enum values read from the installed typelib (verified)
|
|
223
|
+
units.py mm<->m, deg<->rad
|
|
224
|
+
errors.py SolidWorksError -> agent-facing {ok:false,error}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Two non-obvious design decisions, both load-bearing:
|
|
228
|
+
|
|
229
|
+
1. **Early binding is mandatory.** On this build `GetActiveObject` returns a
|
|
230
|
+
dispatch whose `GetTypeInfo()` fails, so `EnsureDispatch`/`CastTo` cannot infer
|
|
231
|
+
types and pure late binding breaks (`IModelDoc2.FirstFeature` →
|
|
232
|
+
`DISP_E_MEMBERNOTFOUND`). We generate makepy wrappers from the installed
|
|
233
|
+
typelib and wrap each raw dispatch in the right interface class; calls then go
|
|
234
|
+
by dispid via `InvokeTypes`, bypassing name resolution. See `binding.py`.
|
|
235
|
+
|
|
236
|
+
2. **A dedicated COM thread.** COM is STA and thread-affine. The MCP server runs
|
|
237
|
+
on asyncio, so all COM work is pinned to one worker thread (`com_worker.py`)
|
|
238
|
+
that handlers post to and await — actively enforcing the "one COM session,
|
|
239
|
+
single-threaded" rule that does not hold automatically in an async server.
|
|
240
|
+
|
|
241
|
+
## Status and roadmap
|
|
242
|
+
|
|
243
|
+
Proven end-to-end against **SOLIDWORKS 2026 (3DEXPERIENCE R2026x)**:
|
|
244
|
+
|
|
245
|
+
| Milestone | What it proves | State |
|
|
246
|
+
|---|---|---|
|
|
247
|
+
| M0 | COM connection to a running SolidWorks | ✅ |
|
|
248
|
+
| M1 | new part → sketch rectangle → extrude → mass properties (volume matches hand calc) | ✅ |
|
|
249
|
+
| M2 | change a named dimension → rebuild → volume changes predictably | ✅ |
|
|
250
|
+
| M3 | full agent loop via the MCP server: build → measure → correct → export STEP/STL + screenshot | ✅ |
|
|
251
|
+
| M4 | revolve, sweep, loft, profiles, holes/pockets/counterbores, slots, fillet/chamfer, shell, patterns, equations, materials, save/open | 🚧 ongoing |
|
|
252
|
+
| M5 | end-to-end 3D-print part: build a functional mounting bracket through the full loop → verify every dimension → export a fine STL ([scripts/m5_demo_bracket.py](https://github.com/hjbaard/SolidWorks-MCP/blob/main/scripts/m5_demo_bracket.py)) | ✅ |
|
|
253
|
+
| M6 | assemblies: insert and position components, mate them, check interference — every placement and mate measured back ([tests/test_assembly.py](https://github.com/hjbaard/SolidWorks-MCP/blob/main/tests/test_assembly.py)) | ✅ |
|
|
254
|
+
|
|
255
|
+
See [Docs/PROGRESS.md](https://github.com/hjbaard/SolidWorks-MCP/blob/main/Docs/PROGRESS.md) for the detailed log and roadmap.
|
|
256
|
+
Feedback and contributions are welcome.
|
|
257
|
+
|
|
258
|
+
## Known limitations
|
|
259
|
+
|
|
260
|
+
- Geometry so far: **boxes**, **cylinders/cones** (revolve), **arbitrary
|
|
261
|
+
extruded profiles**, **holes**, **polygon pockets/slots** (`cut_profile`),
|
|
262
|
+
**fillets**, **chamfers**, **shells**, **linear + circular patterns** (bolt
|
|
263
|
+
circles); plus **equations**, **materials**, geometry **inspection**, and
|
|
264
|
+
**save/open** of `.sldprt`, **holes + pockets on any planar face**
|
|
265
|
+
(model→sketch transform), **round flanges** (disc + bore + bolt circle), and
|
|
266
|
+
**slotted holes** (`cut_slot`, obround at any angle — the first arc-based sketch),
|
|
267
|
+
**general revolves** (`add_revolved_profile`: any `(r,z)` profile → shafts,
|
|
268
|
+
vases, rings), **swept pipes/tubes** (`add_swept_pipe`: a round profile along
|
|
269
|
+
a rounded 2D path), and **lofts** (`add_lofted_solid`: blend stacked polygon
|
|
270
|
+
profiles → transitions/adapters), **free-form extrusions**
|
|
271
|
+
(`add_extruded_spline`: a smooth closed spline → organic/aesthetic outlines), and
|
|
272
|
+
**non-circular sweeps** (`add_swept_profile`: any cross-section along a path →
|
|
273
|
+
rails, gaskets, trim). Mirror is shelved — both routes fail
|
|
274
|
+
on this build; an AI mirrors by placing features symmetrically.
|
|
275
|
+
- Selection: plane walk, face-by-normal/direction (`_planar_face_by_normal`,
|
|
276
|
+
`+z`/…, with `:inner` for the cavity side of a hollow part), and edge selection
|
|
277
|
+
by axis **or explicit index** (`_select_edges`). `list_faces`/`list_edges` let
|
|
278
|
+
an agent inspect geometry before selecting.
|
|
279
|
+
- Assemblies (M6): components, transforms, mates and interference detection.
|
|
280
|
+
Component patterns, in-context features, configurations, drawings and
|
|
281
|
+
Simulation (FEA) are out of scope.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "solidworks-mcp"
|
|
7
|
+
version = "0.2.1"
|
|
8
|
+
description = "MCP server that drives a local SolidWorks instance over COM for parametric part modelling."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Henk Jan Baard" }]
|
|
13
|
+
keywords = ["solidworks", "mcp", "cad", "com", "parametric", "3d-printing"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: Microsoft :: Windows",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: Scientific/Engineering",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"pywin32>=306",
|
|
23
|
+
# mcp 2.x renamed FastMCP (server.py fails on import); 1.26+ is verified.
|
|
24
|
+
"mcp>=1.26,<2",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/hjbaard/SolidWorks-MCP"
|
|
29
|
+
Repository = "https://github.com/hjbaard/SolidWorks-MCP"
|
|
30
|
+
Changelog = "https://github.com/hjbaard/SolidWorks-MCP/blob/main/CHANGELOG.md"
|
|
31
|
+
Issues = "https://github.com/hjbaard/SolidWorks-MCP/issues"
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = ["pytest>=8"]
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
solidworks-mcp = "solidworks_mcp.server:main"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["src"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
testpaths = ["tests"]
|
|
44
|
+
markers = [
|
|
45
|
+
"solidworks: integration test that needs a running SolidWorks instance",
|
|
46
|
+
]
|