Repository avatar
Other Tools
v1.0.0
active

openscad-mcp-v2

io.github.JohnnyTheTank/openscad-mcp-v2

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

Documentation

OpenSCAD MCP v2

Describe a part to your AI assistant, get a 3MF for your 3D printer: as parametric OpenSCAD code you can open, change and keep.

Works with Claude Desktop, Claude Code, ChatGPT (desktop app), OpenAI Codex, Cursor, VS Code (Copilot), Windsurf, Cline, Gemini CLI, Zed and other MCP clients.

npm MCP Registry Node License: MIT

Rendered wall holder for a broom handle: a C-shaped clip on a wall plate with two countersunk screw holes
"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.

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

Is this for you?

  • 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.
  • You already use an AI assistant with MCP support (list above, setup). The server calls no language model and needs no API key: your client's model does the thinking, on the plan you already have.
  • 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.
  • 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.

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.

Examples

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/, including the broom holder above.

Rendered box with rounded corners and a snap-fit lid lying next to itRendered phone stand with a leaning back, a front lip and a slot for the charging cableRendered round knob with grip flutes and a pointer mark on top
"A 60 × 40 × 30 mm box with a snap-fit lid." Box and lid side by side on the bed. code"A phone stand with a slot for the charging cable." Prints without supports. code"A replacement knob for a 6 mm D-shaft, 36 mm across." D-shaped hole underneath. code

What a session looks like

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: "2 mm more clearance, then export it"
                          set_parameters ─► export_design ─► /…/broom-holder/exports/broom-holder-v0003.3mf

You open the 3MF in Bambu Studio, OrcaSlicer or PrusaSlicer and print it.

What it does

  • 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.
  • Sees the part. Every save returns a rendered image; render_views shows any side. The client compares the image with your request and fixes what is off.
  • 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.
  • Never loses a state. Every save is a version; going back adds a new one.
  • 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).
  • Learns your preferences. Corrections such as "always round the edges" are saved and come back with the guidelines for the next part.
  • 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.

Quickstart

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.

Let your coding agent set it up

Paste this into Claude Code, Codex, Cursor or another coding agent that can run commands on your computer:

Set up the OpenSCAD MCP server openscad-mcp-v2 for me on this computer.
Instructions and client configurations: https://github.com/JohnnyTheTank/openscad-mcp-v2#readme

1. Node.js: run `node --version`. It must be 22 or newer. If it is missing or older,
   tell me how to install it and stop.
2. OpenSCAD: it must be a development snapshot from 2024 or newer, not the 2021.01 release.
   Check `openscad --version`; on macOS also look for /Applications/OpenSCAD.app.
   - macOS: `brew install --cask openscad@snapshot`. If an old OpenSCAD.app is in the way,
     ask me before removing it.
   - Windows or Linux: show me the snapshot download on
     https://openscad.org/downloads.html#snapshots. On Linux, put the AppImage on PATH as
     `openscad`, or remember its path for OPENSCAD_PATH.
3. Printers: ask me which 3D printers I use. Built-in profiles: a1mini, a1, p1p, p1s, x1c,
   x1e, h2s, h2d, mk4, mini, ender3; any other as name:WIDTHxDEPTHxHEIGHT in mm.
   The first one is the default. This becomes OPENSCAD_MCP_PRINTERS, comma-separated.
4. Check: if `npx -y openscad-mcp-v2 --help` lists `--check`, run
   `npx -y openscad-mcp-v2 --check` with OPENSCAD_MCP_PRINTERS (and OPENSCAD_PATH if needed)
   set. Exit code 1 means a problem; fix what it reports. Without `--check` in the help,
   skip this step, and do not run the bare command: it starts the server and waits for input.
5. Clients: ask me which MCP clients I want to use it in (for example Claude Desktop,
   Claude Code, ChatGPT desktop, Codex, Cursor, VS Code). Add the server to each one as the
   README section "Add the server to your client" shows: command `npx`, arguments
   `-y openscad-mcp-v2`, and the environment variables from steps 2 and 3. Back up each
   config file first, merge into it and keep the other servers that are there.
6. Libraries: ask me whether to install BOSL2. If yes, clone
   https://github.com/BelfrySCAD/BOSL2 into the library folder that `--check` reports
   (macOS default: ~/Documents/OpenSCAD/libraries/BOSL2).
7. Tell me which clients I have to restart, and that I can then ask there:
   "Run check_setup, then design a wall hook for a 28 mm broom handle."

1. Install OpenSCAD: the development snapshot, not 2021.01

[!IMPORTANT] The download button on openscad.org and most package managers give you OpenSCAD 2021.01. Install a development snapshot (2024 or newer) instead.

SystemInstall
macOSbrew install --cask openscad@snapshot
WindowsInstaller from openscad.org → Development Snapshots
LinuxAppImage from openscad.org → Development Snapshots; put it on PATH as openscad or set OPENSCAD_PATH to it
Why the snapshot, and how to check

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.

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

2. Add the server to your client

