Skip to main content
Glama

OpenSCAD MCP Server

License: MIT Python 3.8+

A Model Context Protocol (MCP) server that provides seamless integration between Large Language Models and OpenSCAD for collaborative 3D modeling and rapid prototyping.

๐Ÿš€ Features

  • Natural Language to 3D Models: Describe your design in plain English and get working OpenSCAD code

  • Live Visual Feedback: Real-time rendering with base64 PNG images optimized for vision models

  • Instant 3D Printing: Direct STL export ready for your 3D printer

  • Persistent Workspace: Scratchpad maintains your work across sessions

  • Multiple Camera Views: Inspect your models from all angles (isometric, front, back, left, right, top, bottom)

  • Error Handling: Comprehensive error reporting and logging for debugging

Related MCP server: OpenSCAD MCP Server

๐ŸŽฏ Use Cases

  • Rapid Prototyping: Quickly iterate on mechanical parts and assemblies

  • Educational Tools: Learn 3D modeling through conversational interfaces

  • Parametric Design: Generate families of related objects with simple parameter changes

  • Accessibility: 3D modeling for users who prefer text-based interfaces

  • Automation: Integrate 3D model generation into larger workflows

๐Ÿ“‹ Requirements

  • Python 3.8+

  • OpenSCAD (installed and accessible via command line)

  • fastmcp library

๐Ÿ› ๏ธ Installation

1. Install OpenSCAD

Windows:

# Download from https://openscad.org/downloads.html
# Or via Chocolatey:
choco install openscad

macOS:

brew install openscad

Linux (Ubuntu/Debian):

sudo apt-get install openscad

2. Clone and Run

git clone https://github.com/jabberjabberjabber/openscad-mcp
cd openscad-mcp
uv run --with fastmcp fastmcp dev main.py

3. Install

Add this to your client's MCP config:

  "mcpServers": {
    "openscad-mcp": {
      "command": "uv",
      "args": [
		"run",
		"--with",
		"fastmcp",
		"fastmcp",
		"run",
        "c:/path/to/openscad-mcp/main.py"
      ],
      "env": {
        "OPENSCAD_WORK_DIR": "c:/path/to/openscad-mcp/"
      }
    }
    },

๐ŸŽฎ Usage

The server provides five main tools for 3D modeling workflows:

Available Tools

Tool

Purpose

Parameters

show_openscad_script

Display current script

None

create_openscad_script

Create/update script

script_content: str

view_render

Render PNG image

view: str (optional)

export_model_to_stl

Export for 3D printing

filename: str

save_openscad_script

Save script to file

filename: str

Example Workflow

# 1. Create a model
create_openscad_script("""
// Simple cube with rounded corners
$fn = 32;
minkowski() {
    cube([20, 20, 10], center=true);
    sphere(r=2);
}
""")

# 2. View the result
view_render("isometric")  # Returns base64 PNG

# 3. Export for printing
export_model_to_stl("rounded_cube")

# 4. Save the source
save_openscad_script("rounded_cube")

Camera Views

  • isometric (default) - 3D perspective view

  • front - Front orthographic view

  • back - Back orthographic view

  • left - Left side view

  • right - Right side view

  • top - Top-down view

  • bottom - Bottom-up view

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   LLM Client    โ”‚โ”€โ”€โ”€โ–ถโ”‚  MCP Server      โ”‚โ”€โ”€โ”€โ–ถโ”‚   OpenSCAD      โ”‚
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚   Engine        โ”‚
โ”‚ Natural Languageโ”‚    โ”‚ โ€ข Script Storage โ”‚    โ”‚ โ€ข Rendering     โ”‚
โ”‚ Descriptions    โ”‚    โ”‚ โ€ข State Mgmt     โ”‚    โ”‚ โ€ข STL Export    โ”‚
โ”‚                 โ”‚โ—€โ”€โ”€โ”€โ”‚ โ€ข Error Handling โ”‚โ—€โ”€โ”€โ”€โ”‚ โ€ข Validation    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Components

  • Persistent State: JSON-based scratchpad for session continuity

  • OpenSCAD Integration: Subprocess calls with timeout protection

  • Image Generation: Base64 PNG encoding for vision model compatibility

  • File Management: Organized output to configurable working directory

  • Error Handling: Comprehensive logging and graceful failure modes

๐ŸŽจ Example Projects

Hollow Sphere (Vase Mode)

$fn = 64;
difference() {
    sphere(r=15);      // 30mm diameter
    sphere(r=12);      // 3mm wall thickness
}

Parametric Gear

module gear(teeth=20, height=5) {
    linear_extrude(height=height) {
        for (i = [0:teeth-1]) {
            rotate([0, 0, i*360/teeth]) {
                translate([8, 0, 0]) circle(r=1);
            }
        }
        circle(r=7);
    }
}
gear(teeth=16, height=8);

Customizable Bracket

width = 30;
depth = 20; 
height = 15;
thickness = 3;

difference() {
    cube([width, depth, height]);
    translate([thickness, thickness, thickness])
        cube([width-2*thickness, depth-thickness, height]);
}

โš™๏ธ Configuration

Environment Variables

  • OPENSCAD_WORK_DIR: Working directory for files (default: server directory)

Logging

Logs are written to openscad_mcp.log with detailed operation information:

  • Script updates and validations

  • Rendering operations and timing

  • Export operations and file sizes

  • Error conditions and recovery

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

Available Tools

5 tools
create_openscad_scriptCreate Openscad ScriptC

Create or update the OpenSCAD script in the scratchpad

Inputs: script_content (required). Returns: result

export_model_to_stlExport Model To StlC

Export the current OpenSCAD script to STL file

Inputs: filename (required). Returns: result

save_openscad_scriptSave Openscad ScriptC

Save the current OpenSCAD script to a file

Inputs: filename (required). Returns: result

show_openscad_scriptShow Openscad ScriptA

Show the current OpenSCAD script from the scratchpad

Inputs: no named parameters. Returns: result

view_renderView RenderB

Render the current OpenSCAD script and return as base64 PNG

Inputs: view. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    B3.4/5.0

    Scored across 5 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: read the scratchpad, update it, render a PNG, export STL, and save to file. The main friction is between create_openscad_script (updates scratchpad) and save_openscad_script (writes to file), which could be confused since both 'persist' the script, but descriptions clarify the target.

    Naming Consistency4/5

    Three tools consistently use the verb_openscad_script pattern (show/create/save_openscad_script), which is predictable. view_render and export_model_to_stl deviate with different noun and suffix conventions, but remain readable and verb-first.

    Tool Count5/5

    Five tools is well-scoped for a scratchpad-based script editing and rendering workflow, with each tool earning its place (read, write, preview, export, persist). No bloat and no obviously redundant operations.

    Completeness4/5

    The surface covers the core lifecycle: read, create/update, render preview, export STL, and save to file. Minor gaps exist, such as clearing/deleting the scratchpad or listing/returning saved file locations, but agents can work around these.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers