mirror of
https://github.com/storytold/effectcraft.git
synced 2026-12-06 00:41:18 -05:00
dc3211b354
- Plain `mcp` routed to a headless session runs a blocking render as a long job again (progress, other requests, cancellation): the long-job path uses the routed session. - A tool's calls all go to one route, so a window closing mid-tool can't split them. - The window's `agent_folders` answer is narrowed to the command's folders. - A write-only session names its write folder as its read folder too. - `file.revert` checks the open project's file against the read folders; `file.save` with a non-string `path` checks the open project's file against the write folders. - Reverting (and the reload after the file changed) keeps an agent's footage limits. - An agent request queued before the switch turned off, or the folders changed, doesn't run; a request with other limits waits until queued input from another scope was applied. - Docs: several write roots need --headless. Tests: fixture cleanup, broken-pipe write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
113 lines
7.5 KiB
Markdown
113 lines
7.5 KiB
Markdown
# MCP conventions
|
||
|
||
Run `effectcraft-cli mcp`: it reaches the open EffectCraft window while the ArtCraft Launcher's
|
||
Settings › AI agents switch lets agents use EffectCraft, runs headless while it doesn't, and
|
||
follows the closed-app choice while it does and EffectCraft is closed
|
||
([agents.md](agents.md#agents-in-the-open-window)). `--headless` always runs headless, and
|
||
`--when-closed launch|headless|error` chooses what happens while EffectCraft is closed.
|
||
`effectcraft-cli mcp --bridge 9877` (deprecated) still drives a desktop app started with
|
||
`--control 9877`.
|
||
|
||
`agent_folders` (no arguments) names the folders the session's file commands may use:
|
||
`read_folder` and `write_folder`, or `unrestricted: true` for the deprecated `--bridge` started
|
||
without automation roots.
|
||
|
||
## Confining file access
|
||
|
||
`--automation-read-root DIR` and `--automation-write-root DIR` (as in PhotoCraft; read roots are
|
||
repeatable, and several write roots need `--headless`, since plain `mcp` takes one) confine what the agent can reach: files are read only under a read or write root and
|
||
written only under a write root; with no write root nothing is written. A session without a window
|
||
is always confined, as in every Craft app: a direction without a root (or, on plain `mcp`, without
|
||
an agent folder) grants nothing, so `mcp --headless` without roots opens and saves no file. Every engine command
|
||
(`execute_command`, `command_run`, each `batch` step) is checked before it runs: its file
|
||
parameters must be absolute paths inside the roots (symbolic links resolved, no `..`), and so must
|
||
any other absolute path in its parameters. Save, Increment and Save and rendering the Render
|
||
Queue are checked against the files they write (the open project's, the queued outputs);
|
||
`renderQueue.add`, `render.preRender` and `file.createProxy` without an output file need a saved
|
||
project, since an unsaved one's default output would go to the home folder (#2479). In a headless
|
||
session the footage a project names, and what an imported file pulls in, is read only inside the
|
||
roots too: footage outside them shows as missing (#2131). Scripts
|
||
(`run_script`, `file.runScript`…), Execute File, Reveal in Finder, `$N` references to file paths
|
||
in a batch, and the bridge's UI-driving tools (`ui_click`, `ui_key`, `ui_type`, `ui_drag`,
|
||
`ui_set`, `script_ui`, `control`) are refused while confined. Only the deprecated `--bridge`
|
||
without roots leaves file access to the app it drives.
|
||
|
||
The server provides the same core conventions as FilmCraft #28:
|
||
|
||
| Tool | Arguments | Result |
|
||
| --- | --- | --- |
|
||
| `command_list` | `filter?`, `enabled_only?`, `schemas?`, `compact?` | Command catalog |
|
||
| `command_run` | `id`, `params?` | Engine command result |
|
||
| `command_batch` | `steps: [{id, params?}]`, `stop_on_error?` | `completed`, `failed`, per-step `results` |
|
||
| `doc_inspect` | none | Project overview and active composition |
|
||
| `render_preview` | `comp?`, `time?` or `times?`, `columns?`, `labels?`, `max_side?`, `transparent?` | PNG and frame information; with `times`, one contact-sheet PNG and its layout (`columns`, `rows`, `cellWidth`, `cellHeight`, `width`, `height`) |
|
||
|
||
`command_batch` stops at the first error by default; false continues. Each edit has its
|
||
own undo step. The existing `batch` tool retains its atomic undo grouping and result references.
|
||
Existing tools, including `list_commands`, `execute_command`, and `batch`, remain listed
|
||
because existing workflows use them; there are no hidden aliases. See [agents.md](agents.md)
|
||
for the full catalog. Each tool has a title and read-only, destructive, idempotent and
|
||
open-world hints. Tools with an optional output path are conservatively annotated as file writers.
|
||
|
||
Unknown top-level tool argument keys return JSON-RPC `-32602` naming the key and accepted
|
||
arguments. EffectCraft already rejects unknown engine command parameters; that behaviour is
|
||
preserved. Tool failures (including escaped panics) return `isError: true`, and so does any JSON
|
||
result with a `failed` count above zero (a `command_batch` / `batch` with a failed step, a
|
||
render whose queue items did not all finish), even though the other steps or items succeeded:
|
||
read `results` / `items` for the details. Malformed JSON
|
||
returns `-32700` with a null id and the session keeps serving. The MCP backend owns its session
|
||
without a mutex; the engine's render-job mutexes already recover poisoned locks.
|
||
|
||
Resources `effectcraft://document` and `effectcraft://commands` return JSON matching
|
||
`doc_inspect` and `command_list`. Clients declaring MCP 2026-07-28 in per-request `_meta`
|
||
receive `resultType: complete` and list/read cache hints; document reads are never cached.
|
||
|
||
```json
|
||
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"command_run","arguments":{"id":"comp.new","params":{"width":640,"height":360}}}}
|
||
{"jsonrpc":"2.0","id":2,"method":"resources/read","params":{"uri":"effectcraft://document"}}
|
||
```
|
||
|
||
## Two outputs on one file
|
||
|
||
Two outputs of one job that write the same file (two items with one Output To, a duplicated item,
|
||
output modules or segments that meet) refuse the whole `renderQueue.render` before anything is
|
||
written: the reply is `isError: true`, naming both items, and the queue is left as it was.
|
||
Sequences clash only on the frames both write. Skip Existing Files leaves earlier frames alone
|
||
only when the exporter can check the final destination; browser/memory sinks and storage-overflow
|
||
renders still report collisions. Preflight checks every configured overflow destination, since free
|
||
space can change during a render. A new item's default output name is numbered (`Main.mp4`,
|
||
`Main_1.mp4`) when another item of the queue writes it.
|
||
|
||
## Progress and cancellation
|
||
|
||
Headless `command_run` / `execute_command` calls to `renderQueue.render` (unless `wait: false`)
|
||
run the existing background job while the MCP server keeps reading stdin. A
|
||
`params._meta.progressToken` string or number opts into `notifications/progress`, at most ten
|
||
per second, strictly increasing with a queue-item total. No token means no notifications.
|
||
`ping`, inspection and other requests are served while rendering. Closing stdin lets the
|
||
pending render finish and reply.
|
||
|
||
### Requests during a render
|
||
|
||
A render job owns a snapshot of the project taken when it started. While it runs:
|
||
|
||
- Every way of starting a second render is refused with `isError: true`: a blocking
|
||
`renderQueue.render`, one with `wait: false`, or one inside a batch.
|
||
- Other commands, including edits, run normally and change the project. They do not affect the
|
||
running job, which keeps rendering its snapshot; to render an edit, render again after the
|
||
job ends. Queue items are matched by id when the job reports their status, so an item removed
|
||
mid-render is left out of the reply and counted in `failed`.
|
||
|
||
Send `notifications/cancelled` with `params.requestId` to stop the matching request at the next
|
||
frame batch. No response is sent for that cancelled request. Unknown and completed ids are
|
||
ignored. The exporter records the exact files it opens, including storage overflow paths, and
|
||
removes those files on cancellation; it never scans for similarly named files. Finished earlier
|
||
queue items and skipped existing frames remain. Custom exporters implement the same cleanup
|
||
contract. A failed queue item gives `isError: true`.
|
||
|
||
Bridge calls, `wait: false`, batch tools and single-frame tools retain synchronous/polling
|
||
behaviour and do not report MCP progress or cancellation. `renderQueue.render {"wait": false}`
|
||
returns the ids being rendered at once; poll `renderQueue.list` for status and stop it with
|
||
`renderQueue.stop`. Use a direct blocking command call
|
||
for an MCP-cancellable render.
|