Skip to main content
Glama

Run Blender headless with a Python script

blender_run_python
Destructive

Run Python in headless Blender to build or edit scenes, set materials, cameras, and lights, render stills or animations, and export GLB/FBX/USD. Persist results in a .blend file.

Instructions

Run Blender in background mode (no window ever appears) and execute Python with the full bpy API: build or edit scenes, model, animate, set up materials, cameras and lights, render stills or frame sequences (bpy.ops.render.render(write_still=True) / animation=True), and export .glb/.fbx/.usd. Optionally open a .blend first; save with bpy.ops.wm.save_as_mainfile(filepath=...). Each call is a fresh Blender process: persist work in a .blend file. print() output is returned. Runs arbitrary Python as the user: only write files inside the job folder.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "blender_run_python"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoWorking directory for relative paths, usually the job folder
argsNoExtra arguments, readable in Python via sys.argv after '--'
codeNoPython source to run (uses bpy). Give this or scriptPath.
engineNoOverride the render engine for this rundefault
blendFileNoA .blend file to open first
scriptPathNoPath to a .py file to run instead of code
factoryStartupNoIgnore the user's Blender preferences and add-ons for reproducible results
timeoutMinutesNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.7.1

TDQS

A4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only supply the safety triad (readOnly=false, destructive=true, openWorld=false); the description adds the behavior an agent actually needs: no GUI window ever appears, every call is a fresh process so unsaved state is lost, print() is the return channel, code executes as the user with writes confined to the job folder, and the save idiom to persist work. These are exactly the non-obvious traits (state loss, isolation boundary) that change how a caller sequences calls.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the headless guarantee are front-loaded, and every clause carries information: the bpy.ops.render.render flags and the save_as_mainfile path are concrete and useful. It is a dense semicolon-chained paragraph with slightly uneven grouping (capabilities, then persistence, then safety), so light structural splitting would improve scanability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, arbitrary-code-execution tool with 8 optional params and no output schema, the description covers the four things a caller must know: what runs, that state does not survive between calls, how to persist and how results come back, and the write-confinement rule. Remaining parameter detail (engine, timeout, factoryStartup) lives in the schema, and the print-return channel substitutes for the missing output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 88%, so the schema already documents cwd, args, engine, blendFile, scriptPath, factoryStartup and timeoutMinutes. The description reinforces a few of these in prose ('Optionally open a .blend first', 'Give this or code/scriptPath') but adds no syntax, format, or default detail beyond the schema. Baseline 3 is appropriate when structured fields carry the parameter burden.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource: 'Run Blender in background mode ... and execute Python with the full bpy API', then enumerates concrete capability domains (model, animate, materials, render, export .glb/.fbx/.usd). An agent immediately knows this is the Blender scripting entry point. It stops short of 5 because it never explicitly contrasts itself with the other CLI-style siblings (godot_cli, rive_cli), leaving that routing to inference from the tool name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage context is implied rather than stated: 'Optionally open a .blend first', 'Give this or scriptPath' from the schema, and the persistence advice 'persist work in a .blend file' hint at the intended workflow. There is no explicit when-to-use / when-not-to-use statement and no named alternative for scene vs. render vs. export tasks. An agent can infer the workflow but must construct the decision boundaries itself.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.