openscad-mcp-v2 1.0.0 → 1.1.0
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.
- package/README.md +359 -26
- package/dist/index.js +1474 -788
- package/package.json +21 -3
package/README.md
CHANGED
|
@@ -1,21 +1,108 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OpenSCAD MCP v2
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Describe a part to your AI assistant, get a 3MF for your 3D printer: as parametric OpenSCAD code you can open, change and keep.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Works with Claude Desktop, Claude Code, ChatGPT (desktop app), OpenAI Codex, Cursor, VS Code (Copilot), Windsurf, Cline, Gemini CLI, Zed and other MCP clients.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/openscad-mcp-v2)
|
|
8
|
+
[](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.JohnnyTheTank/openscad-mcp-v2)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<img src="docs/images/broom-holder.png" width="600" alt="Rendered wall holder for a broom handle: a C-shaped clip on a wall plate with two countersunk screw holes">
|
|
14
|
+
<br>
|
|
15
|
+
<em>"Wall holder for a 28 mm broom handle, two M4 countersunk screws." Rendered by this server, 70 × 38 × 22 mm, fits a Bambu Lab A1 mini.</em>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
A local [MCP](https://modelcontextprotocol.io) server for [OpenSCAD](https://openscad.org). You describe a part in your MCP client and its AI writes the OpenSCAD code. This server checks the code with OpenSCAD, renders images so the AI can see what it built and fix it, shows the part live in your OpenSCAD window, keeps every version and exports a 3MF or STL for your slicer.
|
|
19
|
+
|
|
20
|
+
## Is this for you?
|
|
21
|
+
|
|
22
|
+
- You have a 3D printer and want **functional parts**: holders, clips, boxes, spacers, replacement knobs, adapters. You don't want to learn CAD for each one.
|
|
23
|
+
- You already use an **AI assistant with MCP support** ([list above](#openscad-mcp), [setup](#2-add-the-server-to-your-client)). The server calls no language model and needs **no API key**: your client's model does the thinking, on the plan you already have.
|
|
24
|
+
- You want **code, not a frozen mesh**: every size is a named parameter (`handle_d = 28;`), so "make it 2 mm wider" is a one-value change and the file still opens in OpenSCAD's Customizer years later.
|
|
25
|
+
- You want to **see the part before printing**: the AI looks at real renders, checks the size against your printer's build volume and fixes its own errors.
|
|
26
|
+
|
|
27
|
+
Not a good fit: organic or sculpted shapes (figures, faces, terrain). OpenSCAD builds parts from cubes, cylinders and extrusions, which suits technical parts and not sculptures.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
Requests like these, with the code the AI wrote through this server (Claude, for these four) and the images the server rendered. The code is in [`docs/examples/`](docs/examples), including the [broom holder](docs/examples/broom-holder.scad) above.
|
|
32
|
+
|
|
33
|
+
| | | |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| <img src="docs/images/snap-box.png" width="300" alt="Rendered box with rounded corners and a snap-fit lid lying next to it"> | <img src="docs/images/phone-stand.png" width="300" alt="Rendered phone stand with a leaning back, a front lip and a slot for the charging cable"> | <img src="docs/images/knob.png" width="300" alt="Rendered round knob with grip flutes and a pointer mark on top"> |
|
|
36
|
+
| *"A 60 × 40 × 30 mm box with a snap-fit lid."* Box and lid side by side on the bed. [code](docs/examples/snap-box.scad) | *"A phone stand with a slot for the charging cable."* Prints without supports. [code](docs/examples/phone-stand.scad) | *"A replacement knob for a 6 mm D-shaft, 36 mm across."* D-shaped hole underneath. [code](docs/examples/knob.scad) |
|
|
37
|
+
|
|
38
|
+
## What a session looks like
|
|
6
39
|
|
|
7
40
|
```
|
|
8
41
|
you: "Wall holder for a 28 mm broom handle, two M4 countersunk screws"
|
|
9
42
|
└─ client writes SCAD ─► create_design ─► OpenSCAD errors and a rendered image come back
|
|
10
43
|
update_design ◄─ client fixes what it sees
|
|
11
44
|
open_in_openscad ─► the model is in your OpenSCAD window and follows changes
|
|
12
|
-
you: "export it"
|
|
45
|
+
you: "2 mm more clearance, then export it"
|
|
46
|
+
set_parameters ─► export_design ─► /…/broom-holder/exports/broom-holder-v0003.3mf
|
|
13
47
|
```
|
|
14
48
|
|
|
15
|
-
|
|
49
|
+
You open the 3MF in Bambu Studio, OrcaSlicer or PrusaSlicer and print it.
|
|
50
|
+
|
|
51
|
+
## What it does
|
|
52
|
+
|
|
53
|
+
- **Checks its own work.** OpenSCAD errors come back with file, line and the source around it; failed `assert()`s and missing modules count as errors, although OpenSCAD itself only warns.
|
|
54
|
+
- **Sees the part.** Every save returns a rendered image of the sides you ask for; `render_views` shows any side and cuts the part open. The client compares the image with your request and fixes what is off.
|
|
55
|
+
- **Live in OpenSCAD.** `open_in_openscad` opens the design in your OpenSCAD window, which follows every change. Edits you make there are noticed and kept.
|
|
56
|
+
- **Works on your files too.** `link_file` takes an existing `.scad` file, such as the one open in OpenSCAD right now, and edits it where it is, with the same versions and checks.
|
|
57
|
+
- **Never loses a state.** Every save is a version; going back adds a new one.
|
|
58
|
+
- **Fits your printer.** Real size, closed-solid check and fit on your printers' build volumes (Bambu Lab, Prusa, Creality profiles built in, your own by size).
|
|
59
|
+
- **Learns your preferences.** Corrections such as "always round the edges" are saved and come back with the guidelines for the next part.
|
|
60
|
+
- **Designs for FDM.** Built-in guidelines for wall thickness, overhangs, tolerances, screw and nut sizes, plus usage notes for BOSL2, NopSCADlib and MCAD when installed.
|
|
61
|
+
|
|
62
|
+
## Quickstart
|
|
63
|
+
|
|
64
|
+
You need **Node.js 22** or newer and **OpenSCAD**. Set them up by hand (steps 1 to 3 below), or let a coding agent do it.
|
|
65
|
+
|
|
66
|
+
### Let your coding agent set it up
|
|
67
|
+
|
|
68
|
+
Paste this into Claude Code, Codex, Cursor or another coding agent that can run commands on your computer:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
Set up the OpenSCAD MCP server openscad-mcp-v2 for me on this computer.
|
|
72
|
+
Instructions and client configurations: https://github.com/JohnnyTheTank/openscad-mcp-v2#readme
|
|
73
|
+
|
|
74
|
+
1. Node.js: run `node --version`. It must be 22 or newer. If it is missing or older,
|
|
75
|
+
tell me how to install it and stop.
|
|
76
|
+
2. OpenSCAD: it must be a development snapshot from 2024 or newer, not the 2021.01 release.
|
|
77
|
+
Check `openscad --version`; on macOS also look for /Applications/OpenSCAD.app.
|
|
78
|
+
- macOS: `brew install --cask openscad@snapshot`. If an old OpenSCAD.app is in the way,
|
|
79
|
+
ask me before removing it.
|
|
80
|
+
- Windows or Linux: show me the snapshot download on
|
|
81
|
+
https://openscad.org/downloads.html#snapshots. On Linux, put the AppImage on PATH as
|
|
82
|
+
`openscad`, or remember its path for OPENSCAD_PATH.
|
|
83
|
+
3. Printers: ask me which 3D printers I use. Built-in profiles: a1mini, a1, p1p, p1s, x1c,
|
|
84
|
+
x1e, h2s, h2d, mk4, mini, ender3; any other as name:WIDTHxDEPTHxHEIGHT in mm.
|
|
85
|
+
The first one is the default. This becomes OPENSCAD_MCP_PRINTERS, comma-separated.
|
|
86
|
+
4. Check: if `npx -y openscad-mcp-v2 --help` lists `--check`, run
|
|
87
|
+
`npx -y openscad-mcp-v2 --check` with OPENSCAD_MCP_PRINTERS (and OPENSCAD_PATH if needed)
|
|
88
|
+
set. Exit code 1 means a problem; fix what it reports. Without `--check` in the help,
|
|
89
|
+
skip this step, and do not run the bare command: it starts the server and waits for input.
|
|
90
|
+
5. Clients: ask me which MCP clients I want to use it in (for example Claude Desktop,
|
|
91
|
+
Claude Code, ChatGPT desktop, Codex, Cursor, VS Code). Add the server to each one as the
|
|
92
|
+
README section "Add the server to your client" shows: command `npx`, arguments
|
|
93
|
+
`-y openscad-mcp-v2`, and the environment variables from steps 2 and 3. Back up each
|
|
94
|
+
config file first, merge into it and keep the other servers that are there.
|
|
95
|
+
6. Libraries: ask me whether to install BOSL2. If yes, clone
|
|
96
|
+
https://github.com/BelfrySCAD/BOSL2 into the library folder that `--check` reports
|
|
97
|
+
(macOS default: ~/Documents/OpenSCAD/libraries/BOSL2).
|
|
98
|
+
7. Tell me which clients I have to restart, and that I can then ask there:
|
|
99
|
+
"Run check_setup, then design a wall hook for a 28 mm broom handle."
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 1. Install OpenSCAD: the development snapshot, not 2021.01
|
|
16
103
|
|
|
17
104
|
> [!IMPORTANT]
|
|
18
|
-
> The download button on openscad.org and most package managers give you **OpenSCAD 2021.01**.
|
|
105
|
+
> The download button on openscad.org and most package managers give you **OpenSCAD 2021.01**. Install a **development snapshot (2024 or newer)** instead.
|
|
19
106
|
|
|
20
107
|
| System | Install |
|
|
21
108
|
|---|---|
|
|
@@ -23,20 +110,49 @@ you: "export it" ─► export_design ─► /…/broom-holder/exports/br
|
|
|
23
110
|
| **Windows** | Installer from [openscad.org → Development Snapshots](https://openscad.org/downloads.html#snapshots) |
|
|
24
111
|
| **Linux** | AppImage from [openscad.org → Development Snapshots](https://openscad.org/downloads.html#snapshots); put it on `PATH` as `openscad` or set `OPENSCAD_PATH` to it |
|
|
25
112
|
|
|
113
|
+
<details>
|
|
114
|
+
<summary>Why the snapshot, and how to check</summary>
|
|
115
|
+
|
|
116
|
+
2021.01 has no Manifold backend: full renders take seconds to minutes, so the server falls back to OpenSCAD's quick preview, which can show holes that are not in the model.
|
|
117
|
+
|
|
26
118
|
macOS: the cask `openscad` (2021.01) is disabled in Homebrew since 2026-09-01. If an old `OpenSCAD.app` is in `/Applications`, remove it first (`brew uninstall --cask openscad`, or move it to the Trash), because the snapshot installs under the same name.
|
|
27
119
|
|
|
28
|
-
Check that it worked: `check_setup`
|
|
120
|
+
Check that it worked: `check_setup` reports the version and a line like `OpenSCAD 2026.10.11 at …, Manifold 3.5.2 backend`. No "Manifold" in that line means you still have the old release. Developed and tested with 2026.10.11 on macOS; 2021.01 is not tested.
|
|
121
|
+
|
|
122
|
+
</details>
|
|
29
123
|
|
|
30
|
-
|
|
124
|
+
### 2. Add the server to your client
|
|
31
125
|
|
|
32
|
-
-
|
|
33
|
-
- **Node.js 22** or newer.
|
|
126
|
+
The server is on npm as [`openscad-mcp-v2`](https://www.npmjs.com/package/openscad-mcp-v2); `npx` fetches and starts it, nothing else to install. Every client starts it the same way: command `npx`, arguments `-y openscad-mcp-v2`, plus optional [environment variables](#configuration). Set `OPENSCAD_MCP_PRINTERS` to your printers ([profiles](#printer-profiles)). Only the place where this goes differs between clients: open yours below.
|
|
34
127
|
|
|
35
|
-
|
|
128
|
+
Your client needs to start local (stdio) MCP servers, so ChatGPT works in the desktop app but not on the web. The client should also pass images from tool results to a model that can see them: the server returns renders so the model can check its work. A text-only model still gets errors, sizes and the printer fit.
|
|
36
129
|
|
|
37
|
-
|
|
130
|
+
<details>
|
|
131
|
+
<summary><b>Claude Desktop</b></summary>
|
|
38
132
|
|
|
39
|
-
|
|
133
|
+
Settings → Developer → Edit Config opens `claude_desktop_config.json`. Add:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"openscad": {
|
|
139
|
+
"command": "npx",
|
|
140
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
141
|
+
"env": {
|
|
142
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
143
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Restart Claude Desktop.
|
|
151
|
+
|
|
152
|
+
</details>
|
|
153
|
+
|
|
154
|
+
<details>
|
|
155
|
+
<summary><b>Claude Code</b></summary>
|
|
40
156
|
|
|
41
157
|
```bash
|
|
42
158
|
claude mcp add openscad \
|
|
@@ -45,11 +161,198 @@ claude mcp add openscad \
|
|
|
45
161
|
-- npx -y openscad-mcp-v2
|
|
46
162
|
```
|
|
47
163
|
|
|
48
|
-
Add `--scope user` to have it in every project.
|
|
164
|
+
Add `--scope user` to have it in every project.
|
|
165
|
+
|
|
166
|
+
</details>
|
|
167
|
+
|
|
168
|
+
<details>
|
|
169
|
+
<summary><b>ChatGPT (desktop app)</b></summary>
|
|
170
|
+
|
|
171
|
+
Settings → MCP servers → Add server → **STDIO**:
|
|
172
|
+
|
|
173
|
+
- Command: `npx`
|
|
174
|
+
- Arguments: `-y openscad-mcp-v2`
|
|
175
|
+
- Environment variables: `OPENSCAD_MCP_WORKSPACE` = `~/openscad-designs`, `OPENSCAD_MCP_PRINTERS` = `a1,a1mini`
|
|
176
|
+
|
|
177
|
+
Save and select Restart. The desktop app shares its MCP servers with Codex, so you can also add the server to `~/.codex/config.toml`:
|
|
178
|
+
|
|
179
|
+
```toml
|
|
180
|
+
[mcp_servers.openscad]
|
|
181
|
+
command = "npx"
|
|
182
|
+
args = ["-y", "openscad-mcp-v2"]
|
|
183
|
+
|
|
184
|
+
[mcp_servers.openscad.env]
|
|
185
|
+
OPENSCAD_MCP_WORKSPACE = "~/openscad-designs"
|
|
186
|
+
OPENSCAD_MCP_PRINTERS = "a1,a1mini"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
</details>
|
|
190
|
+
|
|
191
|
+
<details>
|
|
192
|
+
<summary><b>OpenAI Codex (CLI, IDE extension)</b></summary>
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
codex mcp add openscad \
|
|
196
|
+
--env OPENSCAD_MCP_WORKSPACE=~/openscad-designs \
|
|
197
|
+
--env OPENSCAD_MCP_PRINTERS=a1,a1mini \
|
|
198
|
+
-- npx -y openscad-mcp-v2
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Or by hand in `~/.codex/config.toml` (or `.codex/config.toml` in a trusted project):
|
|
202
|
+
|
|
203
|
+
```toml
|
|
204
|
+
[mcp_servers.openscad]
|
|
205
|
+
command = "npx"
|
|
206
|
+
args = ["-y", "openscad-mcp-v2"]
|
|
207
|
+
|
|
208
|
+
[mcp_servers.openscad.env]
|
|
209
|
+
OPENSCAD_MCP_WORKSPACE = "~/openscad-designs"
|
|
210
|
+
OPENSCAD_MCP_PRINTERS = "a1,a1mini"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The ChatGPT desktop app reads the same configuration.
|
|
214
|
+
|
|
215
|
+
</details>
|
|
216
|
+
|
|
217
|
+
<details>
|
|
218
|
+
<summary><b>Cursor</b></summary>
|
|
219
|
+
|
|
220
|
+
`~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project:
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"mcpServers": {
|
|
225
|
+
"openscad": {
|
|
226
|
+
"command": "npx",
|
|
227
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
228
|
+
"env": {
|
|
229
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
230
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Restart Cursor.
|
|
238
|
+
|
|
239
|
+
</details>
|
|
240
|
+
|
|
241
|
+
<details>
|
|
242
|
+
<summary><b>VS Code (GitHub Copilot agent mode)</b></summary>
|
|
243
|
+
|
|
244
|
+
`.vscode/mcp.json` in a project, or **MCP: Open User Configuration** from the command palette. The key is `servers`, not `mcpServers`:
|
|
245
|
+
|
|
246
|
+
```json
|
|
247
|
+
{
|
|
248
|
+
"servers": {
|
|
249
|
+
"openscad": {
|
|
250
|
+
"type": "stdio",
|
|
251
|
+
"command": "npx",
|
|
252
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
253
|
+
"env": {
|
|
254
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
255
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
</details>
|
|
263
|
+
|
|
264
|
+
<details>
|
|
265
|
+
<summary><b>Windsurf</b></summary>
|
|
266
|
+
|
|
267
|
+
`~/.codeium/windsurf/mcp_config.json` (Cascade → MCP → View raw config):
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"mcpServers": {
|
|
272
|
+
"openscad": {
|
|
273
|
+
"command": "npx",
|
|
274
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
275
|
+
"env": {
|
|
276
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
277
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
</details>
|
|
285
|
+
|
|
286
|
+
<details>
|
|
287
|
+
<summary><b>Cline</b></summary>
|
|
288
|
+
|
|
289
|
+
MCP Servers → Configure MCP Servers opens `cline_mcp_settings.json`:
|
|
290
|
+
|
|
291
|
+
```json
|
|
292
|
+
{
|
|
293
|
+
"mcpServers": {
|
|
294
|
+
"openscad": {
|
|
295
|
+
"command": "npx",
|
|
296
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
297
|
+
"env": {
|
|
298
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
299
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
</details>
|
|
307
|
+
|
|
308
|
+
<details>
|
|
309
|
+
<summary><b>Gemini CLI</b></summary>
|
|
310
|
+
|
|
311
|
+
`~/.gemini/settings.json`, or `.gemini/settings.json` in a project:
|
|
312
|
+
|
|
313
|
+
```json
|
|
314
|
+
{
|
|
315
|
+
"mcpServers": {
|
|
316
|
+
"openscad": {
|
|
317
|
+
"command": "npx",
|
|
318
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
319
|
+
"env": {
|
|
320
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
321
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
</details>
|
|
49
329
|
|
|
50
|
-
|
|
330
|
+
<details>
|
|
331
|
+
<summary><b>Zed</b></summary>
|
|
51
332
|
|
|
52
|
-
`
|
|
333
|
+
Zed's `settings.json`; the key is `context_servers`:
|
|
334
|
+
|
|
335
|
+
```json
|
|
336
|
+
{
|
|
337
|
+
"context_servers": {
|
|
338
|
+
"openscad": {
|
|
339
|
+
"command": "npx",
|
|
340
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
341
|
+
"env": {
|
|
342
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
343
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
</details>
|
|
351
|
+
|
|
352
|
+
<details>
|
|
353
|
+
<summary><b>Other MCP clients</b></summary>
|
|
354
|
+
|
|
355
|
+
Most clients use the `mcpServers` format:
|
|
53
356
|
|
|
54
357
|
```json
|
|
55
358
|
{
|
|
@@ -66,7 +369,17 @@ Add `--scope user` to have it in every project. Then ask for a part, or start wi
|
|
|
66
369
|
}
|
|
67
370
|
```
|
|
68
371
|
|
|
69
|
-
|
|
372
|
+
Some call the key `servers` or `context_servers`; the fields inside are the same.
|
|
373
|
+
|
|
374
|
+
</details>
|
|
375
|
+
|
|
376
|
+
### 3. Check the setup and ask for a part
|
|
377
|
+
|
|
378
|
+
Ask the client to run `check_setup`: it reports the OpenSCAD version, the libraries it found, the workspace and the printer profiles, and says what is missing. From 1.1.0 on, `npx -y openscad-mcp-v2 --check` prints the same report in a terminal (exit code 1 when something is missing). Then describe a part, for example:
|
|
379
|
+
|
|
380
|
+
> A cable clip for the edge of my desk, desk 25 mm thick, room for three USB-C cables. Open it in OpenSCAD.
|
|
381
|
+
|
|
382
|
+
Or start with the prompt `new_design`. Designs are saved in `~/openscad-designs` unless you set `OPENSCAD_MCP_WORKSPACE`.
|
|
70
383
|
|
|
71
384
|
## Configuration
|
|
72
385
|
|
|
@@ -103,15 +416,17 @@ A single call can name another one: `printer: "x1c"` or `printer: "300x300x400"`
|
|
|
103
416
|
| `check_setup` | OpenSCAD version and path, libraries, workspace, printer profiles, state of the automatic reload |
|
|
104
417
|
| `get_guidelines` | Design guidelines: workflow, code structure, FDM rules, screw sizes, installed libraries, OpenSCAD reference |
|
|
105
418
|
| `list_designs` | Designs with latest version and time of change |
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
419
|
+
| `find_scad_files` | The files OpenSCAD opened last (the first is usually the one open now), or the `.scad` files in a folder |
|
|
420
|
+
| `link_file` | Makes an existing `.scad` file a design that is edited where it is; version 1 keeps it as it was |
|
|
421
|
+
| `create_design` | Saves new code as version 1, validates it, returns errors with source lines and an image (isometric, or the sides listed in `views`) |
|
|
422
|
+
| `update_design` | Targeted text edits or complete new code, as a new version; validates and returns an image (`views` like `create_design`) |
|
|
108
423
|
| `get_design` | Current code (or an old version) with its parameters |
|
|
109
424
|
| `validate_design` | Errors, warnings and echo output of the file as it is on disk |
|
|
110
|
-
| `render_views` | Images from `iso`, `iso_back`, `front`, `back`, `left`, `right`, `top`, `bottom`; optional parameter overrides |
|
|
425
|
+
| `render_views` | Images from `iso`, `iso_back`, `front`, `back`, `left`, `right`, `top`, `bottom`; optional parameter overrides; `section` cuts the model open at a plane, cut faces in orange |
|
|
111
426
|
| `open_in_openscad` | Shows the design in the OpenSCAD window, which then follows every change |
|
|
112
427
|
| `list_versions`, `restore_version` | History, and going back (a restore is a new version) |
|
|
113
428
|
| `set_parameters` | Lists the customizer parameters, or changes their values in the file |
|
|
114
|
-
| `analyze_design` | Real size, bounding box, closed-solid check, bed contact, fit per printer |
|
|
429
|
+
| `analyze_design` | Real size, bounding box, closed-solid check, bed contact, fit per printer; with parameter overrides an overlap check answers "Empty", "Touching only" or the size of the overlap |
|
|
115
430
|
| `export_design` | 3MF (default) or binary STL into the design's `exports/` folder, with path, size and fit |
|
|
116
431
|
| `record_learning`, `list_learnings`, `forget_learning` | Lessons for later designs: your corrections and preferences, techniques that failed or worked |
|
|
117
432
|
|
|
@@ -141,6 +456,16 @@ OpenSCAD has no remote control. `open_in_openscad` starts it with the design's f
|
|
|
141
456
|
|
|
142
457
|
The server remembers which designs it opened and does not open a second window for the same file. A window you opened yourself is unknown to it. You can edit the code in OpenSCAD's editor: the server notices the change and keeps it as its own version before the next update.
|
|
143
458
|
|
|
459
|
+
## Your existing files
|
|
460
|
+
|
|
461
|
+
Say "change the bracket that is open in OpenSCAD" or "make the knob in ~/3d/knob.scad 5 mm taller". The client finds the file with `find_scad_files` (OpenSCAD's list of recent files, newest first, or a folder) and links it with `link_file`.
|
|
462
|
+
|
|
463
|
+
- The file stays where it is. `update_design`, `set_parameters` and `restore_version` write into it; versions, images and exports live in the design's folder in the workspace, and `design.json` names the file. Version 1 is the file as it was found.
|
|
464
|
+
- OpenSCAD runs in the file's folder, so `include <…>` and `use <…>` of neighbouring files keep working. Only the linked file is changed, never the files it includes.
|
|
465
|
+
- If the file is open in OpenSCAD with **Automatic Reload and Preview** on, the window follows every change. The server sees the file as saved: save in OpenSCAD before you ask for a change, or the server works on the older state. With unsaved changes OpenSCAD asks whether to reload the file; either answer loses nothing, because every state the server wrote and every state you save is kept as a version.
|
|
466
|
+
- "The file open in OpenSCAD" is the first entry of OpenSCAD's list of recent files (macOS preferences, `OpenSCAD.conf` on Linux). It needs no extra permission; on Windows the list is not read, so give the path.
|
|
467
|
+
- A moved file: `link_file` with the design's name and the new path connects it again.
|
|
468
|
+
|
|
144
469
|
## Learnings
|
|
145
470
|
|
|
146
471
|
The server learns from the work in your workspace. When you correct the model ("round every edge"), when a technique fails and another one works, or when you change a design yourself in OpenSCAD, the client saves a one-sentence lesson with `record_learning`. `get_guidelines` returns these learnings with the guidelines, so the next design starts with them.
|
|
@@ -164,7 +489,7 @@ The server learns from the work in your workspace. When you correct the model ("
|
|
|
164
489
|
gui.json OpenSCAD windows this server opened
|
|
165
490
|
```
|
|
166
491
|
|
|
167
|
-
Design names become folder names (lower-case letters, digits, dashes)
|
|
492
|
+
Design names become folder names (lower-case letters, digits, dashes). Outside the workspace the server writes only into `.scad` files you linked with `link_file` (through a temporary file next to it, then a rename, so OpenSCAD never reads half a file).
|
|
168
493
|
|
|
169
494
|
## Printing
|
|
170
495
|
|
|
@@ -177,6 +502,7 @@ Printer servers can start a print without asking. This server's instructions tel
|
|
|
177
502
|
- The closed-solid check is OpenSCAD's own. Two bodies that only share an edge pass it.
|
|
178
503
|
- Wall thickness, overhangs and bridges are not measured; the guidelines make the model design for them, and the slicer preview is the final check.
|
|
179
504
|
- Images show the bounding box fitted to the frame; there is no free camera yet.
|
|
505
|
+
- Of a linked file only the file itself is edited; files it includes stay as they are. Code typed in OpenSCAD but not saved is not visible to the server.
|
|
180
506
|
|
|
181
507
|
## Development
|
|
182
508
|
|
|
@@ -199,13 +525,20 @@ npx tsx scripts/call.ts render_views '{"name":"x"}' --images /tmp/out
|
|
|
199
525
|
|
|
200
526
|
Notes for coding agents are in [CLAUDE.md](CLAUDE.md).
|
|
201
527
|
|
|
202
|
-
###
|
|
528
|
+
### Benchmark
|
|
529
|
+
|
|
530
|
+
The server's guidance (instructions, guidelines, tool descriptions) decides how good the models get, so changes to it are measured. `bench/tasks.ts` holds six complex parts (Raspberry Pi case, planetary gears, screw-top jar, print-in-place hinge, Gridfinity bin, phone stand), each a first request plus two follow-up requests. Claude solves them through this server's tools, with a fresh workspace per run; the final design is graded with a full render: valid closed solid on z = 0, size, Customizer parameters, render time, point probes (solid or empty at a given position), parameter values and whether a follow-up used `set_parameters`. `--judge` adds a rating of six rendered views against a per-task rubric.
|
|
203
531
|
|
|
204
|
-
|
|
532
|
+
```bash
|
|
533
|
+
npm run bench -- --tasks jar --runs 1 # one task, to try it
|
|
534
|
+
npm run bench -- --runs 3 --judge # all tasks, three runs each
|
|
535
|
+
npm run bench -- --runs 3 --judge --compare bench/baselines/<file>.json
|
|
536
|
+
npm run bench -- --grade <workspace> --design <name> --tasks jar # grade an existing design, no model
|
|
537
|
+
```
|
|
205
538
|
|
|
206
|
-
|
|
539
|
+
By default Claude runs as Claude Code in headless mode (`claude -p`, billed to the Claude subscription it is logged in with). It starts this server from the checkout's sources and gets only its tools: no built-in tools, no user or project settings, an empty working folder, `open_in_openscad` and `export_design` disallowed. `--driver api` calls the Claude API directly instead (needs `ANTHROPIC_API_KEY` with credit, from the environment or a `.env` in the checkout). The two drivers use different system prompts, so compare results of the same driver.
|
|
207
540
|
|
|
208
|
-
|
|
541
|
+
Results land in `bench/results/<date>-<model>-<commit>/` (`result.json`, `report.md` and the final designs). Copy a run you want to compare against into `bench/baselines/`. The report shows the cost per task (for `claude -p` what the usage would cost at API prices).
|
|
209
542
|
|
|
210
543
|
## Security
|
|
211
544
|
|