openscad-mcp-v2 0.0.0-stage → 1.0.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 +215 -2
- package/dist/index.js +3215 -0
- package/package.json +61 -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,216 @@
|
|
|
1
|
-
#
|
|
1
|
+
# openscad-mcp-v2
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
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.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
you: "Wall holder for a 28 mm broom handle, two M4 countersunk screws"
|
|
9
|
+
└─ client writes SCAD ─► create_design ─► OpenSCAD errors and a rendered image come back
|
|
10
|
+
update_design ◄─ client fixes what it sees
|
|
11
|
+
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
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Install OpenSCAD: the development snapshot, not 2021.01
|
|
16
|
+
|
|
17
|
+
> [!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)**.
|
|
19
|
+
|
|
20
|
+
| System | Install |
|
|
21
|
+
|---|---|
|
|
22
|
+
| **macOS** | `brew install --cask openscad@snapshot` |
|
|
23
|
+
| **Windows** | Installer from [openscad.org → Development Snapshots](https://openscad.org/downloads.html#snapshots) |
|
|
24
|
+
| **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
|
+
|
|
26
|
+
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
|
+
|
|
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.
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- **OpenSCAD** development snapshot, see above.
|
|
33
|
+
- **Node.js 22** or newer.
|
|
34
|
+
|
|
35
|
+
## Setup
|
|
36
|
+
|
|
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.
|
|
38
|
+
|
|
39
|
+
### Claude Code
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
claude mcp add openscad \
|
|
43
|
+
-e OPENSCAD_MCP_WORKSPACE=~/openscad-designs \
|
|
44
|
+
-e OPENSCAD_MCP_PRINTERS=a1,a1mini \
|
|
45
|
+
-- npx -y openscad-mcp-v2
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Add `--scope user` to have it in every project. Then ask for a part, or start with the prompt `new_design`.
|
|
49
|
+
|
|
50
|
+
### Claude Desktop
|
|
51
|
+
|
|
52
|
+
`claude_desktop_config.json` (Settings → Developer → Edit Config):
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"openscad": {
|
|
58
|
+
"command": "npx",
|
|
59
|
+
"args": ["-y", "openscad-mcp-v2"],
|
|
60
|
+
"env": {
|
|
61
|
+
"OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
|
|
62
|
+
"OPENSCAD_MCP_PRINTERS": "a1,a1mini"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
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.
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
| Variable | Default | Meaning |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `OPENSCAD_PATH` | auto-detect | OpenSCAD executable, a command name, or the `.app` bundle on macOS |
|
|
76
|
+
| `OPENSCAD_MCP_WORKSPACE` | `~/openscad-designs` | Folder with one sub-folder per design |
|
|
77
|
+
| `OPENSCAD_MCP_PRINTERS` | `generic` (256 × 256 × 256 mm) | Comma-separated printer profiles, see below; the first is the default |
|
|
78
|
+
| `OPENSCAD_MCP_PREVIEW` | `auto` | `auto`: `create_design` and `update_design` attach an image. `never`: only `render_views` renders |
|
|
79
|
+
| `OPENSCAD_MCP_IMAGE_SIZE` | `800x600` | Size of rendered images in pixels |
|
|
80
|
+
| `OPENSCAD_MCP_COLORSCHEME` | `Tomorrow` | OpenSCAD colour scheme for images |
|
|
81
|
+
| `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` |
|
|
83
|
+
| `OPENSCAD_MCP_MANAGE_GUI_PREFS` | `true` | `false`: never change OpenSCAD's "Automatic Reload and Preview" setting |
|
|
84
|
+
|
|
85
|
+
### Printer profiles
|
|
86
|
+
|
|
87
|
+
`analyze_design` and `export_design` check the model against the build volume of every configured printer, also turned 90° and lying diagonally.
|
|
88
|
+
|
|
89
|
+
Built in: `a1mini`, `a1`, `p1p`, `p1s`, `x1c`, `x1e`, `h2s`, `h2d` (Bambu Lab), `mk4`, `mini` (Prusa), `ender3`.
|
|
90
|
+
Your own: `name:WIDTHxDEPTHxHEIGHT` in mm.
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
OPENSCAD_MCP_PRINTERS=a1,a1mini
|
|
94
|
+
OPENSCAD_MCP_PRINTERS=voron:350x350x340,a1mini
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
A single call can name another one: `printer: "x1c"` or `printer: "300x300x400"`.
|
|
98
|
+
|
|
99
|
+
## Tools
|
|
100
|
+
|
|
101
|
+
| Tool | What it does |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `check_setup` | OpenSCAD version and path, libraries, workspace, printer profiles, state of the automatic reload |
|
|
104
|
+
| `get_guidelines` | Design guidelines: workflow, code structure, FDM rules, screw sizes, installed libraries, OpenSCAD reference |
|
|
105
|
+
| `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 |
|
|
108
|
+
| `get_design` | Current code (or an old version) with its parameters |
|
|
109
|
+
| `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 |
|
|
111
|
+
| `open_in_openscad` | Shows the design in the OpenSCAD window, which then follows every change |
|
|
112
|
+
| `list_versions`, `restore_version` | History, and going back (a restore is a new version) |
|
|
113
|
+
| `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 |
|
|
116
|
+
| `record_learning`, `list_learnings`, `forget_learning` | Lessons for later designs: your corrections and preferences, techniques that failed or worked |
|
|
117
|
+
|
|
118
|
+
Resources: `openscad://guidelines/3d-printing`, `openscad://guidelines/openscad-reference`, `openscad://guidelines/libraries`, `openscad://guidelines/learnings`, `openscad://design/{name}`. Prompts: `new_design`, `refine_design`.
|
|
119
|
+
|
|
120
|
+
### What counts as an error
|
|
121
|
+
|
|
122
|
+
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.
|
|
123
|
+
|
|
124
|
+
## Libraries
|
|
125
|
+
|
|
126
|
+
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:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
git clone --depth 1 https://github.com/BelfrySCAD/BOSL2.git ~/Documents/OpenSCAD/libraries/BOSL2
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`check_setup` prints the library folder of your installation.
|
|
133
|
+
|
|
134
|
+
## The OpenSCAD window
|
|
135
|
+
|
|
136
|
+
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.
|
|
137
|
+
|
|
138
|
+
- **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.
|
|
139
|
+
- **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.
|
|
140
|
+
- **Windows** (implemented, not verified): OpenSCAD is started with the file; switch the setting on once yourself.
|
|
141
|
+
|
|
142
|
+
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
|
+
|
|
144
|
+
## Learnings
|
|
145
|
+
|
|
146
|
+
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.
|
|
147
|
+
|
|
148
|
+
- 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.
|
|
149
|
+
- 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.
|
|
150
|
+
- 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.
|
|
151
|
+
|
|
152
|
+
## Workspace
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
~/openscad-designs/
|
|
156
|
+
broom-holder/
|
|
157
|
+
broom-holder.scad current code
|
|
158
|
+
design.json name, description, version counter
|
|
159
|
+
versions/0001.scad … every saved state, never overwritten
|
|
160
|
+
renders/iso.png … latest images
|
|
161
|
+
exports/broom-holder-v0003.3mf
|
|
162
|
+
.openscad-mcp/
|
|
163
|
+
learnings.json lessons for later designs
|
|
164
|
+
gui.json OpenSCAD windows this server opened
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Design names become folder names (lower-case letters, digits, dashes); nothing is written outside the workspace.
|
|
168
|
+
|
|
169
|
+
## Printing
|
|
170
|
+
|
|
171
|
+
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.
|
|
172
|
+
|
|
173
|
+
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.
|
|
174
|
+
|
|
175
|
+
## Limits
|
|
176
|
+
|
|
177
|
+
- The closed-solid check is OpenSCAD's own. Two bodies that only share an edge pass it.
|
|
178
|
+
- 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
|
+
- Images show the bounding box fitted to the frame; there is no free camera yet.
|
|
180
|
+
|
|
181
|
+
## Development
|
|
182
|
+
|
|
183
|
+
From a checkout, point the client at `node /absolute/path/to/openscad-mcp-v2/dist/index.js` instead of `npx -y openscad-mcp-v2`:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
git clone https://github.com/JohnnyTheTank/openscad-mcp-v2.git
|
|
187
|
+
cd openscad-mcp-v2
|
|
188
|
+
npm install
|
|
189
|
+
npm run build
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm test # unit and integration tests; a smoke test uses the installed OpenSCAD when present
|
|
194
|
+
npm run typecheck
|
|
195
|
+
npm run lint
|
|
196
|
+
npx tsx scripts/call.ts check_setup # call a tool in-process
|
|
197
|
+
npx tsx scripts/call.ts render_views '{"name":"x"}' --images /tmp/out
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Notes for coding agents are in [CLAUDE.md](CLAUDE.md).
|
|
201
|
+
|
|
202
|
+
### Releasing
|
|
203
|
+
|
|
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.
|
|
205
|
+
|
|
206
|
+
## Background
|
|
207
|
+
|
|
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.
|
|
209
|
+
|
|
210
|
+
## Security
|
|
211
|
+
|
|
212
|
+
Report vulnerabilities privately, see [SECURITY.md](SECURITY.md). It also describes what the server guards against and what it does not.
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
MIT
|