Skip to content

Commit f7c8d16

Browse files
committed
feat: add 3D printing tools, sculpting tools, and mushroom keychain showcase
Adds mesh validation/repair/export tools for 3D printing (check_mesh_for_printing, repair_mesh, apply_voxel_remesh, export_model, set_scene_units, etc.) and a new sculpting tool module (enter/exit_sculpt_mode, sculpt_inflate, sculpt_grab, symmetrize_mesh, set_dyntopo). Includes a community showcase (Sculpted Mushroom Keychain) built end-to-end with an n8n agent
1 parent 57e9963 commit f7c8d16

57 files changed

Lines changed: 4135 additions & 335 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MCP_BRIDGE_HOST=0.0.0.0
2+
MCP_BRIDGE_PORT=8008
3+
BLENDER_ADDON_HOST=127.0.0.1
4+
BLENDER_ADDON_PORT=8888
5+
6+
# Optional: Directory for resolving relative texture, HDRI, or 3D Printing export paths.
7+
# BLENDER_ASSETS_DIR=/path/to/your/assets

.github/workflows/audit.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Dependency Audit
2+
3+
on:
4+
# Run weekly every Monday at 08:00 UTC
5+
schedule:
6+
- cron: "0 8 * * 1"
7+
# Also allow manual trigger from the Actions tab
8+
workflow_dispatch:
9+
10+
jobs:
11+
audit:
12+
name: "pip-audit (CVE scan)"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: "Set up uv"
18+
uses: astral-sh/setup-uv@v4
19+
with:
20+
version: "latest"
21+
enable-cache: true
22+
23+
- name: "Export requirements for audit"
24+
# pip-audit works best against a flat requirements list
25+
run: uv export --no-dev --format requirements-txt > /tmp/requirements.txt
26+
27+
- name: "Run pip-audit"
28+
run: uvx pip-audit -r /tmp/requirements.txt

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
pull_request:
7+
branches: ["main", "master"]
8+
9+
# Cancel in-progress runs for the same branch (saves CI minutes on rapid pushes)
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
# ── 1. Lint & Format ────────────────────────────────────────────────────────
16+
lint:
17+
name: "Lint & Format (ruff)"
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: "Lint — ruff check"
23+
# uvx runs a tool without installing into project venv
24+
run: uvx ruff check src/ tests/ blender_mcp_addon/
25+
26+
- name: "Format — ruff format --check"
27+
run: uvx ruff format --check src/ tests/ blender_mcp_addon/
28+
29+
# ── 2. Complexity (McCabe via ruff C90) ─────────────────────────────────────
30+
complexity:
31+
name: "Complexity Check (McCabe ≤ 12)"
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: "McCabe complexity — ruff C90"
37+
# Flags any function/method with cyclomatic complexity > 12
38+
# Config lives in pyproject.toml [tool.ruff.lint.mccabe]
39+
run: uvx ruff check --select C90 src/ tests/ blender_mcp_addon/
40+
41+
# ── 3. Type Check (mypy — src/ only) ────────────────────────────────────────
42+
# blender_mcp_addon/ is excluded because `bpy` (Blender Python API)
43+
# has no public type stubs and cannot be installed outside Blender.
44+
type-check:
45+
name: "Type Check (mypy — src/)"
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: "Set up uv"
51+
uses: astral-sh/setup-uv@v4
52+
with:
53+
version: "latest"
54+
enable-cache: true
55+
56+
- name: "Install project + dev deps"
57+
run: uv sync --group dev
58+
59+
- name: "mypy — src/"
60+
run: uv run mypy src/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ tmp/
3636
!tests/benchmarks/arch_expected.json
3737
!tests/benchmarks/grid_expected.json
3838
!community/**/*.json
39+
40+
# Ignorte all log files
41+
*.log

README.md

Lines changed: 79 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@ graph LR
2020

2121
### 1. Install Dependencies
2222

