Blender Agent MCP
# Blender Agent MCP
A modular Blender control server with structured operations, visual feedback and
progressive `learn://` discovery. Python is the implementation language; agents
normally send compact arguments rather than generating scripts.
**Project rule:** no scene-specific names, collection roles, dimensions, layouts,
printer tolerances or credentials are embedded in the implementation. Discover the
current scene and accept those choices as data. See [AGENTS.md](AGENTS.md).
## Run it
Requirements: Blender 4.3+ and Python 3.11+; `uv` is used for development.
The integration suite has been exercised against Blender 4.3.2 and 5.2.0 LTS.
From this repository:
```powershell
uv sync
uv run python scripts/package.py
```
1. In Blender, open Preferences > Add-ons > Install from Disk and choose the ZIP
produced under `dist/`. Enable **Blender Agent**.
2. Open your scene. In the 3D View sidebar, open **Agent** and click **Connect Agent**.
3. Merge the generated `dist/mcp-config.json` server entry into your MCP client's
configuration. For clients using TOML, the equivalent entry is in
`dist/mcp-config.toml`. These generated files use this checkout's Python environment.
They do not overwrite existing client configuration.
4. Start/reload that MCP server. Read `learn://start`, then the relevant domain resource.
The generic launch command is `uv run blender-agent-mcp` from the repository.
For production distribution, a Python wheel can be installed instead of using `uv`.
The add-on has no third-party Python dependencies and does not install packages into Blender.
## Discovery and control
Only three tools are visible initially:
- `blender_learn`: reads a guide and enables its domain's tools.
- `blender_call`: structured dispatch for hosts that do not refresh tool lists.
- `blender_job`: inspect or cancel queued work.
The guides are real MCP resources (`resources/list` and `resources/read`), not
instructions repeated in every tool description. Reading one issues
`notifications/tools/list_changed`. Domain execution is gated until its guide is read.
`blender_learn(..., replace=true)` unloads other domains to keep context small.
Domain manifests register tools independently; the catalog and resource index are
built from these modules. Tool input contracts are JSON Schema, validated by the MCP
server. Blender changes run on Blender's main thread through a local authenticated
job queue. A timeout returns a job id rather than rerunning an operation.
| Domain | Implemented capabilities |
|---|---|
| Scene | Complete paginated hierarchy, inspect/create/duplicate/rename/transform objects, physical translation/resize, collection creation/assignment/reparenting |
| Modifiers | Discover installed types, inspect live RNA schemas, add/update/remove/reorder/apply, discover and edit Geometry Nodes inputs |
| Mesh | Revision-checked vertices and disconnected source islands, physical island filters, selected-island removal, non-destructive simplification |
| Project | Multi-angle/custom-direction shape images with material/object colors, asset import, checkpoint copies, connected-runtime tool reload |
| Assembly | Semantic groups, evaluated measurements, dominant planes, cross-sections and circular feature fits, topology defect locations, pairwise clearance/contact/containment, sampled wall thickness |
| Solid | Editable extrusions of rounded rectangles, circles and explicit polygons; evaluated binary STL export in physical millimeters |
| Animation | Independent evaluated presentation scenes, numeric/boolean keyframes with isolated actions, timeline markers, aimed cameras and bounded PNG frame rendering |
| Batch | Prevalidated structured operation lists, one undo boundary, explicit partial-completion reports |
| Operators | Search and describe all installed `bpy.ops` operators, execute structured properties with selection/mode/editor context |
| Data | Discover datablock stores, inspect nested RNA schemas and collection members, update settings and node/socket values through explicit RNA paths |
| Generation | Discover provider adapters; persistent image/model generation submissions, status, downloads and GLB import; Meshy adapter included |
| Python | Explicit opt-in fallback with a recorded reason; disabled by default |
## Enclosure workflow
Inspect the file-wide hierarchy and multiple views first. The orchestrating agent
supplies semantic groups using discovered collection/object names; the server does
not guess them. Confirm physical scale using known dimensions. Read the assembly
guide, choose the objects that represent actual material, and supply the intended
clearance in millimeters. Boolean operands are construction geometry unless the
user says otherwise; inspection reports their dependencies instead of treating them
as automatic collisions.
Fit checks use the evaluated surface after viewport-enabled modifiers. A part in a
Boolean cavity is different from a part inside solid material. Distance computation
reports lower/upper bounds if its work budget is exhausted. No inconclusive outcome
is silently promoted to a pass.
For a change, save a checkpoint, edit the driving modifier/parameter/geometry, and
remeasure. Physical fit additionally depends on accurate component models,
manufacturing tolerance, assembly motion and unmodeled details.
Use `mesh_planes` and `mesh_section` to recover geometry such as board planes and
mounting-hole candidates. `solid_create` and editable Boolean modifiers build
supports and openings from explicit dimensions. `mesh_diagnostics` locates defective
evaluated triangles before export. All these operations are generic; project plans,
role maps, printer assumptions and manufacturing dimensions remain caller data.
For assembly presentations, read `learn://animation`. Snapshot evaluated parts into
a separate scene before animating; their live Boolean dependencies remain in the CAD
scene. Keyframe tracks use discovered RNA fields and support legacy and slotted actions.
Scene cleanup can inspect dependency closures and dry-run explicit removals before
deleting unused drafts. Animation illustrates sequencing, not certified insertion paths.
`scripts/mcp_request.py manifest.json --output new-journal.json` is a generic real
MCP stdio client for repeatable project plans. A manifest supplies `learn` domains
and structured `operations`. It records request IDs before submitting, polls pending
jobs and stops on errors or partial batches. Never blindly rerun an uncertain mutation;
inspect the journal and job first. Output journals must be new files.
After installing changed add-on source, `project_reload_tools` reloads handlers while
preserving the connection and job ledger. The first installation still requires
enabling the add-on and connecting it in Blender. Batch operations cannot reload or
disconnect the runtime; perform lifecycle changes separately.
## Generation providers
The included Meshy adapter supports text-to-image, text-to-model, image-to-model and
texture refinement using the provider's documented API. Set `MESHY_API_KEY` in the
MCP process environment when you want to use it. No provider is needed for Blender
inspection or edits. Requests can spend provider credits; none were sent during testing.
Request ids are persisted locally to prevent accidental duplicate paid submissions.
A lost response is recorded as uncertain and never blindly retried. Additional adapters
can be registered with `BLENDER_AGENT_PROVIDERS`; see [EXTENDING.md](EXTENDING.md).
## Configuration
| Setting | Purpose |
|---|---|
| `BLENDER_AGENT_CONFIG` | Optional connection-file location, set consistently for Blender and the MCP process |
| `BLENDER_AGENT_MODULES` | Comma-separated extra tool manifest modules available on Python's import path |
| `BLENDER_AGENT_PROVIDERS` | Comma-separated extra generation provider modules |
| `BLENDER_AGENT_ALLOW_PYTHON=1` | Enables the explicit fallback when set in both processes |
| `MESHY_API_KEY` | Optional Meshy credential, only in the external MCP process |
Default connection file: `~/.blender-agent/connection.json`. It contains a local
bearer token; do not commit it. The bridge binds to `127.0.0.1:9878`. The port can be
changed through `blender_agent.start(port=...)` for a custom launcher. One active
connection file selects one Blender session; use distinct config paths for multiple sessions.
## Verification
```powershell
uv run pytest -q
uv run ruff check .
uv run ruff format --check .
```
For the actual Blender end-to-end test:
```powershell
$env:BLENDER_BIN = 'path\to\blender.exe'
uv run pytest -q
& $env:BLENDER_BIN --background --factory-startup --python-exit-code 1 --python tests/blender_checks.py
& $env:BLENDER_BIN --background --factory-startup --python-exit-code 1 --python tests/solid_checks.py
& $env:BLENDER_BIN --background --factory-startup --python-exit-code 1 --python tests/animation_checks.py
```
Tests use isolated processes and synthetic geometry. Reports are written under
`artifacts/`. The real-Blender MCP test is explicitly skipped if `BLENDER_BIN` is
unset. Provider tests use fakes; they do not use real credentials or spend credits.
## Current boundaries
- Direct vertex edits require Object Mode, local single-user meshes and no shape keys.
Context-aware operators cover other workflows when Blender supports them.
- Shape previews are solid Workbench images of evaluated mesh-convertible objects;
they are not final lighting/material renders, volume previews or live UI video.
- Some operators require a visible editor or interactive events. The structured
operator interface cannot guarantee every modal UI workflow.
- The pairwise fit checker does not certify self-intersection-free solids, assembly
insertion paths, every instance type, screw engagement or the behavior of a printer.
Wall thickness is sampled, not a proven global minimum.
- RNA collection creation/removal still needs a domain tool or an operator.
- Names are current-session references. Reinspect after renaming, external edits or
reopening a file. Mesh edits additionally require an exact geometry revision token.
- Undo checkpoints work in interactive Blender. They are not cross-operation atomic
transactions. Importers/operators can partially change state before failing.
- Blender jobs are retained for one connection session, up to 2,000 requests.
Disconnect/reconnect resets that ledger. Running jobs cannot be safely cancelled.
- Preview files are retained in the OS temp directory so the MCP process can read
them. Generated provider assets are retained alongside the local connection data.
## Layout
`addon/blender_agent/modules/` contains declarative domain manifests; handlers live
beside them. `src/blender_agent_mcp/` contains discovery, the external bridge client
and provider adapters. `learn/` contains concise agent guides. See
[SOURCES.md](SOURCES.md) for architectural references and license provenance.
TDQS
Scored across 3 tools
The three tools mostly have distinct roles: learning/activation, fallback invocation, and job inspection/cancellation. However, blender_learn and blender_call both relate to learned operations and could be confused by an agent unsure whether it needs to activate tools or invoke an operation directly.
All names share a clear blender_ prefix and are concise and readable. The pattern is not a strict verb_noun convention because blender_job is a noun while the other two are verbs, but the deviation is minor.
Three tools is a minimal but reasonable surface for a meta-orchestration server that dynamically activates domain-specific tools. Each tool has a role, though the small count makes the interface feel slightly thin without the activated tools visible.
The set covers learning, fallback invocation, and basic job inspection/cancellation, but there are notable gaps such as listing jobs, checking progress/results explicitly, or discovering active domains without relying on resources. The dynamic activation model likely fills these gaps, but the visible tool surface alone leaves possible dead ends.