The server is on npm as 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. Set OPENSCAD_MCP_PRINTERS to your printers (profiles). Only the place where this goes differs between clients: open yours below.

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.

Claude Desktop

Settings → Developer → Edit Config opens claude_desktop_config.json. Add:

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

Restart Claude Desktop.

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.

ChatGPT (desktop app)

Settings → MCP servers → Add server → STDIO:

  • Command: npx
  • Arguments: -y openscad-mcp-v2
  • Environment variables: OPENSCAD_MCP_WORKSPACE = ~/openscad-designs, OPENSCAD_MCP_PRINTERS = a1,a1mini

Save and select Restart. The desktop app shares its MCP servers with Codex, so you can also add the server to ~/.codex/config.toml:

[mcp_servers.openscad]
command = "npx"
args = ["-y", "openscad-mcp-v2"]

[mcp_servers.openscad.env]
OPENSCAD_MCP_WORKSPACE = "~/openscad-designs"
OPENSCAD_MCP_PRINTERS = "a1,a1mini"
OpenAI Codex (CLI, IDE extension)
codex mcp add openscad \
  --env OPENSCAD_MCP_WORKSPACE=~/openscad-designs \
  --env OPENSCAD_MCP_PRINTERS=a1,a1mini \
  -- npx -y openscad-mcp-v2

Or by hand in ~/.codex/config.toml (or .codex/config.toml in a trusted project):

[mcp_servers.openscad]
command = "npx"
args = ["-y", "openscad-mcp-v2"]

[mcp_servers.openscad.env]
OPENSCAD_MCP_WORKSPACE = "~/openscad-designs"
OPENSCAD_MCP_PRINTERS = "a1,a1mini"

The ChatGPT desktop app reads the same configuration.

Cursor

~/.cursor/mcp.json, or .cursor/mcp.json in a project:

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

Restart Cursor.

VS Code (GitHub Copilot agent mode)

.vscode/mcp.json in a project, or MCP: Open User Configuration from the command palette. The key is servers, not mcpServers:

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

~/.codeium/windsurf/mcp_config.json (Cascade → MCP → View raw config):

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

MCP Servers → Configure MCP Servers opens cline_mcp_settings.json:

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

~/.gemini/settings.json, or .gemini/settings.json in a project:

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

Zed's settings.json; the key is context_servers:

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

Most clients use the mcpServers format:

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

Some call the key servers or context_servers; the fields inside are the same.

3. Check the setup and ask for a part

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. Versions after 1.0.0 print the same report in a terminal with npx -y openscad-mcp-v2 --check (exit code 1 when something is missing). Then describe a part, for example:

A cable clip for the edge of my desk, desk 25 mm thick, room for three USB-C cables. Open it in OpenSCAD.

Or start with the prompt new_design. Designs are saved in ~/openscad-designs unless you set OPENSCAD_MCP_WORKSPACE.

Configuration

VariableDefaultMeaning
OPENSCAD_PATHauto-detectOpenSCAD executable, a command name, or the .app bundle on macOS
OPENSCAD_MCP_WORKSPACE~/openscad-designsFolder with one sub-folder per design
OPENSCAD_MCP_PRINTERSgeneric (256 × 256 × 256 mm)Comma-separated printer profiles, see below; the first is the default
OPENSCAD_MCP_PREVIEWautoauto: create_design and update_design attach an image. never: only render_views renders
OPENSCAD_MCP_IMAGE_SIZE800x600Size of rendered images in pixels
OPENSCAD_MCP_COLORSCHEMETomorrowOpenSCAD colour scheme for images
OPENSCAD_MCP_PREVIEW_TIMEOUT_MS60000Limit for validation and the automatic image
OPENSCAD_MCP_RENDER_TIMEOUT_MS300000Limit for render_views, analyze_design and export_design
OPENSCAD_MCP_MANAGE_GUI_PREFStruefalse: 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

ToolWhat it does
check_setupOpenSCAD version and path, libraries, workspace, printer profiles, state of the automatic reload
get_guidelinesDesign guidelines: workflow, code structure, FDM rules, screw sizes, installed libraries, OpenSCAD reference
list_designsDesigns with latest version and time of change
create_designSaves new code as version 1, validates it, returns errors with source lines and an image
update_designTargeted text edits or complete new code, as a new version; validates and returns an image
get_designCurrent code (or an old version) with its parameters
validate_designErrors, warnings and echo output of the file as it is on disk
render_viewsImages from iso, iso_back, front, back, left, right, top, bottom; optional parameter overrides
open_in_openscadShows the design in the OpenSCAD window, which then follows every change
list_versions, restore_versionHistory, and going back (a restore is a new version)
set_parametersLists the customizer parameters, or changes their values in the file
analyze_designReal size, bounding box, closed-solid check, bed contact, fit per printer
export_design3MF (default) or binary STL into the design's exports/ folder, with path, size and fit
record_learning, list_learnings, forget_learningLessons 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.

Security

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

License

MIT