blender_exec
Run Python code inside an open Blender instance to inspect or modify the scene, returning the result as JSON.
Instructions
Execute Python inside the running Blender (bpy), like ae_exec / cocosmcp_exec.
The snippet runs on Blender's main thread with a VIEW_3D temp_override when one exists.
bpy and mathutils are already in scope. The value of the last expression is returned as JSON
(Vector/Euler/Color/Matrix become lists; bpy data-blocks become {type, name}).
Assign result if the last line is not an expression. A top-level return is also accepted.
Prefer the data API over bpy.ops. Do not return raw bpy objects.
Successful calls push an undo step unless undo is false.
Example: bpy.context.scene.name
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "blender_exec"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python snippet. Last expression is the result. | |
| undo | No | Push an undo step before running. Defaults to true. |