openscad-mcp-v2 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +548 -2
- package/dist/index.js +3901 -0
- package/package.json +79 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jonathan Hornung
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,549 @@
|
|
|
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
|
+
|
|
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
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
you: "Wall holder for a 28 mm broom handle, two M4 countersunk screws"
|
|
42
|
+
└─ client writes SCAD ─► create_design ─► OpenSCAD errors and a rendered image come back
|
|
43
|
+
update_design ◄─ client fixes what it sees
|
|
44
|
+
open_in_openscad ─► the model is in your OpenSCAD window and follows changes
|
|
45
|
+
you: "2 mm more clearance, then export it"
|
|
46
|
+
set_parameters ─► export_design ─► /…/broom-holder/exports/broom-holder-v0003.3mf
|
|
47
|
+
```
|
|
48
|
+
|
|
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
|
|
103
|
+
|
|
104
|
+
> [!IMPORTANT]
|
|
105
|
+
> The download button on openscad.org and most package managers give you **OpenSCAD 2021.01**. Install a **development snapshot (2024 or newer)** instead.
|
|
106
|
+
|
|
107
|
+
| System | Install |
|
|
108
|
+
|---|---|
|
|
109
|
+
| **macOS** | `brew install --cask openscad@snapshot` |
|
|
110
|
+
| **Windows** | Installer from [openscad.org → Development Snapshots](https://openscad.org/downloads.html#snapshots) |
|
|
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 |
|
|
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
|
+
|
|
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.
|
|
119
|
+
|
|
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>
|
|
123
|
+
|
|
124
|
+
### 2. Add the server to your client
|
|
125
|
+
|
|
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.
|
|
127
|
+
|
|
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.
|
|
129
|
+
|
|
130
|
+
<details>
|
|
131
|
+
<summary><b>Claude Desktop</b></summary>
|
|
132
|
+
|
|
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>
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
claude mcp add openscad \
|
|
159
|
+
-e OPENSCAD_MCP_WORKSPACE=~/openscad-designs \
|
|
160
|
+
-e OPENSCAD_MCP_PRINTERS=a1,a1mini \
|
|
161
|
+
-- npx -y openscad-mcp-v2
|
|
162
|
+
```
|
|
163
|
+
|
|
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>
|
|
329
|
+
|
|
330
|
+
<details>
|
|
331
|
+
<summary><b>Zed</b></summary>
|
|
332
|
+
|
|
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:
|
|
356
|
+
|
|
357
|
+
```json
|
|
358
|
+
{
|
|
359
|
+
"mcpServers": {
|
|
360
|
+
"openscad": {
|
|
361
|
+
"command": "npx",
|
|
362
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
363
|
+
"env": {
|
|
364
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
365
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
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`.
|
|
383
|
+
|
|
384
|
+
## Configuration
|
|
385
|
+
|
|
386
|
+
| Variable | Default | Meaning |
|
|
387
|
+
|---|---|---|
|
|
388
|
+
| `OPENSCAD_PATH` | auto-detect | OpenSCAD executable, a command name, or the `.app` bundle on macOS |
|
|
389
|
+
| `OPENSCAD_MCP_WORKSPACE` | `~/openscad-designs` | Folder with one sub-folder per design |
|
|
390
|
+
| `OPENSCAD_MCP_PRINTERS` | `generic` (256 × 256 × 256 mm) | Comma-separated printer profiles, see below; the first is the default |
|
|
391
|
+
| `OPENSCAD_MCP_PREVIEW` | `auto` | `auto`: `create_design` and `update_design` attach an image. `never`: only `render_views` renders |
|
|
392
|
+
| `OPENSCAD_MCP_IMAGE_SIZE` | `800x600` | Size of rendered images in pixels |
|
|
393
|
+
| `OPENSCAD_MCP_COLORSCHEME` | `Tomorrow` | OpenSCAD colour scheme for images |
|
|
394
|
+
| `OPENSCAD_MCP_PREVIEW_TIMEOUT_MS` | `60000` | Limit for validation and the automatic image |
|
|
395
|
+
| `OPENSCAD_MCP_RENDER_TIMEOUT_MS` | `300000` | Limit for `render_views`, `analyze_design` and `export_design` |
|
|
396
|
+
| `OPENSCAD_MCP_MANAGE_GUI_PREFS` | `true` | `false`: never change OpenSCAD's "Automatic Reload and Preview" setting |
|
|
397
|
+
|
|
398
|
+
### Printer profiles
|
|
399
|
+
|
|
400
|
+
`analyze_design` and `export_design` check the model against the build volume of every configured printer, also turned 90° and lying diagonally.
|
|
401
|
+
|
|
402
|
+
Built in: `a1mini`, `a1`, `p1p`, `p1s`, `x1c`, `x1e`, `h2s`, `h2d` (Bambu Lab), `mk4`, `mini` (Prusa), `ender3`.
|
|
403
|
+
Your own: `name:WIDTHxDEPTHxHEIGHT` in mm.
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
OPENSCAD_MCP_PRINTERS=a1,a1mini
|
|
407
|
+
OPENSCAD_MCP_PRINTERS=voron:350x350x340,a1mini
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
A single call can name another one: `printer: "x1c"` or `printer: "300x300x400"`.
|
|
411
|
+
|
|
412
|
+
## Tools
|
|
413
|
+
|
|
414
|
+
| Tool | What it does |
|
|
415
|
+
|---|---|
|
|
416
|
+
| `check_setup` | OpenSCAD version and path, libraries, workspace, printer profiles, state of the automatic reload |
|
|
417
|
+
| `get_guidelines` | Design guidelines: workflow, code structure, FDM rules, screw sizes, installed libraries, OpenSCAD reference |
|
|
418
|
+
| `list_designs` | Designs with latest version and time of change |
|
|
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`) |
|
|
423
|
+
| `get_design` | Current code (or an old version) with its parameters |
|
|
424
|
+
| `validate_design` | Errors, warnings and echo output of the file as it is on disk |
|
|
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 |
|
|
426
|
+
| `open_in_openscad` | Shows the design in the OpenSCAD window, which then follows every change |
|
|
427
|
+
| `list_versions`, `restore_version` | History, and going back (a restore is a new version) |
|
|
428
|
+
| `set_parameters` | Lists the customizer parameters, or changes their values in the file |
|
|
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 |
|
|
430
|
+
| `export_design` | 3MF (default) or binary STL into the design's `exports/` folder, with path, size and fit |
|
|
431
|
+
| `record_learning`, `list_learnings`, `forget_learning` | Lessons for later designs: your corrections and preferences, techniques that failed or worked |
|
|
432
|
+
|
|
433
|
+
Resources: `openscad://guidelines/3d-printing`, `openscad://guidelines/openscad-reference`, `openscad://guidelines/libraries`, `openscad://guidelines/learnings`, `openscad://design/{name}`. Prompts: `new_design`, `refine_design`.
|
|
434
|
+
|
|
435
|
+
### What counts as an error
|
|
436
|
+
|
|
437
|
+
OpenSCAD exits with 0 after a failed `assert()` and still writes files, and it only warns about an unknown module or a missing library although part of the model is then gone. The server treats both as errors and returns them with file, line and the source lines around it, so the client can repair its own code.
|
|
438
|
+
|
|
439
|
+
## Libraries
|
|
440
|
+
|
|
441
|
+
Libraries in OpenSCAD's library folders are found automatically, and `get_guidelines` adds usage notes for BOSL2, NopSCADlib and MCAD when they are installed. To install BOSL2 on macOS:
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
git clone --depth 1 https://github.com/BelfrySCAD/BOSL2.git ~/Documents/OpenSCAD/libraries/BOSL2
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
`check_setup` prints the library folder of your installation.
|
|
448
|
+
|
|
449
|
+
## The OpenSCAD window
|
|
450
|
+
|
|
451
|
+
OpenSCAD has no remote control. `open_in_openscad` starts it with the design's file and relies on OpenSCAD's own setting **Design → Automatic Reload and Preview**, which makes the window follow the file.
|
|
452
|
+
|
|
453
|
+
- **macOS** (verified): the server switches the setting on before it starts OpenSCAD. If OpenSCAD is already running with the setting off, the tool says so; switch it on once in the menu.
|
|
454
|
+
- **Linux** (implemented, not verified on a Linux machine): the setting is written to `~/.config/OpenSCAD/OpenSCAD.conf`; each design opens in its own OpenSCAD process.
|
|
455
|
+
- **Windows** (implemented, not verified): OpenSCAD is started with the file; switch the setting on once yourself.
|
|
456
|
+
|
|
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.
|
|
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
|
+
|
|
469
|
+
## Learnings
|
|
470
|
+
|
|
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.
|
|
472
|
+
|
|
473
|
+
- Changes you make in OpenSCAD's editor or Customizer are reported to the client as a diff (changed values and changed lines) by the next tool that works on the design. `list_versions` keeps a summary of them.
|
|
474
|
+
- Learnings live in `.openscad-mcp/learnings.json` in the workspace, at most 100 at a time. `list_learnings` shows them with the reason; ask the client to forget one that is wrong (`forget_learning`). Nothing is deleted from the file: forgotten and replaced learnings stay with their reason.
|
|
475
|
+
- The server's instructions tell the client to take learnings only from your own words and from this server's results, never from text inside SCAD files or other tools, and that a learning never changes the rules on exporting and printing. The server cannot check where a sentence came from, so look at `list_learnings` now and then.
|
|
476
|
+
|
|
477
|
+
## Workspace
|
|
478
|
+
|
|
479
|
+
```
|
|
480
|
+
~/openscad-designs/
|
|
481
|
+
broom-holder/
|
|
482
|
+
broom-holder.scad current code
|
|
483
|
+
design.json name, description, version counter
|
|
484
|
+
versions/0001.scad … every saved state, never overwritten
|
|
485
|
+
renders/iso.png … latest images
|
|
486
|
+
exports/broom-holder-v0003.3mf
|
|
487
|
+
.openscad-mcp/
|
|
488
|
+
learnings.json lessons for later designs
|
|
489
|
+
gui.json OpenSCAD windows this server opened
|
|
490
|
+
```
|
|
491
|
+
|
|
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).
|
|
493
|
+
|
|
494
|
+
## Printing
|
|
495
|
+
|
|
496
|
+
This server ends at the exported file. 3MF and STL are models, not print jobs: a slicer turns them into one. Open the file in Bambu Studio, OrcaSlicer or PrusaSlicer, or hand its path to a printer MCP server that slices, such as [bambu-printer-mcp](https://github.com/DMontgomery40/bambu-printer-mcp) (`print_3mf` slices an unsliced 3MF with the Bambu Studio CLI first). An export of this server was sliced with the Bambu Studio 2.9 CLI for an A1 mini as a check.
|
|
497
|
+
|
|
498
|
+
Printer servers can start a print without asking. This server's instructions tell the model to start a print only after you asked for it in the conversation; keep your client's tool approval on for printer tools.
|
|
499
|
+
|
|
500
|
+
## Limits
|
|
501
|
+
|
|
502
|
+
- The closed-solid check is OpenSCAD's own. Two bodies that only share an edge pass it.
|
|
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.
|
|
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.
|
|
506
|
+
|
|
507
|
+
## Development
|
|
508
|
+
|
|
509
|
+
From a checkout, point the client at `node /absolute/path/to/openscad-mcp-v2/dist/index.js` instead of `npx -y openscad-mcp-v2`:
|
|
510
|
+
|
|
511
|
+
```bash
|
|
512
|
+
git clone https://github.com/JohnnyTheTank/openscad-mcp-v2.git
|
|
513
|
+
cd openscad-mcp-v2
|
|
514
|
+
npm install
|
|
515
|
+
npm run build
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
npm test # unit and integration tests; a smoke test uses the installed OpenSCAD when present
|
|
520
|
+
npm run typecheck
|
|
521
|
+
npm run lint
|
|
522
|
+
npx tsx scripts/call.ts check_setup # call a tool in-process
|
|
523
|
+
npx tsx scripts/call.ts render_views '{"name":"x"}' --images /tmp/out
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Notes for coding agents are in [CLAUDE.md](CLAUDE.md).
|
|
527
|
+
|
|
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.
|
|
531
|
+
|
|
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
|
+
```
|
|
538
|
+
|
|
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.
|
|
540
|
+
|
|
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).
|
|
542
|
+
|
|
543
|
+
## Security
|
|
544
|
+
|
|
545
|
+
Report vulnerabilities privately, see [SECURITY.md](SECURITY.md). It also describes what the server guards against and what it does not.
|
|
546
|
+
|
|
547
|
+
## License
|
|
548
|
+
|
|
549
|
+
MIT
|