openscad-mcp-v2 1.0.0 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +373 -28
  2. package/dist/index.js +1825 -832
  3. package/package.json +22 -3
package/README.md CHANGED
@@ -1,21 +1,118 @@
1
- # openscad-mcp-v2
1
+ # OpenSCAD MCP v2
2
2
 
3
- A local [MCP](https://modelcontextprotocol.io) server for [OpenSCAD](https://openscad.org). You describe a part in a chat with Claude (or another MCP client); the client writes parametric OpenSCAD code, and this server stores it, validates it with OpenSCAD, renders images the client checks, shows the model in your OpenSCAD window, keeps every version and exports a 3MF or STL file for your slicer.
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
- The server calls no language model. The MCP client is the model; the server gives it tools and design guidelines for 3D printing.
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
+ [![npm](https://img.shields.io/npm/v/openscad-mcp-v2)](https://www.npmjs.com/package/openscad-mcp-v2)
8
+ [![MCP Registry](https://img.shields.io/badge/MCP_Registry-openscad--mcp--v2-blue)](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.JohnnyTheTank/openscad-mcp-v2)
9
+ [![Node](https://img.shields.io/node/v/openscad-mcp-v2)](https://nodejs.org)
10
+ [![License: MIT](https://img.shields.io/npm/l/openscad-mcp-v2)](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" ─► export_design ─► /…/broom-holder/exports/broom-holder-v0003.3mf
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
- ## Install OpenSCAD: the development snapshot, not 2021.01
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
+ - **Measures what images can't show.** `measure_design` reads wall thicknesses, hole sizes and the gap between a lid and its rim or between hinge knuckles off the rendered model, in millimetres.
56
+ - **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.
57
+ - **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.
58
+ - **Never loses a state.** Every save is a version; going back adds a new one.
59
+ - **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).
60
+ - **Learns your preferences.** Corrections such as "always round the edges" are saved and come back with the guidelines for the next part.
61
+ - **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.
62
+
63
+ ## Quickstart
64
+
65
+ You need **OpenSCAD** in every case. **Claude Desktop** installs the server in one click from a bundle and needs nothing else. Other clients need **Node.js 22** or newer: set them up by hand (steps 1 to 3 below), or let a coding agent do it.
66
+
67
+ ### Claude Desktop: one-click install
68
+
69
+ 1. Install OpenSCAD, the development snapshot: [step 1](#1-install-openscad-the-development-snapshot-not-202101).
70
+ 2. Download `openscad-mcp-v2-<version>.mcpb` from the [latest release](https://github.com/JohnnyTheTank/openscad-mcp-v2/releases/latest) (releases from 1.2.0 on carry it).
71
+ 3. Open the file: double-click it, drag it onto the Claude Desktop window, or install it under Settings → Extensions. Claude Desktop shows three optional settings: the design folder, your [printers](#printer-profiles) (for example `a1,a1mini`) and the OpenSCAD executable, which is only needed when it is not found on its own.
72
+ 4. Ask in a new chat: *"Run check_setup, then design a wall hook for a 28 mm broom handle."*
73
+
74
+ Claude Desktop runs the bundle with its own Node.js. To update, install the `.mcpb` of the newer release. The other [settings](#configuration) keep their defaults in the bundle; for those, use the JSON configuration in [step 2](#2-add-the-server-to-your-client) instead.
75
+
76
+ ### Let your coding agent set it up
77
+
78
+ Paste this into Claude Code, Codex, Cursor or another coding agent that can run commands on your computer:
79
+
80
+ ```text
81
+ Set up the OpenSCAD MCP server openscad-mcp-v2 for me on this computer.
82
+ Instructions and client configurations: https://github.com/JohnnyTheTank/openscad-mcp-v2#readme
83
+
84
+ 1. Node.js: run `node --version`. It must be 22 or newer. If it is missing or older,
85
+ tell me how to install it and stop.
86
+ 2. OpenSCAD: it must be a development snapshot from 2024 or newer, not the 2021.01 release.
87
+ Check `openscad --version`; on macOS also look for /Applications/OpenSCAD.app.
88
+ - macOS: `brew install --cask openscad@snapshot`. If an old OpenSCAD.app is in the way,
89
+ ask me before removing it.
90
+ - Windows or Linux: show me the snapshot download on
91
+ https://openscad.org/downloads.html#snapshots. On Linux, put the AppImage on PATH as
92
+ `openscad`, or remember its path for OPENSCAD_PATH.
93
+ 3. Printers: ask me which 3D printers I use. Built-in profiles: a1mini, a1, p1p, p1s, x1c,
94
+ x1e, h2s, h2d, mk4, mini, ender3; any other as name:WIDTHxDEPTHxHEIGHT in mm.
95
+ The first one is the default. This becomes OPENSCAD_MCP_PRINTERS, comma-separated.
96
+ 4. Check: if `npx -y openscad-mcp-v2 --help` lists `--check`, run
97
+ `npx -y openscad-mcp-v2 --check` with OPENSCAD_MCP_PRINTERS (and OPENSCAD_PATH if needed)
98
+ set. Exit code 1 means a problem; fix what it reports. Without `--check` in the help,
99
+ skip this step, and do not run the bare command: it starts the server and waits for input.
100
+ 5. Clients: ask me which MCP clients I want to use it in (for example Claude Desktop,
101
+ Claude Code, ChatGPT desktop, Codex, Cursor, VS Code). Add the server to each one as the
102
+ README section "Add the server to your client" shows: command `npx`, arguments
103
+ `-y openscad-mcp-v2`, and the environment variables from steps 2 and 3. Back up each
104
+ config file first, merge into it and keep the other servers that are there.
105
+ 6. Libraries: ask me whether to install BOSL2. If yes, clone
106
+ https://github.com/BelfrySCAD/BOSL2 into the library folder that `--check` reports
107
+ (macOS default: ~/Documents/OpenSCAD/libraries/BOSL2).
108
+ 7. Tell me which clients I have to restart, and that I can then ask there:
109
+ "Run check_setup, then design a wall hook for a 28 mm broom handle."
110
+ ```
111
+
112
+ ### 1. Install OpenSCAD: the development snapshot, not 2021.01
16
113
 
17
114
  > [!IMPORTANT]
18
- > The download button on openscad.org and most package managers give you **OpenSCAD 2021.01**. That release 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. Install a **development snapshot (2024 or newer)**.
115
+ > The download button on openscad.org and most package managers give you **OpenSCAD 2021.01**. Install a **development snapshot (2024 or newer)** instead.
19
116
 
20
117
  | System | Install |
21
118
  |---|---|
@@ -23,20 +120,49 @@ you: "export it" ─► export_design ─► /…/broom-holder/exports/br
23
120
  | **Windows** | Installer from [openscad.org → Development Snapshots](https://openscad.org/downloads.html#snapshots) |
24
121
  | **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
122
 
123
+ <details>
124
+ <summary>Why the snapshot, and how to check</summary>
125
+
126
+ 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.
127
+
26
128
  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
129
 
28
- Check that it worked: `check_setup` (see below) 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.
130
+ 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.
131
+
132
+ </details>
29
133
 
30
- ## Requirements
134
+ ### 2. Add the server to your client
31
135
 
32
- - **OpenSCAD** development snapshot, see above.
33
- - **Node.js 22** or newer.
136
+ 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
137
 
35
- ## Setup
138
+ 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
139
 
37
- 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.
140
+ <details>
141
+ <summary><b>Claude Desktop</b></summary>
38
142
 
39
- ### Claude Code
143
+ The [one-click bundle](#claude-desktop-one-click-install) is the easier way. By hand: Settings → Developer → Edit Config opens `claude_desktop_config.json`. Add:
144
+
145
+ ```json
146
+ {
147
+ "mcpServers": {
148
+ "openscad": {
149
+ "command": "npx",
150
+ "args": ["-y", "openscad-mcp-v2"],
151
+ "env": {
152
+ "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
153
+ "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
154
+ }
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ Restart Claude Desktop.
161
+
162
+ </details>
163
+
164
+ <details>
165
+ <summary><b>Claude Code</b></summary>
40
166
 
41
167
  ```bash
42
168
  claude mcp add openscad \
@@ -45,11 +171,198 @@ claude mcp add openscad \
45
171
  -- npx -y openscad-mcp-v2
46
172
  ```
47
173
 
48
- Add `--scope user` to have it in every project. Then ask for a part, or start with the prompt `new_design`.
174
+ Add `--scope user` to have it in every project.
175
+
176
+ </details>
177
+
178
+ <details>
179
+ <summary><b>ChatGPT (desktop app)</b></summary>
180
+
181
+ Settings → MCP servers → Add server → **STDIO**:
182
+
183
+ - Command: `npx`
184
+ - Arguments: `-y openscad-mcp-v2`
185
+ - Environment variables: `OPENSCAD_MCP_WORKSPACE` = `~/openscad-designs`, `OPENSCAD_MCP_PRINTERS` = `a1,a1mini`
186
+
187
+ Save and select Restart. The desktop app shares its MCP servers with Codex, so you can also add the server to `~/.codex/config.toml`:
188
+
189
+ ```toml
190
+ [mcp_servers.openscad]
191
+ command = "npx"
192
+ args = ["-y", "openscad-mcp-v2"]
193
+
194
+ [mcp_servers.openscad.env]
195
+ OPENSCAD_MCP_WORKSPACE = "~/openscad-designs"
196
+ OPENSCAD_MCP_PRINTERS = "a1,a1mini"
197
+ ```
198
+
199
+ </details>
200
+
201
+ <details>
202
+ <summary><b>OpenAI Codex (CLI, IDE extension)</b></summary>
203
+
204
+ ```bash
205
+ codex mcp add openscad \
206
+ --env OPENSCAD_MCP_WORKSPACE=~/openscad-designs \
207
+ --env OPENSCAD_MCP_PRINTERS=a1,a1mini \
208
+ -- npx -y openscad-mcp-v2
209
+ ```
210
+
211
+ Or by hand in `~/.codex/config.toml` (or `.codex/config.toml` in a trusted project):
212
+
213
+ ```toml
214
+ [mcp_servers.openscad]
215
+ command = "npx"
216
+ args = ["-y", "openscad-mcp-v2"]
217
+
218
+ [mcp_servers.openscad.env]
219
+ OPENSCAD_MCP_WORKSPACE = "~/openscad-designs"
220
+ OPENSCAD_MCP_PRINTERS = "a1,a1mini"
221
+ ```
222
+
223
+ The ChatGPT desktop app reads the same configuration.
224
+
225
+ </details>
226
+
227
+ <details>
228
+ <summary><b>Cursor</b></summary>
229
+
230
+ `~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project:
231
+
232
+ ```json
233
+ {
234
+ "mcpServers": {
235
+ "openscad": {
236
+ "command": "npx",
237
+ "args": ["-y", "openscad-mcp-v2"],
238
+ "env": {
239
+ "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
240
+ "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
241
+ }
242
+ }
243
+ }
244
+ }
245
+ ```
246
+
247
+ Restart Cursor.
248
+
249
+ </details>
250
+
251
+ <details>
252
+ <summary><b>VS Code (GitHub Copilot agent mode)</b></summary>
253
+
254
+ `.vscode/mcp.json` in a project, or **MCP: Open User Configuration** from the command palette. The key is `servers`, not `mcpServers`:
255
+
256
+ ```json
257
+ {
258
+ "servers": {
259
+ "openscad": {
260
+ "type": "stdio",
261
+ "command": "npx",
262
+ "args": ["-y", "openscad-mcp-v2"],
263
+ "env": {
264
+ "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
265
+ "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
266
+ }
267
+ }
268
+ }
269
+ }
270
+ ```
271
+
272
+ </details>
273
+
274
+ <details>
275
+ <summary><b>Windsurf</b></summary>
276
+
277
+ `~/.codeium/windsurf/mcp_config.json` (Cascade → MCP → View raw config):
278
+
279
+ ```json
280
+ {
281
+ "mcpServers": {
282
+ "openscad": {
283
+ "command": "npx",
284
+ "args": ["-y", "openscad-mcp-v2"],
285
+ "env": {
286
+ "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
287
+ "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
288
+ }
289
+ }
290
+ }
291
+ }
292
+ ```
293
+
294
+ </details>
295
+
296
+ <details>
297
+ <summary><b>Cline</b></summary>
298
+
299
+ MCP Servers → Configure MCP Servers opens `cline_mcp_settings.json`:
300
+
301
+ ```json
302
+ {
303
+ "mcpServers": {
304
+ "openscad": {
305
+ "command": "npx",
306
+ "args": ["-y", "openscad-mcp-v2"],
307
+ "env": {
308
+ "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
309
+ "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
310
+ }
311
+ }
312
+ }
313
+ }
314
+ ```
315
+
316
+ </details>
317
+
318
+ <details>
319
+ <summary><b>Gemini CLI</b></summary>
320
+
321
+ `~/.gemini/settings.json`, or `.gemini/settings.json` in a project:
322
+
323
+ ```json
324
+ {
325
+ "mcpServers": {
326
+ "openscad": {
327
+ "command": "npx",
328
+ "args": ["-y", "openscad-mcp-v2"],
329
+ "env": {
330
+ "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
331
+ "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
332
+ }
333
+ }
334
+ }
335
+ }
336
+ ```
337
+
338
+ </details>
49
339
 
50
- ### Claude Desktop
340
+ <details>
341
+ <summary><b>Zed</b></summary>
51
342
 
52
- `claude_desktop_config.json` (Settings → Developer → Edit Config):
343
+ Zed's `settings.json`; the key is `context_servers`:
344
+
345
+ ```json
346
+ {
347
+ "context_servers": {
348
+ "openscad": {
349
+ "command": "npx",
350
+ "args": ["-y", "openscad-mcp-v2"],
351
+ "env": {
352
+ "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
353
+ "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
354
+ }
355
+ }
356
+ }
357
+ }
358
+ ```
359
+
360
+ </details>
361
+
362
+ <details>
363
+ <summary><b>Other MCP clients</b></summary>
364
+
365
+ Most clients use the `mcpServers` format:
53
366
 
54
367
  ```json
55
368
  {
@@ -66,7 +379,17 @@ Add `--scope user` to have it in every project. Then ask for a part, or start wi
66
379
  }
67
380
  ```
68
381
 
69
- Ask the client to run `check_setup` first: it reports the OpenSCAD version, the libraries it found, the workspace and the printer profiles, and says what is missing.
382
+ Some call the key `servers` or `context_servers`; the fields inside are the same.
383
+
384
+ </details>
385
+
386
+ ### 3. Check the setup and ask for a part
387
+
388
+ 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:
389
+
390
+ > A cable clip for the edge of my desk, desk 25 mm thick, room for three USB-C cables. Open it in OpenSCAD.
391
+
392
+ Or start with the prompt `new_design`. Designs are saved in `~/openscad-designs` unless you set `OPENSCAD_MCP_WORKSPACE`.
70
393
 
71
394
  ## Configuration
72
395
 
@@ -79,7 +402,7 @@ Ask the client to run `check_setup` first: it reports the OpenSCAD version, the
79
402
  | `OPENSCAD_MCP_IMAGE_SIZE` | `800x600` | Size of rendered images in pixels |
80
403
  | `OPENSCAD_MCP_COLORSCHEME` | `Tomorrow` | OpenSCAD colour scheme for images |
81
404
  | `OPENSCAD_MCP_PREVIEW_TIMEOUT_MS` | `60000` | Limit for validation and the automatic image |
82
- | `OPENSCAD_MCP_RENDER_TIMEOUT_MS` | `300000` | Limit for `render_views`, `analyze_design` and `export_design` |
405
+ | `OPENSCAD_MCP_RENDER_TIMEOUT_MS` | `300000` | Limit for `render_views`, `analyze_design`, `measure_design` and `export_design` |
83
406
  | `OPENSCAD_MCP_MANAGE_GUI_PREFS` | `true` | `false`: never change OpenSCAD's "Automatic Reload and Preview" setting |
84
407
 
85
408
  ### Printer profiles
@@ -103,16 +426,19 @@ A single call can name another one: `printer: "x1c"` or `printer: "300x300x400"`
103
426
  | `check_setup` | OpenSCAD version and path, libraries, workspace, printer profiles, state of the automatic reload |
104
427
  | `get_guidelines` | Design guidelines: workflow, code structure, FDM rules, screw sizes, installed libraries, OpenSCAD reference |
105
428
  | `list_designs` | Designs with latest version and time of change |
106
- | `create_design` | Saves new code as version 1, validates it, returns errors with source lines and an image |
107
- | `update_design` | Targeted text edits or complete new code, as a new version; validates and returns an image |
429
+ | `find_scad_files` | The files OpenSCAD opened last (the first is usually the one open now), or the `.scad` files in a folder |
430
+ | `link_file` | Makes an existing `.scad` file a design that is edited where it is; version 1 keeps it as it was |
431
+ | `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`) |
432
+ | `update_design` | Targeted text edits or complete new code, as a new version; validates and returns an image (`views` like `create_design`) |
108
433
  | `get_design` | Current code (or an old version) with its parameters |
109
434
  | `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 |
435
+ | `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
436
  | `open_in_openscad` | Shows the design in the OpenSCAD window, which then follows every change |
112
437
  | `list_versions`, `restore_version` | History, and going back (a restore is a new version) |
113
438
  | `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 |
115
- | `export_design` | 3MF (default) or binary STL into the design's `exports/` folder, with path, size and fit |
439
+ | `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 |
440
+ | `measure_design` | Distances in the rendered model: solid and empty stretches along lines parallel to X, Y or Z (wall thickness, the gap between two parts, hole widths), and whether points are in material; optional parameter overrides, e.g. an assembled pose |
441
+ | `export_design` | 3MF (default) or binary STL into the design's `exports/` folder, with path, size and fit; `parts: true` writes one file per part (box and lid separately) from the design's `part` parameter |
116
442
  | `record_learning`, `list_learnings`, `forget_learning` | Lessons for later designs: your corrections and preferences, techniques that failed or worked |
117
443
 
118
444
  Resources: `openscad://guidelines/3d-printing`, `openscad://guidelines/openscad-reference`, `openscad://guidelines/libraries`, `openscad://guidelines/learnings`, `openscad://design/{name}`. Prompts: `new_design`, `refine_design`.
@@ -141,6 +467,16 @@ OpenSCAD has no remote control. `open_in_openscad` starts it with the design's f
141
467
 
142
468
  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
469
 
470
+ ## Your existing files
471
+
472
+ 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`.
473
+
474
+ - 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.
475
+ - 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.
476
+ - 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.
477
+ - "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.
478
+ - A moved file: `link_file` with the design's name and the new path connects it again.
479
+
144
480
  ## Learnings
145
481
 
146
482
  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 +500,7 @@ The server learns from the work in your workspace. When you correct the model ("
164
500
  gui.json OpenSCAD windows this server opened
165
501
  ```
166
502
 
167
- Design names become folder names (lower-case letters, digits, dashes); nothing is written outside the workspace.
503
+ 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
504
 
169
505
  ## Printing
170
506
 
@@ -177,6 +513,7 @@ Printer servers can start a print without asking. This server's instructions tel
177
513
  - The closed-solid check is OpenSCAD's own. Two bodies that only share an edge pass it.
178
514
  - 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
515
  - Images show the bounding box fitted to the frame; there is no free camera yet.
516
+ - 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
517
 
181
518
  ## Development
182
519
 
@@ -187,6 +524,7 @@ git clone https://github.com/JohnnyTheTank/openscad-mcp-v2.git
187
524
  cd openscad-mcp-v2
188
525
  npm install
189
526
  npm run build
527
+ npm run bundle # optional: build/openscad-mcp-v2-<version>.mcpb for Claude Desktop
190
528
  ```
191
529
 
192
530
  ```bash
@@ -199,13 +537,20 @@ npx tsx scripts/call.ts render_views '{"name":"x"}' --images /tmp/out
199
537
 
200
538
  Notes for coding agents are in [CLAUDE.md](CLAUDE.md).
201
539
 
202
- ### Releasing
540
+ ### Benchmark
541
+
542
+ 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
543
 
204
- Set the new version in `package.json` (`npm version X.Y.Z --no-git-tag-version`) and in both places in `server.json`, add a `## X.Y.Z — date` section to the [CHANGELOG](CHANGELOG.md), merge to `main`, then publish a GitHub release `vX.Y.Z`. [`release.yml`](.github/workflows/release.yml) checks versions and CHANGELOG, runs the tests and publishes to npm (Trusted Publishing) and then to the MCP Registry, both through GitHub's OIDC identity without stored tokens. `gh workflow run release.yml` (a dry run by default) checks everything without publishing.
544
+ ```bash
545
+ npm run bench -- --tasks jar --runs 1 # one task, to try it
546
+ npm run bench -- --runs 3 --judge # all tasks, three runs each
547
+ npm run bench -- --runs 3 --judge --compare bench/baselines/<file>.json
548
+ npm run bench -- --grade <workspace> --design <name> --tasks jar # grade an existing design, no model
549
+ ```
205
550
 
206
- ## Background
551
+ 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
552
 
208
- Successor of the web app vibecad (Next.js, OpenSCAD in WebAssembly, its own model calls). The design guidelines, the snapshot idea and the split between quick preview and final render come from there; the architecture does not.
553
+ 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
554
 
210
555
  ## Security
211
556