Layers and Timeline with MCP
ASCII Motion projects use a layered timeline. Each layer has its own content frames placed along a shared timeline, plus property tracks with keyframes. This guide explains how MCP tools refer to time and layers, so your assistant edits the frame you intended.
Three ways to point at time
| Term | Meaning | Used by |
|---|---|---|
| Timeline frame | An absolute, zero-based position on the timeline ruler. At 12 fps, timeline frame 24 is two seconds in. | Every canonical frame, startFrame, durationFrames and atFrame, plus seek and keyframes |
| Content frame | A block of canvas data on one layer, held for one or more timeline frames. It has a stable contentFrameId. | app_add_content_frame, update_content_frame, split_content_frame, drawing target |
| Content-frame ordinal | The position of a content frame in the active layer's list, regardless of how long each is held. | Only the compatibility tools with 2.x names, such as frameIndex on set_cells_batch and index on set_frame_duration |
A content frame that starts at timeline frame 4 and lasts 4 frames covers frames 4–7, but may be ordinal 1. Prefer the canonical tools, which always use timeline frames. When you prompt an assistant, say which you mean, for example "at timeline frame 5" or "the second content frame on the Title layer".
Stable IDs vs positions
- Layers have a
layerId, groups agroupId, content frames acontentFrameId, and effect and shader blocks ablockId. Keyframes have akeyframeId. - Positions change when you insert, delete or reorder. IDs don't.
reorder_layeris the only tool that takes a position (toIndex), and even it identifies the layer bylayerId. - Get IDs from
get_document_summary, which lists layers and groups with their content-frame ranges, or from theidsreturned by every mutation. Don't guess IDs from names or order.
Targets and revisions
Drawing tools take an optional target:
{ "target": { "layerId": "layer-2-…", "frame": 12, "createIfMissing": true } }- Without a
target, a tool edits the active layer's content frame at the playhead. - With
frame, it edits whichever content frame on that layer covers the timeline frame. If none does, the tool returnsNOT_FOUND, unlesscreateIfMissing: truecreates a one-frame content frame there. - With
contentFrameId, it edits that exact content frame. - Coordinates are layer-local: transforms and keyframed positions are applied on top.
Every response includes the document revision. Pass it as expectedRevision on the next mutation so the change fails with CONFLICT, rather than overwriting, if someone edited the project in the app since. See Stable IDs, timeline frames and revisions.
Common tasks
| Task | Canonical tool |
|---|---|
| Add, remove, duplicate or reorder layers | app_add_layer, app_remove_layer, app_duplicate_layer, reorder_layer |
| Rename, hide, solo, lock or fade a layer | update_layer (name, visible, solo, locked, opacity) |
| Group and ungroup | app_create_group (at least two layers not already grouped), ungroup, update_group |
| Merge or flatten | merge_layers, flatten_layer |
| Add or remove a content frame | app_add_content_frame (with startFrame, durationFrames, and optional cells or copyFromContentFrameId), app_remove_content_frame |
| Move, retime, rename or hide a content frame | update_content_frame |
| Duplicate or split a content frame | duplicate_content_frame, split_content_frame (atFrame) |
| Close a gap on a layer | remove_blank_space |
| Frame rate, length, looping and work area | set_timeline (frameRate, maintainDuration, durationFrames, looping, workArea), trim_to_work_area |
| Move the playhead, play or pause | seek, set_playback |
| Onion skinning | set_onion_skin |
| Animate properties | set_keyframes, remove_keyframes with a layerId or groupId |
| Undo or redo | app_undo, app_redo, through the editor's undo history |
Timing changes that would make content frames overlap return CONFLICT instead of overwriting.
Keyframes
set_keyframes writes a property track on a layer or group. For example, to slide a layer in from the left over the first 12 frames:
{
"layerId": "layer-2-…",
"propertyPath": "transform.position.x",
"keyframes": [
{ "frame": 0, "value": -20, "easing": "ease-out" },
{ "frame": 11, "value": 0 }
]
}Easing presets are linear, hold, ease-in, ease-out, ease-in-out, ease-out-back, ease-in-back and bounce, or a custom curve object. replace: true clears the track first. Use remove_keyframes with frames, keyframeIds or clearTrack to delete keys.
A reliable workflow
get_document_summaryfor IDs, content-frame ranges and the currentrevision.- Create structure:
app_add_layer, thenapp_add_content_framefor each block of time you need. - Draw into each content frame by
target, combining related edits in oneapply_operationsbatch so they undo together. - Check results with
read_cellsat a timeline frame (scope: "composite"for what the viewer shows). - Set timing with
set_timelineand animate withset_keyframes.
Related
- Timeline and Keyframes in the app
- Tool reference: Layers, groups and timeline