MCP (Model Context Protocol) server that bridges LLMs with OpenSCAD for parametric 3D CAD. Enables AI agents to generate, render, analyze, and export 3D models through a standardized protocol.
| Tool | Description |
|---|---|
render_openscad |
Render OpenSCAD code to PNG preview (Base64 multimodal response) |
export_stl |
Export OpenSCAD code to STL for 3D printing |
get_csg_tree |
Parse and return the CSG tree structure (JSON) |
get_model_metrics |
Extract bounding box, dimensions, and vertex count |
- Node.js >= 18
- OpenSCAD installed and available in PATH (or configured via
OPENSCAD_PATH)
# Ubuntu/Debian
sudo apt-get install openscad
# macOS
brew install openscad
# Or download from https://openscad.org/downloads.htmlnpm install
npm run buildAdd to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"openscad-vision-bridge": {
"command": "node",
"args": ["/absolute/path/to/dist/index.js"],
"env": {
"OPENSCAD_PATH": "/usr/bin/openscad"
}
}
}
}npm startnpm run dev # Run with tsx (no build needed)
npm test # Run tests
npm run build # Compile TypeScript| Variable | Default | Description |
|---|---|---|
OPENSCAD_PATH |
openscad |
Path to the OpenSCAD binary |
OPENSCAD_TIMEOUT |
30000 |
Execution timeout in milliseconds |
OPENSCAD_MAX_FILE_SIZE |
52428800 |
Max output file size in bytes (50MB) |
src/
├── index.ts # Entry point, stdio transport
├── server.ts # MCP server setup & tool registration
├── services/
│ ├── openscad-executor.ts # OpenSCAD binary execution with timeout
│ └── temp-file-manager.ts # Ephemeral file lifecycle management
├── tools/
│ ├── render-openscad.ts # PNG rendering tool
│ ├── export-stl.ts # STL export tool
│ ├── get-csg-tree.ts # CSG tree analysis tool
│ └── get-model-metrics.ts # Dimensional metrics extraction tool
└── types/
└── schemas.ts # Zod validation schemas
- Execution timeouts: All OpenSCAD processes are killed after configurable timeout
- File size limits: Output files are capped to prevent disk exhaustion
- Input validation: All tool inputs validated via Zod schemas
- Isolation: Each session uses a unique temporary directory, cleaned up on shutdown
- No arbitrary code: Only OpenSCAD code is executed, no shell commands
MIT