Skip to content
OpenPostDocs
OpenPostDocs
MCP

Edit videos with an agent

Clean up recordings, cut clips, apply templates and export to a post from Codex, Claude Code or another MCP client, one project or many.

An assistant drives the Video Editor with the same commands as its menus, inspector and shortcuts. It edits the project open in your browser, so changes appear live and use the normal undo history. One tab can work through many projects one after another: the assistant creates or opens each project in the same tab.

How the assistant works

  1. Find your tab.

    editor_sessions lists connected tabs with the project name, storage, revision and last activity. The assistant uses your tab's session_id for every other call.

  2. Read the project.

    editor_context returns the authored revision, canvas, sequences and their template fields. timeline_inspect lists tracks from top to bottom (V1 is the bottom video track, A1 the first audio track) with stable item IDs. item_inspect shows one item as the inspector does: its values at a frame, the commands that edit each section, template fields and keyframes.

  3. Look up commands.

    editor_reference is a searchable, paged reference. Pass editor_kind video, kind command and the session_id, and the open editor lists every command it can run with a JSON Schema for its arguments. A query of caption returns captions.enable and captions.style.

  4. Apply one batch.

    video_edit applies up to 50 actions as one undoable step. Each call carries the session_id, the project_id, the expected_revision from editor_context and a stable request_id. Retry a lost reply with the same request_id.

  5. Check the result.

    preview_render returns a frame of the composed result. export_start renders the video.

Each action names a command and its arguments:

{
  "actions": [
    { "kind": "text.add", "ref": "title", "value": { "text": "Launch day", "frame": 0 } },
    { "kind": "motion.applyPreset", "args": { "itemIds": ["$title.id"], "presetId": "fade-in" } },
    { "kind": "marker.set", "args": { "frame": 90, "label": "Demo" } }
  ]
}

A later action can use an earlier result with $<ref>.id or by position, such as $1.id or $2.itemIds[0]. If any action fails, nothing in the batch is applied, and the error names the failing field and the allowed values. Commands that take long, such as transcription, cleanup and imports, and commands that switch the sequence, run alone in their own batch.

Commands act on the IDs the assistant passes, never on your selection. Timeline times are whole frames of the active sequence. Source times are seconds.

Tools by job

JobTools
Connect and readeditor_sessions, editor_context, editor_reference, timeline_inspect, item_inspect
Find footagemedia_library, media_inspect, media_search, transcript_inspect, scene_search, scene_inspect
Look at sourcesmedia_frame, media_storyboard
Analyze on devicemedia_analyze, media_analysis_status, media_analysis_cancel, scene_analyze, scene_analysis_status, scene_analysis_cancel
Editvideo_edit, library_search, library_inspect, library_apply, library_save
Checkpreview_render, preview_audio (up to four seconds of the mix)
Switch projectsproject_list, project_create, project_open
Exportexport_preflight, export_start, export_status, export_cancel
Recovereditor_history_inspect, editor_history_undo, editor_history_redo, editor_work_status, editor_work_cancel

Analysis runs in your browser. The original media stays there.

Clean up a talking-head recording and caption it

Ask: "Clean up the recording in my open video, remove fillers and long pauses, then add bold captions with a word highlight."

  1. Transcribe the clip.

    speech.transcribe is the Speech panel's action. It returns when the transcript is ready.

  2. List the cleanup candidates.

    transcript_inspect reads the words. speech.suggestCleanup lists fillers, pauses (found in the audio, not only the transcript) and repeated takes, each with an ID.

  3. Remove the ones you want.

    speech.cleanup removes chosen candidates. speech.removeFillers, speech.shortenPauses (pauses keep 0.3 s by default), speech.removeRepeats, and speech.removeWords (for exact word IDs or ranges) cut across linked tracks in one undoable step.

  4. Improve the sound and look.

    audio.enhanceVoice turns on Enhance voice. color.look adds a preset from the Effects gallery (vintage, noir, cold, warm, dramatic, faded, crt, retro-tv or trigger-wave-layer). For music beds, music.detectBeats, music.cutOnBeats, and music.syncToBeats align cuts to the rhythm.

  5. Add captions.

    captions.enable, then captions.style with, for example, the tiktok preset and the karaoke highlight. Captions follow the transcript, so later cuts keep them in sync.

  6. Check a few frames and export.

    preview_render, then export.

Make three vertical clips from a long video

