execute_blender_code
Run custom Python inside Blender to perform operations lacking dedicated tools, capture output, return structured JSON, and stop runaway code via a timeout.
Instructions
Execute arbitrary Python code inside Blender.
Pre-imported: bpy, bmesh, mathutils (Vector, Matrix, Euler, Quaternion),
math, np (numpy), C (bpy.context), D (bpy.data). Stdout/stderr are captured.
Assign a variable named result to get structured data back as JSON.
Runaway code is stopped after timeout seconds. 3D-viewport operators work
(the code runs with a viewport context). The whole run is one Ctrl+Z step.
Use this for any operation that doesn't have a dedicated tool. The user can turn it
off (add-on preference "Allow Python code"); then it returns an error and only the
structured tools work.
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": "execute_blender_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| timeout | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |