MCP server: drive the running app from an AI harness #157
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
needs-info
needs-triage
question
ready-for-agent
ready-for-human
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crowmaki/ai-studio#157
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
A filmmaker who works with an AI harness (Claude Code or a similar agent) wants the harness to do the repetitive production work: take a screenplay, build the references, plan coverage, render and review Takes, and hand an edit to DaVinci Resolve. The harness can already drive Blender through a Blender MCP and Resolve through a Resolve MCP. AI Studio, which sits in the middle of that pipeline, has no programmatic surface at all. Every Character, Reference set, Setup, Shot, Keyframe, Take and export has to be clicked through by hand in the app's UI, so the agent stops at AI Studio's front door and the filmmaker does the middle of the film by hand.
Solution
While AI Studio is running, it serves an MCP server on the local machine. The harness connects to it the same way it connects to the Blender and Resolve MCPs, and drives the open Project through tools named in the app's own vocabulary (Scene, Setup, Shot, Take, Tile, Lock snapshot, Keyframe, Edit package…).
Through those tools the harness can carry a film from script to Edit package:
Everything the harness does goes through the same domain commands the UI uses. So the open windows update live as the agent works, every edit lands in the undo log with its usual label, and the filmmaker can step in at any time, in the UI or by asking the agent.
The MCP server is off by default. The filmmaker turns it on in App settings, which shows the address, the access token and a ready-to-paste client configuration.
Hand-drawn Boards are not part of the MCP surface.
User Stories
Connecting
claude mcp addcommand line), so that I don't hand-write JSON.Project
Script
Entities
References
Viewing images
Coverage
Keyframes
Performance
Rendering
Review
Cut and export
Safety and collaboration
_Removed/, deleting Source sheets) to be left out of the MCP surface, so that an agent can never destroy media.Implementation Decisions
Api. Each tool calls the existingApiImplcommand (or the samestudio-corefunctions those commands call). No domain rule is written in the MCP layer, in line with ADR-0003. Where a tool needs something the RPC surface lacks, the command is added toApiImplfirst and the MCP tool calls it, so the UI can use it too.ApiImplthe windows use, so it shares the session, the Render worker, the undo log and the change hooks. Agent edits emit the sameChangedDtoevents, so windows refetch as they do for their own edits.127.0.0.1only, using the official Rust MCP SDK (rmcp), running on the app's existing Tokio runtime. stdio is not offered, because the app is a GUI process that is already running when the harness connects.Originheader that isn't a loopback origin are refused, against DNS rebinding.queue_take,edit_tile,lock_reference_set,export_edit_package). It is not a mechanical mirror of all RPCs. Ids are the same strings the RPC uses. Results are compact JSON (as structured content plus a text copy) built from the existing DTOs. Read tools that return large trees (the script, a Scene's Takes) take a Scene or Shot filter.openedordeclined. With no window to ask, it opens directly.save_topath, it writes the full-resolution image there and returns the path instead. Take frames are sampled across the Rendition with the app's existing ffmpeg support. The number of frames can be chosen up to a cap.wait_for_jobs(job_ids, timeout_seconds)blocks until every job has finished or failed, or the timeout runs out, with a capped maximum. It returns early on a failure, on ComfyUI going offline and on a paused queue. When the client sends a progress token, running-job progress is sent as MCP progress notifications, from the same progress feed the Queue panel follows. Export progress is reported the same way._Removed/, delete Source sheets, window commands, the crop editor session, Board save, describe or edit, Notation editing, and App-default settings are not exposed. Authored deletes (Character, Setup, Shot…) are exposed because they are undoable and follow ADR-0004.CommandErrormaps to an MCP tool error (isError) with the app's message and its kind (not found, invalid input, no Project open, conflict…). Errors are never protocol errors, so the agent can recover. Invalid enum inputs list the valid values.Testing Decisions
ApiImplwith a temp config dir, pointed atfake-comfy. A real MCP client (thermcpclient) connects with the token and calls tools. Tests assert only on tool results, tool errors, returned image content and files, and theChangedDtoevents captured throughHooks. They never assert on internals.Originis refused, and the server instructions are presentwait_for_jobs→ view image → Edit with references → lockqueue_takerefusal reasons, and queue → wait → Take listed with Rendition paths and framestools/listwait_for_jobsreturns early on a failed job and on a paused queue, and times out cleanlysrc-tauri/tests/tile_generation.rs(drivesApiImplwithfake-comfy, aninstall_everythinghelper and aHookssink) andsrc-tauri/tests/smoke.rs. The MCP tests follow the same setup with an MCP client on top. Domain rules stay covered by the existingstudio-coretests and are not re-tested through MCP.Out of Scope
_Removed/).Further Notes
rmcpmust stay on the same Tokio runtime the app enters at startup, because taurpc and the Render worker already share it.rmcpto an exact version, like the existingspectapin, because the SDK is still moving.