forma-mcp
by wrong-nebula
README.md
# Forma
**A 1.2 MB pure-Rust rewrite of headless Blender built for AI agents — 3D B-rep modeling engine, CLI, and MCP server.**
<p align="center">
<img src="assets/readme_hero.png" alt="Forma — Pure-Rust Rewrite of Headless Blender for AI Agents" width="100%" />
</p>
Forma rewrites headless Blender's 3D modeling, boolean, and studio-preview workflow from scratch in pure Rust—replacing the 953 MB desktop stack and brittle `bpy` scripting with a compact declarative pipe language (`Forma-Pipe`), semantic edge/face selectors, guaranteed-manifold CSG booleans, transactional snapshots, and a built-in zero-GPU studio renderer.
| Metric | Stock Headless Blender 5.3 (`bpy`) | **Forma** | Improvement |
|---|---:|---:|---:|
| **Cold-Start Eval + GLB Export** | 1,306.8 ms | **16.9 ms** (`5.4 ms` batch flange) | **~77×–89× faster** |
| **Completion Tokens (12-model avg)** | 294,661 total | **84,551 total** | **3.49× fewer** (up to **15.5×**) |
| **Pass Rate (12 models / 10 labs)** | 79.1% (`bpy`) | **95.5% – 100%** | **+16.4 pp** |
| **Binary / Install Footprint** | 953 MB | **1.2 MB** | **~800× smaller** |
| **Peak Memory RSS** | 223 MB | **2.16 MB** | **103× less RAM** |
| **MCP Tool Schema Budget** | — | **789 `o200k` tokens** (4 tools) | Strictly `< 800` |
---
## Features
- **Declarative `Forma-Pipe` Language:** Chain primitives and ops cleanly (`box | bevel | shell | cut`) with semantic selectors (`vertical`, `top_rim`, `bottom_rim`, `outer_rim`, `top`, `sides`)—zero fragile integer vertex indices.
- **Fast, Watertight Pure-Rust Kernel:** Double-precision polyhedral B-rep, BVH-localized Möller-guarded booleans, automatic batch CSG for multi-hole patterns, zero-error Link-Condition coplanar mesh simplification, ring-preserving bevels, shell, crease-aware Catmull-Clark subsurf, `pipe`, `loft`, helical `thread`, `sweep`, `text3d`, and `pattern_linear`/`pattern_radial`.
- **Spatial Constraints & Queries:** Relational placement (`| on(base)`, `| align(axis, min|center|max, val)`), exact 3D `clearance(a, b)`, 2D `section(part, z)` loop/area queries, and Euler genus (`g`) diagnostics.
- **Zero-GPU Rendering & Blueprints:** Built-in 4-view (`Front / Right / Top / Iso`) studio PNG renderer with SSAO-lite + depth silhouettes + pure-Rust Deflate compression (`~20–75 KB` PNG in ~4 ms), plus dimensioned 1200×900 vector SVG technical blueprints (`forma draw`).
- **Universal Export:** Native `.glb` (PBR materials + automatic triplanar UVs), ISO 10303-21 `.step`, `.3mf`, `.stl`, `.obj`, `.svg`, `.png`, and `.blend` (via optional Blender bridge).
---
## Quickstart
### Option 1 — Zero-Install via npm (Cross-Platform WASM)
```bash
npx -y forma-3d eval --strict --out flange.glb --render flange.png --draw flange.svg <<'EOF'
flange = box(4, 2, 0.4)
| mat("brushed_steel", color=(0.55, 0.68, 0.85), metallic=0.9, roughness=0.25)
| cut(cyl(0.5, 1))
| cut(cyl(0.25, 1), at=[(-1.4,-0.5,0), (-1.4,0.5,0), (1.4,-0.5,0), (1.4,0.5,0)])
section(flange, 0.0)
EOF
```
### Option 2 — Build Native 1.2 MB Rust Binary
```bash
git clone https://github.com/wrong-nebula/forma.git
cd forma
cargo build --release
./target/release/forma eval --strict --out flange.glb --render flange.png --draw flange.svg script.forma
```
<p align="center">
<img src="assets/readme_quad_views.png" alt="Built-In Pure-Rust 4-View Studio Renders" width="100%" />
</p>
---
## For AI Agents
Forma is designed for drop-in agent use via **MCP**, **CLI**, **Agent Skills**, or **GBNF constrained decoding**:
- **LLM Agent Skill:** [`SKILL.md`](SKILL.md)
- **Machine-readable index:** [`llms.txt`](llms.txt)
- **Full agent integration guide:** [`AGENTS.md`](AGENTS.md)
- **Constrained-decoding grammar:** [`grammar/forma_pipe.gbnf`](grammar/forma_pipe.gbnf) (`forma spec --gbnf`)
### MCP Server Setup (`forma-mcp` / `npx forma-3d-mcp`)
Add Forma's MCP server (4 tools: `eval`, `inspect`, `tx`, `export` — **789 `o200k` tokens** total) to any MCP client:
```json
{
"mcpServers": {
"forma": {
"command": "npx",
"args": ["-y", "forma-3d-mcp"]
}
}
}
```
Or invoke directly from any shell-capable agent:
```bash
forma spec # ~355-token language reference
forma eval --strict --out out.glb script.forma # transactional eval + ~100-tok spatial diff
forma render --out preview.png script.forma # 4-view studio PNG (~4 ms, zero GPU)
forma draw --out blueprint.svg script.forma # dimensioned vector engineering blueprint
```
---
## Benchmarks
All models were evaluated head-to-head on stock headless **Blender 5.3.0 (`bpy`)** vs **Forma (`Forma-Pipe`)** across 6 cross-category exact-dimension tasks (`flange_plate`, `pipe_tee`, `beveled_enclosure`, `hex_nut`, `subdiv_mug`, `pedestal_bowl`), verified independently with `trimesh` + `scipy` (Chamfer distance, Hausdorff-99, Generalized Winding Number Volumetric IoU, watertight/0-non-manifold checks, and 16-layer planar sliceability).
<p align="center">
<img src="assets/readme_benchmarks.png" alt="12-Model Benchmark Results: Forma vs Stock Blender 5.3" width="100%" />
</p>
### 1. Cross-Lab Results — 12 Models Across 10 Labs (`low` reasoning)
| Model | `bpy` Pass (P@1 / P@3) | **Forma Pass (P@1 / P@3)** | `bpy` Tokens (API / Comp) | **Forma Tokens (API / Comp)** | `bpy` Mean IoU | **Forma Mean IoU** | Comp Token Reduction |
|---|---:|---:|---:|---:|---:|---:|---:|
| `anthropic/claude-opus-5.5` | 4/6 · 6/6 | **6/6 · 6/6** | 15,139 / 9,333 | **6,140 / 731** | 0.973 | **0.980** | **12.77×** |
| `anthropic/claude-haiku-5.5` | 4/6 · 5/6 | **3/6 · 6/6**\* | 36,296 / 25,815 | **18,159 / 8,474** | 0.807 | **0.978** | **3.05×** |
| `google/gemini-4-neon` | 4/6 · 6/6 | **5/6 · 6/6** | 28,447 / 20,867 | **12,938 / 7,388** | 0.970 | **0.974** | **2.82×** |
| `google/gemini-4-hydrogen` | 3/6 · 5/6 | **5/6 · 6/6** | 27,794 / 18,297 | **10,157 / 5,020** | 0.818 | **0.989** | **3.64×** |
| `openai/gpt-6.2-astra` | 4/6 · 6/6 | **4/6 · 6/6** | 9,914 / 5,787 | **6,798 / 950** | 0.970 | **0.978** | **6.09×** |
| `openai/gpt-6.2-sol` | 4/6 · 6/6 | **4/6 · 6/6** | 10,333 / 6,239 | **7,126 / 1,243** | 0.968 | **0.972** | **5.02×** |
| `qwen/qwen4-max` | 2/6 · 4/6 | **4/6 · 6/6** | 43,265 / 36,827 | **19,161 / 12,133** | 0.651 | **0.965** | **3.04×** |
| `z-ai/glm-5.4` | 5/6 · 6/6 | **3/6 · 6/6** | 9,380 / 6,151 | **11,632 / 2,696** | 0.960 | **0.985** | **2.28×** |
| `x-ai/grok-4.7` | 5/6 · 6/6 | **4/6 · 6/6** | 88,001 / 76,397 | **30,024 / 14,558** | 0.966 | **0.972** | **5.25×** |
| `deepseek/deepseek-v4.1-flash` | 1/6 · 1/6 | **3/6 · 4/6** | 61,812 / 56,599 | **37,825 / 29,120** | 0.167 | **0.661** | **1.94×** |
| `tencent/hy4-flash` (`none`) | 1/6 · 1/6 | **3/6 · 5/6** | 52,799 / 22,079 | **10,497 / 1,574** | 0.159 | **0.924** | **14.03×** |
| `mistralai/mistral-large-4-0`† | 0/1 · 1/1 | **1/1 · 1/1** | 12,666 / 10,270 | **1,331 / 664** | 1.000 | **1.000** | **15.47×** |
| **Aggregate (67 paired trials)** | **55.2% · 79.1%** | **67.2% · 95.5%** | **395,846 / 294,661** | **171,788 / 84,551** | **0.768** | **0.944** | **3.49×** |
*\*On subsequent v0.2+ ring-preserving bevel fixes, `claude-haiku-5.5` improved to **6/6 (100%) Pass@1** (10,920 API tokens) and all 4 re-tested models hit **24/24 (100%) Pass@2** (`0.980` Mean IoU).*
*†Completed 1 paired task (`flange_plate`: 1-shot Forma vs 3-turn `bpy`) before upstream provider returned HTTP 400.*
### 2. Reasoning-Effort Scaling (`claude-haiku-5.5`, `gpt-6.2-sol`, `gemini-4-hydrogen`, `qwen4-max`)
| Reasoning Level | Paired Tasks | `bpy` Pass@3 | **Forma Pass@3** | `bpy` API / Cost | **Forma API / Cost** | `bpy` IoU | **Forma IoU** | Cost Reduction |
|---|---:|---:|---:|---:|---:|---:|---:|---:|
| **`none`** | 12 | 83.3% | **91.7%** | 53,812 / \$0.100 | **22,453 / \$0.012** | 0.792 | **0.925** | **8.57×** |
| **`low`** | 24 | 83.3% | **100.0%** | 117,688 / \$0.402 | **54,603 / \$0.132** | 0.811 | **0.976** | **3.05×** |
| **`medium`** | 24 | 83.3% | **100.0%** | 178,275 / \$0.693 | **56,488 / \$0.202** | 0.834 | **0.975** | **3.44×** |
| **`high`** | 24 | 83.3% | **95.8%** | 269,423 / \$1.285 | **80,107 / \$0.326** | 0.864 | **0.941** | **3.95×** |
### 3. Full 12-Task Suite Summary (4 Model Families, 144 Trials)
| Metric | Stock Blender 5.3 (`bpy`) | **Forma (`Forma-Pipe`)** | Gain |
|---|---:|---:|---:|
| **Pass@1 / Pass@3** | 68.8% / 85.4% | **81.2% / 97.9%** | **+12.5 pp** |
| **Median Code Tokens (`o200k`)** | 644 | **115** | **5.60× shorter** |
| **Mean Volumetric IoU** | 0.8421 | **0.9814** | **+0.1393** |
| **All 12 Canonical Meshes (build + `.glb`)** | ~15,600 ms | **61.2 ms total (`5.1 ms/mesh`)** | **12/12 `WT=ok NM=0`** |
| **Fuzz & Determinism** | — | **11,000 ops in `2.46 s` (`0.22 ms/op`)** | **0 panics · 0 NaNs · byte-identical `.glb`** |
Full logs and methodology: [`docs/EXTENDED_BENCHMARK_REPORT.md`](docs/EXTENDED_BENCHMARK_REPORT.md) · [`docs/VERIFICATION_REPORT.md`](docs/VERIFICATION_REPORT.md).
---
## License
MIT License — see [`LICENSE`](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues