OpenSCAD MCP V2

v1.3.0
io.github.JohnnyTheTank/openscad-mcp-v2 Checked 2 days ago Published 13 hours ago

Write, validate, render, version and export parametric OpenSCAD designs for 3D printing.

A local MCP server for OpenSCAD. 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. The server calls no language model. The MCP client is the model; the server gives it tools and design guidelines for 3D printing. macOS: the cask openscad (2021.01) is disabled in Homebrew since 2026-09-01.

Summary extracted from the README.

openscad-mcp-v2

A local MCP server for OpenSCAD. 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.

The server calls no language model. The MCP client is the model; the server gives it tools and design guidelines for 3D printing.

you: "Wall holder for a 28 mm broom handle, two M4 countersunk screws"
 └─ client writes SCAD ─► create_design ─► OpenSCAD errors and a rendered image come back
                          update_design ◄─ client fixes what it sees
                          open_in_openscad ─► the model is in your OpenSCAD window and follows changes
you: "export it"        ─► export_design ─► /…/broom-holder/exports/broom-holder-v0003.3mf

Install OpenSCAD: the development snapshot, not 2021.01

[!IMPORTANT] 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).

System Install
macOS brew install --cask openscad@snapshot
Windows Installer from openscad.org → Development Snapshots
Linux AppImage from openscad.org → Development Snapshots; put it on PATH as openscad or set OPENSCAD_PATH to it

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.

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.

Requirements

  • OpenSCAD development snapshot, see above.
  • Node.js 22 or newer.

Setup

The server is on npm as openscad-mcp-v2; npx fetches and starts it, nothing else to install.

Claude Code

claude mcp add openscad \
  -e OPENSCAD_MCP_WORKSPACE=~/openscad-designs \
  -e OPENSCAD_MCP_PRINTERS=a1,a1mini \
  -- npx -y openscad-mcp-v2

Add --scope user to have it in every project. Then ask for a part, or start with the prompt new_design.

Claude Desktop

claude_desktop_config.json (Settings → Developer → Edit Config):

{
  "mcpServers": {
    "openscad": {
      "command": "npx",
      "args": ["-y", "openscad-mcp-v2"],
      "env": {
        "OPENSCAD_MCP_WORKSPACE": "~/openscad-designs",
        "OPENSCAD_MCP_PRINTERS": "a1,a1mini"
      }
    }
  }
}

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.

Configuration

Variable Default Meaning
OPENSCAD_PATH auto-detect OpenSCAD executable, a command name, or the .app bundle on macOS
OPENSCAD_MCP_WORKSPACE ~/openscad-designs Folder with one sub-folder per design
OPENSCAD_MCP_PRINTERS generic (256 × 256 × 256 mm) Comma-separated printer profiles, see below; the first is the default
OPENSCAD_MCP_PREVIEW auto auto: create_design and update_design attach an image. never: only render_views renders
OPENSCAD_MCP_IMAGE_SIZE 800x600 Size of rendered images in pixels
OPENSCAD_MCP_COLORSCHEME Tomorrow OpenSCAD colour scheme for images
OPENSCAD_MCP_PREVIEW_TIMEOUT_MS 60000 Limit for validation and the automatic image
OPENSCAD_MCP_RENDER_TIMEOUT_MS 300000 Limit for render_views, analyze_design and export_design
OPENSCAD_MCP_MANAGE_GUI_PREFS true false: never change OpenSCAD's "Automatic Reload and Preview" setting

Printer profiles

analyze_design and export_design check the model against the build volume of every configured printer, also turned 90° and lying diagonally.

Built in: a1mini, a1, p1p, p1s, x1c, x1e, h2s, h2d (Bambu Lab), mk4, mini (Prusa), ender3. Your own: name:WIDTHxDEPTHxHEIGHT in mm.

OPENSCAD_MCP_PRINTERS=a1,a1mini
OPENSCAD_MCP_PRINTERS=voron:350x350x340,a1mini

A single call can name another one: printer: "x1c" or printer: "300x300x400".

Tools

Tool What it does
check_setup OpenSCAD version and path, libraries, workspace, printer profiles, state of the automatic reload
get_guidelines Design guidelines: workflow, code structure, FDM rules, screw sizes, installed libraries, OpenSCAD reference
list_designs Designs with latest version and time of change
create_design Saves new code as version 1, validates it, returns errors with source lines and an image
update_design Targeted text edits or complete new code, as a new version; validates and returns an image
get_design Current code (or an old version) with its parameters
validate_design Errors, warnings and echo output of the file as it is on disk
render_views Images from iso, iso_back, front, back, left, right, top, bottom; optional parameter overrides
open_in_openscad Shows the design in the OpenSCAD window, which then follows every change
list_versions, restore_version History, and going back (a restore is a new version)
set_parameters Lists the customizer parameters, or changes their values in the file
analyze_design Real size, bounding box, closed-solid check, bed contact, fit per printer
export_design 3MF (default) or binary STL into the design's exports/ folder, with path, size and fit
record_learning, list_learnings, forget_learning Lessons for later designs: your corrections and preferences, techniques that failed or worked

Resources: openscad://guidelines/3d-printing, openscad://guidelines/openscad-reference, openscad://guidelines/libraries, openscad://guidelines/learnings, openscad://design/{name}. Prompts: new_design, refine_design.

What counts as an error

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.

Libraries

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:

git clone --depth 1 https://github.com/BelfrySCAD/BOSL2.git ~/Documents/OpenSCAD/libraries/BOSL2

check_setup prints the library folder of your installation.

The OpenSCAD window

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.

  • 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.
  • 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.
  • Windows (implemented, not verified): OpenSCAD is started with the file; switch the setting on once yourself.

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.

Learnings

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.

  • 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.
  • 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.
  • 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.

Workspace

~/openscad-designs/
  broom-holder/
    broom-holder.scad        current code
    design.json              name, description, version counter
    versions/0001.scad …     every saved state, never overwritten
    renders/iso.png …        latest images
    exports/broom-holder-v0003.3mf
  .openscad-mcp/
    learnings.json           lessons for later designs
    gui.json                 OpenSCAD windows this server opened

Design names become folder names (lower-case letters, digits, dashes); nothing is written outside the workspace.

Printing

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 (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.

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.

Limits

  • The closed-solid check is OpenSCAD's own. Two bodies that only share an edge pass it.
  • Wall thickness, overhangs and bridges are not measured; the guidelines make the model design for them, and the slicer preview is the final check.
  • Images show the bounding box fitted to the frame; there is no free camera yet.

Development

From a checkout, point the client at node /absolute/path/to/openscad-mcp-v2/dist/index.js instead of npx -y openscad-mcp-v2:

git clone https://github.com/JohnnyTheTank/openscad-mcp-v2.git
cd openscad-mcp-v2
npm install
npm run build
npm test             # unit and integration tests; a smoke test uses the installed OpenSCAD when present
npm run typecheck
npm run lint
npx tsx scripts/call.ts check_setup                       # call a tool in-process
npx tsx scripts/call.ts render_views '{"name":"x"}' --images /tmp/out

Notes for coding agents are in CLAUDE.md.

Releasing

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, merge to main, then publish a GitHub release vX.Y.Z. 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.

Background

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.

Security

Report vulnerabilities privately, see SECURITY.md. It also describes what the server guards against and what it does not.

License

MIT