OpenSCAD
STDIO为AI助手提供OpenSCAD 3D渲染的MCP服务器
为AI助手提供OpenSCAD 3D渲染的MCP服务器
A production-ready Model Context Protocol (MCP) server that provides OpenSCAD 3D rendering capabilities to AI assistants and LLM applications. Built with FastMCP for robust, scalable performance.
Run directly from GitHub without any setup:
uv run --with git+https://github.com/quellant/openscad-mcp.git openscad-mcp
Perfect for MCP clients, CI/CD pipelines, and instant deployment scenarios!
uvNo installation required! Run directly from GitHub:
# Run via script entry point (recommended) uv run --with git+https://github.com/quellant/openscad-mcp.git openscad-mcp # Or run as Python module uv run --with git+https://github.com/quellant/openscad-mcp.git python -m openscad_mcp
# Clone and run locally git clone https://github.com/quellant/openscad-mcp.git cd openscad-mcp uv run openscad-mcp
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{ "mcpServers": { "openscad": { "command": "uv", "args": ["run", "--with", "git+https://github.com/quellant/openscad-mcp.git", "openscad-mcp"], "env": { "OPENSCAD_PATH": "/usr/bin/openscad" } } } }
{ "mcpServers": { "openscad": { "command": "uv", "args": ["run", "openscad-mcp"], "cwd": "/path/to/openscad-mcp", "env": { "OPENSCAD_PATH": "/usr/bin/openscad" } } } }
IMPORTANT: When using the OpenSCAD MCP server with Claude CLI or other MCP clients, you MUST explicitly grant permissions using the --allowedTools flag for security. This prevents unauthorized tool usage and ensures controlled access to server capabilities.
The OpenSCAD MCP server requires explicit permission for each tool:
openscad-mcp:check_openscad - Permission to check OpenSCAD installationopenscad-mcp:render_single - Permission to render single viewsopenscad-mcp:render_perspectives - Permission to render multiple perspectives# Start the server with uv and grant permissions # (Create mcp-config.json with uv configuration first) # Grant permission for a single tool claude --config mcp-config.json \ --allowedTools openscad-mcp:check_openscad \ "Check if OpenSCAD is installed" # Grant permission for multiple tools claude --config mcp-config.json \ --allowedTools openscad-mcp:check_openscad,openscad-mcp:render_single \ "Render a cube with dimensions 30x30x30" # Grant full permissions for all OpenSCAD tools claude --config mcp-config.json \ --allowedTools openscad-mcp:check_openscad,openscad-mcp:render_single,openscad-mcp:render_perspectives \ "Create a gear model and show it from multiple angles"
Create mcp-config.json for Claude CLI:
{ "mcpServers": { "openscad-mcp": { "command": "uv", "args": ["run", "--with", "git+https://github.com/quellant/openscad-mcp.git", "openscad-mcp"], "env": { "OPENSCAD_PATH": "/usr/bin/openscad" } } } }
Use the provided test script to verify proper permission configuration:
# Run all permission tests ./test_claude_with_permissions.sh all # Test individual tools ./test_claude_with_permissions.sh check # Test check_openscad only ./test_claude_with_permissions.sh single # Test render_single only ./test_claude_with_permissions.sh perspectives # Test render_perspectives only # Launch interactive session with full permissions ./test_claude_with_permissions.sh interactive # Show usage examples ./test_claude_with_permissions.sh examples
No additional Python packages required when using uv - all dependencies are handled automatically!
uv (Recommended)No installation required! Just run directly:
# Run directly from GitHub - uv handles everything automatically uv run --with git+https://github.com/quellant/openscad-mcp.git openscad-mcp # All dependencies (FastMCP 2.11.3, Pydantic 2.11.7, etc.) are resolved and installed automatically
uv# Clone for local development git clone https://github.com/quellant/openscad-mcp.git cd openscad-mcp # Run with uv (installs dependencies automatically) uv run openscad-mcp # Or run as module uv run python -m openscad_mcp
# Only if you can't use uv git clone https://github.com/quellant/openscad-mcp.git cd openscad-mcp pip install -e . python -m openscad_mcp
Create a .env file in the project root:
# OpenSCAD Configuration OPENSCAD_PATH=/usr/bin/openscad # Path to OpenSCAD executable OPENSCAD_TIMEOUT=30 # Timeout for rendering operations (seconds) # Server Configuration MCP_SERVER_NAME=openscad-mcp MCP_SERVER_VERSION=1.0.0 MCP_SERVER_TRANSPORT=stdio # Transport: stdio, sse, or http # Rendering Configuration MCP_RENDER_MAX_CONCURRENT=4 # Max concurrent renders MCP_RENDER_DEFAULT_WIDTH=800 # Default image width MCP_RENDER_DEFAULT_HEIGHT=600 # Default image height
Create config.yaml for advanced configuration:
server: name: "OpenSCAD MCP Server" version: "1.0.0" transport: stdio openscad: timeout: 30 default_color_scheme: "Cornfield" rendering: max_concurrent: 4 default_width: 800 default_height: 600
render_singleRender a single view of an OpenSCAD model with complete camera control.
Parameters:
| Parameter | Type | Required | Description | 
|---|---|---|---|
scad_content | string | No* | OpenSCAD code to render | 
scad_file | string | No* | Path to .scad file | 
camera_position | [x,y,z] | No | Camera position (default: [30,30,30]) | 
camera_target | [x,y,z] | No | Look-at point (default: [0,0,0]) | 
camera_up | [x,y,z] | No | Up vector (default: [0,0,1]) | 
image_size | [w,h] | No | Image dimensions in pixels | 
color_scheme | string | No | OpenSCAD color scheme | 
variables | dict | No | Variables to pass to OpenSCAD | 
auto_center | bool | No | Auto-center the model | 
*Either scad_content or scad_file must be provided
Example Request:
{ "tool": "render_single", "arguments": { "scad_content": "cube([10, 10, 10]);", "camera_position": [30, 30, 30], "image_size": [800, 600], "color_scheme": "Cornfield" } }
Example Response:
{ "success": true, "image": "data:image/png;base64,iVBORw0KGgo...", "metadata": { "width": 800, "height": 600, "render_time": 1.23 } }
render_perspectivesGenerate multiple standard views of a model (front, back, left, right, top, bottom, isometric).
Parameters:
| Parameter | Type | Required | Description | 
|---|---|---|---|
scad_content | string | No* | OpenSCAD code to render | 
scad_file | string | No* | Path to .scad file | 
distance | float | No | Camera distance from origin | 
image_size | [w,h] | No | Image dimensions for each view | 
variables | dict | No | Variables to pass to OpenSCAD | 
views | list | No | Specific views to render | 
Example Request:
{ "tool": "render_perspectives", "arguments": { "scad_file": "model.scad", "views": ["front", "isometric", "top"], "distance": 200, "image_size": [400, 400] } }
check_openscadVerify OpenSCAD installation and get version information.
Parameters:
| Parameter | Type | Required | Description | 
|---|---|---|---|
include_paths | bool | No | Include searched paths in response | 
Example Request:
{ "tool": "check_openscad", "arguments": { "include_paths": true } }
resource://server/infoGet server configuration and capabilities.
Returns:
The server implements a clean architecture pattern:
┌─────────────────────────────────────┐
│         MCP Client (Claude)         │
└─────────────────────────────────────┘
                    │
                    ▼
