MCP: Previz (#185) #215

Merged
crowmaki merged 1 commit from issue-185-mcp-previz into main 2026-10-14 07:47:12 +00:00
Owner

Closes #185. Part of #157.

A harness can now take a Complex shot through Previz: flag the Shot, read its Blender scene spec, build and animate the scene through a Blender MCP, and attach the Playblast. Each tool wraps the same ApiImpl command the UI uses. The edits land in the undo log with their usual labels: "Mark shot complex", "Unmark shot complex" and "Import playblast".

Tools

  • set_shot_complex: marks a Shot complex or unmarks it. Unmarking keeps its versions. Returns read_shot_previz.
  • read_shot_previz: complex, status (none, current or mismatched), current, versions oldest first, and refused.
  • prepare_blender_scene: writes the scene spec, its reference files and the bootstrap into the Shot's previz folder, as Open in Blender does. Returns folder, specFile, script, blendFile, reopens, setAside and the camelCase spec: size, frames, subjects with their figure colours, Line markers, and the paths of the reference files (audio, panels, locationAngle) and of output. With rebuild, it moves the saved Blender file aside first. The description tells an agent in a running Blender to set sys.argv to end in -- and the spec file before it runs the bootstrap. It also says the spec file uses snake_case keys, and that a video written to output is picked up by itself, so the agent shouldn't attach it as well.
  • attach_playblast: imports a video from an absolute path as the Shot's next previz version, the same ingest as "Import playblast…". Returns versionId and previz.
  • open_in_blender: the optional "Open in Blender" (and with rebuild, "Rebuild Blender scene"). It starts Blender on the filmmaker's machine and returns read_shot_previz.

The server instructions now define Complex shot, Previz and Playblast in the glossary, and put Previz in the pipeline order.

Core

BlenderScene now carries the PrevizSceneSpec it wrote, so the tool returns exactly what is in scene.json. ApiImpl::prepare_blender_scene is shared by the Open in Blender command and the MCP tool. The new DTOs are MCP-only, so bindings.ts is unchanged.

Tests

src-tauri/tests/mcp_previz.rs covers:

  • Marking and unmarking a Shot complex, with the undo labels.
  • Reading the scene spec. The files it names are on disk in the Shot's folder, and scene.json matches the returned spec. A second call reopens the saved file, and rebuild sets it aside.
  • Refusing the scene spec for a Shot that isn't complex.
  • Attaching a Playblast rendered at the spec's frames. It becomes the current version, not mismatched, with the "Import playblast" undo label, and undo removes it.
  • Refusing a relative path and a Shot that isn't complex.

The full cargo test --workspace and bun test pass.

Known limits

  • open_in_blender has no test. It would start a real Blender on a machine that has one installed.
Closes #185. Part of #157. A harness can now take a Complex shot through Previz: flag the Shot, read its Blender scene spec, build and animate the scene through a Blender MCP, and attach the Playblast. Each tool wraps the same `ApiImpl` command the UI uses. The edits land in the undo log with their usual labels: "Mark shot complex", "Unmark shot complex" and "Import playblast". ## Tools - `set_shot_complex`: marks a Shot complex or unmarks it. Unmarking keeps its versions. Returns `read_shot_previz`. - `read_shot_previz`: `complex`, `status` (`none`, `current` or `mismatched`), `current`, `versions` oldest first, and `refused`. - `prepare_blender_scene`: writes the scene spec, its reference files and the bootstrap into the Shot's previz folder, as Open in Blender does. Returns `folder`, `specFile`, `script`, `blendFile`, `reopens`, `setAside` and the camelCase `spec`: size, frames, subjects with their figure colours, Line markers, and the paths of the reference files (`audio`, `panels`, `locationAngle`) and of `output`. With `rebuild`, it moves the saved Blender file aside first. The description tells an agent in a running Blender to set `sys.argv` to end in `--` and the spec file before it runs the bootstrap. It also says the spec file uses snake_case keys, and that a video written to `output` is picked up by itself, so the agent shouldn't attach it as well. - `attach_playblast`: imports a video from an absolute path as the Shot's next previz version, the same ingest as "Import playblast…". Returns `versionId` and `previz`. - `open_in_blender`: the optional "Open in Blender" (and with `rebuild`, "Rebuild Blender scene"). It starts Blender on the filmmaker's machine and returns `read_shot_previz`. The server instructions now define Complex shot, Previz and Playblast in the glossary, and put Previz in the pipeline order. ## Core `BlenderScene` now carries the `PrevizSceneSpec` it wrote, so the tool returns exactly what is in `scene.json`. `ApiImpl::prepare_blender_scene` is shared by the Open in Blender command and the MCP tool. The new DTOs are MCP-only, so `bindings.ts` is unchanged. ## Tests `src-tauri/tests/mcp_previz.rs` covers: - Marking and unmarking a Shot complex, with the undo labels. - Reading the scene spec. The files it names are on disk in the Shot's folder, and `scene.json` matches the returned spec. A second call reopens the saved file, and `rebuild` sets it aside. - Refusing the scene spec for a Shot that isn't complex. - Attaching a Playblast rendered at the spec's frames. It becomes the current version, not mismatched, with the "Import playblast" undo label, and undo removes it. - Refusing a relative path and a Shot that isn't complex. The full `cargo test --workspace` and `bun test` pass. ## Known limits - `open_in_blender` has no test. It would start a real Blender on a machine that has one installed.
set_shot_complex marks a Shot complex or unmarks it, and read_shot_previz
reads its previz status and versions. prepare_blender_scene writes the
Shot's scene spec, references and bootstrap as Open in Blender does, and
returns the spec with the paths, so an agent can build the scene through
a Blender MCP. attach_playblast imports a video as the Shot's next previz
version, the same ingest as Import playblast. open_in_blender starts
Blender on the scene, or rebuilds it.

BlenderScene now carries the spec it wrote, and ApiImpl's
prepare_blender_scene is shared by Open in Blender and the MCP tool.
crowmaki deleted branch issue-185-mcp-previz 2026-10-14 07:47:12 +00:00
Sign in to join this conversation.
No description provided.