23+
We recommend using [`uv`](https://docs.astral.sh/uv/) for fast virtual environment management and package installation:
24+
2325
```bash
24-
pip install -r requirements.txt
26+
# 1. Sync dependencies (automatically creates .venv if missing)
27+
uv sync
28+
29+
# 2. Activate it
30+
# Windows:
31+
.venv\Scripts\activate
32+
# macOS/Linux:
33+
source .venv/bin/activate
2534
```
2635

2736
## Configuration
@@ -41,9 +50,9 @@ Create a `.env` file in the root directory to customize your setup:
4150
### Method 1: Zip & Install (Recommended)
4251
1. Zip the `blender_mcp_addon` folder (into `blender_mcp_addon.zip`).
4352
2. Open Blender.
44-
3. Go to **Edit** > **Preferences** > **Add-ons**.
45-
4. Click **Install...** and select the `.zip` file.
46-
5. Search for "Blender MCP" and enable the checkbox.
53+
3. **For Blender 4.2+**: Go to **Edit** > **Preferences** > **Get Extensions** > Click the dropdown arrow in the top right > **Install from Disk...** and select the `.zip`.
54+
**For Blender 4.0 / 4.1**: Go to **Edit** > **Preferences** > **Add-ons** > **Install...** and select the `.zip`.
55+
4. Search for "Blender MCP" and enable the checkbox.
4756

4857
### Method 2: Manual Copy (Developer)
4958
1. Copy the `blender_mcp_addon` folder to your Blender addons directory:
@@ -67,10 +76,10 @@ As the addon grows, a single 1800+ line file becomes unmaintainable. We've split
6776

6877
```bash
6978
# Standard mode
70-
python -m src.main serve
79+
uv run python -m src.main serve
7180

7281
# Recording mode (Save all commands to a file)
73-
python -m src.main serve --record my_session.json --name "Building My House"
82+
uv run python -m src.main serve --record my_session.json --name "Building My House"
7483
```
7584

7685
The server will start on `http://localhost:8008` with HTTP Streamable endpoint at `/mcp`. It uses detailed logging to show exactly which tools are being called and their results.
@@ -82,7 +91,7 @@ The **Bridge Sessions** feature allows you to record yours or an AI's tool calls
8291
### Recording a Session
8392
To record all tool calls made to the bridge while the server is running:
8493
```bash
85-
python -m src.main serve --record path/to/session.json --name "My Project" --description "Optional description"
94+
uv run python -m src.main serve --record path/to/session.json --name "My Project" --description "Optional description"
8695
```
8796
Any tool calls made by n8n or other clients will be automatically saved to the JSON file.
8897

@@ -91,10 +100,10 @@ Any tool calls made by n8n or other clients will be automatically saved to the J
91100
To playback a previously recorded session:
92101
```bash
93102
# Default (Stateful - HTTP Streamable) - Recommended for speed
94-
python -m src.main play path/to/session.json
103+
uv run python -m src.main play path/to/session.json
95104

96105
# Stateless mode (Standard HTTP) - Slower due to handshake overhead
97-
python -m src.main play path/to/session.json --transport stateless
106+
uv run python -m src.main play path/to/session.json --transport stateless
98107
```
99108

100109
> [!TIP]
@@ -132,7 +141,7 @@ If you modify the addon code or the MCP server logic, follow these steps to ensu
132141

133142
1. **Reload Scripts**: In Blender, press `F3` and type **"Reload Scripts"** (or use the shortcut `Alt + R` if configured).
134143
2. **Restart Blender Server**: In the N-Panel, click **Stop MCP Server** and then **Start MCP Server** again.
135-
3. **Restart Python Server**: Stop and restart the server with `python -m src.main serve`.
144+
3. **Restart Python Server**: Stop and restart the server with `uv run python -m src.main serve`.
136145

137146
> [!IMPORTANT]
138147
> All Blender operations now run on the main thread via a command queue, ensuring stability and preventing dependency graph errors.
@@ -212,6 +221,28 @@ The server exposes **70+ Blender tools** across several categories:
212221
| `add_tray_support` | Move existing supports or add new ones (TRAPEZE, CANTILEVER, WALL) to tray runs. |
213222
| `add_auto_cable_drops` | Automatically generate smooth Bezier cable drops from trays to racks/equipment beneath. |
214223

224+
### 3D Printing (Validation & Repair)
225+
| Tool | Explanation |
226+
|---|---|
227+
| `set_scene_units` | Set scene units and scale (e.g., metric millimeters) crucial for 3D slicers. |
228+
| `check_mesh_for_printing` | Analyze mesh topology for non-manifold edges, holes, and degenerate geometry. |
229+
| `repair_mesh` | Automated, non-destructive mesh repair (merge vertices, fill holes, recalculate normals). |
230+
| `apply_voxel_remesh` | Fuse overlapping parts into a single manifold volume using voxel remeshing. |
231+
| `apply_sculpt_smooth` | Smooth mesh geometry with sculpt-mode brush for organic cleanup. |
232+
| `apply_transforms` | Bake location/rotation/scale transforms into mesh data (required before boolean ops). |
233+
| `apply_all_modifiers` | Apply all pending modifiers on an object and convert to clean mesh. |
234+
| `convert_to_mesh` | Convert FONT/Curve objects (e.g. text) to editable mesh geometry. |
235+
| `export_model` | Export objects or selections to standard 3D print formats (STL or 3MF). |
236+
237+
### Sculpting
238+
| Tool | Explanation |
239+
|---|---|
240+
| `enter_sculpt_mode` / `exit_sculpt_mode` | Switch an object into/out of Sculpt Mode. |
241+
| `set_dyntopo` | Enable/configure Dynamic Topology for adaptive detail while sculpting. |
242+
| `sculpt_inflate` | Inflate/deflate a mesh along vertex normals; optional world-space Z mask to protect a flat base. |
243+
| `sculpt_grab` | Simulate the Grab brush — pull vertices near a world-space point by an offset, with cosine falloff. |
244+
| `symmetrize_mesh` | Mirror one half of a mesh onto the other across an axis, in Sculpt Mode. |
245+
215246
### Materials
216247
| Tool | Explanation |
217248
|---|---|
@@ -390,17 +421,52 @@ We use an integrated test suite to verify Blender tools and layout scenarios.
390421

391422
```bash
392423
# Run the Arch layout test
393-
python tests/run_integration.py run --scenario arch
424+
uv run python tests/run_integration.py run --scenario arch
394425

395426
# Run the standard functional grid test
396-
python tests/run_integration.py run --scenario grid
427+
uv run python tests/run_integration.py run --scenario grid
428+
429+
# Run the 3D Printing tool verification test
430+
uv run python tests/run_integration.py run --scenario print
431+
432+
# Run the Filament Name Tag & Stand generation test
433+
uv run python tests/run_integration.py run --scenario filament_tag
397434
```
398435

436+
### Scenarios
437+
438+
| Scenario | Key | Description |
439+
|---|---|---|
440+
| Grid Layout | `grid` | Functional grid test covering all tool categories |
441+
| Arch Layout | `arch` | Architectural scene generation test |
442+
| Print Validation | `print` | 3D printing workflow: units, mesh repair, export |
443+
| Filament Tag | `filament_tag` | Generates a 4-piece modular filament name tag & clip system (NameTagCard, AMSClip, StickonHolder, DeskStand) |
444+
399445
See the [Integration Testing Guide](docs/integration_tests.md) for full details on verification and benchmarking.
400446

447+
## Code Quality & Standards
448+
449+
We enforce code quality standards using [Ruff](https://docs.astral.sh/ruff/) and [Mypy](https://mypy.readthedocs.io/). These are run automatically on GitHub Actions CI.
450+
451+
To run these checks locally:
452+
453+
```bash
454+
# 1. Format code (strict black-compatible formatting)
455+
uv run ruff format src/ tests/ blender_mcp_addon/
456+
457+
# 2. Run linter and check code complexity (McCabe <= 12)
458+
uv run ruff check src/ tests/ blender_mcp_addon/
459+
460+
# 3. Auto-fix standard lint issues
461+
uv run ruff check src/ tests/ blender_mcp_addon/ --fix
462+
463+
# 4. Run static type checking
464+
uv run mypy src/
465+
```
466+
401467
## Troubleshooting
402468

403-
**Server won't start**: Install dependencies with `pip install -r requirements.txt`
469+
**Server won't start**: Install dependencies with `uv sync`
404470

405471
**Connection failed**: Ensure Blender MCP addon is running on port 8888.
406472

blender_mcp_addon/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import bpy
2+
23
from .server import BlenderMCPServer
34

45
bl_info = {

0 commit comments

Comments
 (0)