3D建模MCP服务

OpenSCAD MCP服务器是一个让AI助手(如Claude)通过OpenSCAD创建、编辑、渲染和导出3D模型的工具,适用于参数化建模与快速原型设计。

  • by sergiudanstan
  • Python
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 sergiudanstan/openscad-mcp

使用说明


title: OpenSCAD MCP emoji: "\U0001F4D0" colorFrom: blue colorTo: green sdk: docker app_port: 7860 pinned: false

OpenSCAD MCP Server

An MCP (Model Context Protocol) server that lets AI assistants like Claude create, edit, render, and export 3D models using OpenSCAD.

What It Does

Connect this server to Claude Desktop and you can ask Claude to:

  • Design parametric 3D models in OpenSCAD
  • Preview renders as PNG images
  • Export to STL, 3MF, AMF, DXF, SVG, and more
  • Animate models using OpenSCAD's $t variable
  • Check syntax before rendering
  • Browse an OpenSCAD language cheatsheet

Available Tools

Tool Description
openscad_create Create a new .scad file
openscad_read Read an existing .scad file
openscad_edit Update an existing .scad file
openscad_export Export to STL, 3MF, OFF, AMF, DXF, SVG, PDF
openscad_preview Render a PNG preview with camera/color options
openscad_render_animated Render animation frames using $t
openscad_get_info Get model render statistics
openscad_list_files List .scad files in the workspace
openscad_check_syntax Dry-run syntax validation
openscad_cheatsheet OpenSCAD language quick reference
openscad_version Get installed OpenSCAD version
openscad_list_examples List built-in example files

Quick Start

Prerequisites

Install

git clone https://github.com/sergiudanstan/openscad-mcp.git
cd openscad-mcp
python3 -m venv .venv
source .venv/bin/activate    # Windows: .venv\Scripts\activate
pip install -e .

Configure Claude Desktop

Add to your Claude Desktop config:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "openscad": {
      "command": "/full/path/to/openscad-mcp/.venv/bin/python",
      "args": ["-m", "openscad_mcp"]
    }
  }
}

On Windows, use ".venv\\Scripts\\python.exe" instead.

Restart Claude Desktop — the OpenSCAD tools will appear in the hammer icon.

Configure Claude Code

claude mcp add openscad -s user -- /full/path/to/openscad-mcp/.venv/bin/python -m openscad_mcp

Start a new Claude Code session and the openscad_* tools will be available.

Examples

The examples/ directory includes sample .scad files:

  • box.scad — Simple parametric box
  • gear.scad — Involute spur gear
  • vase.scad — Curved vase with twist

Project Structure

openscad-mcp/
├── src/openscad_mcp/
│   ├── server.py           # FastMCP server setup
│   ├── client.py           # OpenSCAD CLI wrapper
│   └── tools/
│       ├── design_tools.py   # create / read / edit
│       ├── render_tools.py   # preview / export / animate
│       └── library_tools.py  # list files / cheatsheet / syntax check
├── examples/               # Sample .scad files
├── tests/                  # Test suite
└── pyproject.toml

Security

  • No shell injection — uses subprocess_exec (argument list, not shell string)
  • Path traversal protection — all file operations are sandboxed to the workspace directory
  • No credentials or API keys — runs entirely locally

Workspace

All files are created in ~/openscad-mcp-workspace/ by default.

Running Tests

pip install -e ".[dev]"
pytest tests/

Full Installation Guide

See openscad-mcp-install-guide.pdf for detailed step-by-step instructions for macOS and Windows.