┌─────────────────────────────────────┐
│    FastMCP Server (Presentation)    │
│        - MCP Protocol Handler       │
│        - Tool Decorators            │
└─────────────────────────────────────┘
                    │
                    ▼
┌─────────────────────────────────────┐
│     Application Layer (Business)    │
│        - Rendering Logic            │
│        - Parameter Validation       │
└─────────────────────────────────────┘
                    │
                    ▼
┌─────────────────────────────────────┐
│   Infrastructure Layer (External)   │
│        - OpenSCAD CLI               │
│        - File I/O Operations        │
└─────────────────────────────────────┘
The server has achieved 100% test success rate across all integration tests:
# Run comprehensive test suite python comprehensive_test.py # Run MCP tools integration test python test_mcp_tools.py # Run server startup test python test_server_startup.py
See Test Report for detailed results.
openscad-mcp-server/
├── src/
│   └── openscad_mcp/
│       ├── __init__.py         # Package initialization
│       ├── __main__.py          # Entry point
│       ├── server.py            # FastMCP server implementation
│       ├── types.py             # Pydantic models & types
│       └── utils/
│           └── config.py        # Configuration management
├── tests/                       # Test suite
├── pyproject.toml              # Project configuration
├── README.md                   # This file
├── CHANGELOG.md               # Version history
├── API.md                     # Detailed API documentation
└── .env.example               # Environment template
To add new rendering capabilities:
types.py:class CustomRenderParams(BaseModel): # Your parameters here pass
server.py:@mcp.tool async def custom_render(params: CustomRenderParams) -> RenderResult: """Your custom rendering logic""" # Implementation pass
API.md# Check OpenSCAD installation which openscad # Set environment variable export OPENSCAD_PATH=/path/to/openscad # Or add to .env file OPENSCAD_PATH=/usr/local/bin/openscad
# Ensure execute permissions chmod +x /path/to/openscad
Increase timeout in configuration:
export OPENSCAD_TIMEOUT=60 # 60 seconds
Ensure correct versions:
pip install fastmcp==2.11.3 pydantic==2.11.7
✅ Ready for Production
MIT License - See LICENSE file for details
Contributions are welcome! Please:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)Version: 1.0.0 | Status: Production Ready | Last Updated: 2025-08-25