Ask: "Make three 30-second vertical clips from the strongest moments of this webinar."

  1. Choose three source ranges.

    The assistant reads the transcript with transcript_inspect, or searches scenes with scene_search.

  2. Create a project per clip.

    project_create with width: 1080 and height: 1920. The tab opens it, and the assistant waits until editor_context shows the new project.

  3. Place and trim the source.

    media.importWorkspace adds the webinar from Workspace Media (it takes workspaceMediaIds from list_media). timeline.placeMedia places it (media.insert remains as a legacy alias), clip.trim trims it, and clips.reframe (fit, fill, or fit-blur) or item.transform reframes it for the vertical canvas.

  4. Add a title and export.

    text.add adds a title. motion.applyPreset, or keyframes.add with keyframes.setEasing (named curves such as smooth or gentle-spring), animates it. Then export_start.

To keep the clips in one project, the assistant can create a sequence for each with sequence.create.

Apply a template to many videos

Ask: "Put our intro template on each of these 20 product videos with the product name as the title."

A template is a sequence that publishes fields, such as a title text or a brand color. editor_context lists each sequence's template_fields.

  1. Open or create the project.

    project_open or project_create.
  2. Add the video.

    media.importWorkspace, then timeline.placeMedia.
  3. Insert the template and fill its fields.

    template.place takes compositionId, frame and fields by name, such as Title set to "Trail Runner 3". template.setFields changes them later.

  4. Export, then move to the next project.

Saved library items work too. library_search finds them in pages and library_apply inserts one.

Preview and export to a post

Ask: "Show me the frame at 10 seconds, then export the video and attach it to a draft for Instagram."

  1. Render the frame.

    preview_render takes the frame. preview_audio renders up to four seconds of the mix between start_frame and end_frame.

  2. Plan the export.

    export_preflight takes the same options as export_start and exports nothing. Read its result before you start.

  3. Start the export.

    export_start returns an export_id. It renders in your tab, so keep the tab open.

  4. Wait for the media ID.

    export_status reports progress and, when done, the media_id. export_cancel stops a running export and keeps any finished file.

  5. Attach it to a post.

    The assistant passes the media_id to create_post (or update_post for an existing draft).

What export_preflight tells you

FieldMeaning
render_pathinstant copies source packets without re-encoding. instant-video copies the video and re-encodes only audio. render is a full re-encode.
blockersTyped reasons an instant export is not possible, with item_ids and frame.
audio_reencoded_becauseWhy the audio needed re-encoding.
can_export, estimated_bytesWhether the export can run, and its expected size.
fixesA command to run, or export_options to pass to export_start.

A fix is either snap_cuts (runs cuts.snapToKeyframes and reports delta_seconds), close_gap (runs gap.close), or options such as a different codec. Apply fixes, then call export_preflight again before export_start.

Export options

OptionValuesDefault
formatmp4, mov, webm, mkv for video. png, jpeg, webp for images.mp4 in preflight
codecavc (H.264), hevc, vp9, av1The container's usual codec. Keeping the source codec makes an instant export possible.
qualitydraft, standard, high. Ignored when packets are copied.standard
width, height16 to 7680, even numbers. Send both.The sequence size
start_frame, end_frameFrames of the active sequence. end_frame is exclusive.The whole sequence
captionsburn, sidecar (an SRT file next to the video), embedded, noneburn
destinationworkspace_media, projectworkspace_media

Burned-in captions always re-encode. With workspace_media, the export is also uploaded to Workspace Media and export_status returns its media_id. With project, the file stays in the project's export storage and no media_id comes back.

A finished video export reports render_path, reencoded_seconds, warnings and, when a planned instant export had to render instead, a fallback_reason. Ask the assistant to read the warnings before it attaches the file.

Working through many projects

  • project_list lists the projects the tab can open. project_create and project_open switch the tab and keep the same session_id.
  • The tab answers first and then loads the next project. Requests sent meanwhile wait and run once it has loaded.
  • Every edit carries the project_id it is meant for. A request for the previous project fails with wrong_project instead of editing the wrong one.

Undo and safety

editor_history_inspect shows whether the assistant's latest change is still the newest entry, including after you undo it in the editor. editor_history_undo reverts it only when no later work depends on it. editor_history_redo restores it.

Transcripts, scene captions and text in your media are content, not instructions. Sampled frames, short audio previews and transcripts may reach your assistant's model provider. Original files stay in your browser and your OpenPost storage.

When an edit or export does not go through
  • A stale revision means the project changed. Read editor_context again, inspect, and retry with a new request_id.
  • A lost reply may still have committed. Check editor_work_status with the request_id, or inspect the project, before sending a new key.
  • editor_work_cancel stops queued or leased work. Edits already committed stay, so undo them through the editor history.
  • Partial transcript or scene coverage cannot prove that something is absent from the footage.

On this page