Skip to main content

Overview

External agents (such as Claude Code, custom scripts, or any HTTP client) can control the running Masterselects editor via a local HTTP bridge. The bridge exposes 76 tools covering clip management, timeline editing, playback, effects, export, and debugging.
The bridge only accepts loopback connections (127.0.0.1). It never binds to a network interface, so it cannot be reached from other machines on the same network. All requests require a Bearer token generated at startup.

Requirements

Two environments are supported:
EnvironmentEndpointRequirements
ProductionPOST http://127.0.0.1:9877/api/ai-toolsNative Helper running, Masterselects open in a browser tab
DevelopmentPOST http://localhost:5173/api/ai-toolsVite dev server running, Masterselects open in a browser tab
Both modes require a Bearer token. In production the token is printed to the Native Helper terminal at startup. In development the token is generated per session.

Making a request

Endpoint

POST http://127.0.0.1:9877/api/ai-tools

Request headers

header.Content-Type
string
required
Must be application/json.
header.Authorization
string
required
Bearer token in the format Bearer <startup-token>. The token is printed to the Native Helper terminal at startup.

Request body

tool
string
required
The tool name to execute. Use _list to retrieve all available tools. Use _status to check bridge health.
args
object
required
Arguments for the tool. Shape depends on the tool. Pass {} for tools with no required arguments.

Example: list available tools

curl -X POST http://127.0.0.1:9877/api/ai-tools \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <startup-token>" \
  -d '{"tool":"_list","args":{}}'

Example: move the playhead

curl -X POST http://127.0.0.1:9877/api/ai-tools \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <startup-token>" \
  -d '{"tool":"setPlayhead","args":{"time":10.5}}'

Example: call from Node.js

const response = await fetch('http://127.0.0.1:9877/api/ai-tools', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <startup-token>',
  },
  body: JSON.stringify({ tool: 'getStats', args: {} }),
});
const result = await response.json();

Tool call format

{
  "tool": "<tool_name>",
  "args": { ... }
}
All tool responses are JSON. Failed calls return an error object with a message field.

Available tools (76 total)

Tools are defined in src/services/aiTools/definitions/ across 15 files.

Timeline state

ToolDescription
getTimelineStateFull timeline state (tracks, clips, playhead)
setPlayheadMove playhead to a time
setInOutPointsSet in/out markers

Clip info

ToolDescription
getClipDetailsDetailed clip info + analysis + transcript
getClipsInTimeRangeFind clips within a time range

Clip editing

ToolDescription
splitClipSplit at a specific time
splitClipEvenlySplit into N equal parts
splitClipAtTimesSplit at multiple specific times
deleteClipDelete a single clip
deleteClipsDelete multiple clips
moveClipMove to a new position/track
trimClipAdjust in/out points
cutRangesFromClipRemove multiple sections
reorderClipsReorder clips by ID list
addClipSegmentAdd a segment of a source clip to the timeline

Selection

ToolDescription
selectClipsSelect clips by ID
clearSelectionClear the current selection

Track tools

ToolDescription
createTrackCreate a video or audio track
deleteTrackDelete a track and its clips
setTrackVisibilityShow or hide a track
setTrackMutedMute or unmute a track

Visual capture

ToolDescription
captureFrameExport a PNG at a specific time
getCutPreviewQuad4 frames before + 4 frames after a cut point
getFramesAtTimesGrid image at multiple times

Analysis and transcript

ToolDescription
getClipAnalysisMotion/focus/brightness data per frame
getClipTranscriptWord-level transcript
findSilentSectionsFind silence gaps
findLowQualitySectionsFind blurry sections
startClipAnalysisTrigger background analysis
startClipTranscriptionTrigger transcription

Media panel

ToolDescription
getMediaItemsFiles, compositions, folders
createMediaFolderCreate a folder
renameMediaItemRename an item
deleteMediaItemDelete an item
moveMediaItemsMove items to a folder
createCompositionCreate a new composition
openCompositionOpen/switch to a composition
importLocalFilesImport files from the local filesystem
listLocalFilesList files in a local directory
selectMediaItemsSelect items in the media panel

Batch operations

ToolDescription
executeBatchExecute multiple tool calls as a single undoable action

YouTube / Downloads

ToolDescription
searchVideosSearch YouTube by keyword
listVideoFormatsList available formats for a video URL
downloadAndImportVideoDownload a video and import to the timeline
getYouTubeVideosList videos in the Downloads panel

Transform

ToolDescription
setTransformSet position, scale, rotation on a clip

Effects

ToolDescription
listEffectsList available GPU effects
addEffectAdd an effect to a clip
removeEffectRemove an effect from a clip
updateEffectUpdate effect parameters

Keyframes

ToolDescription
getKeyframesGet keyframes for a clip property
addKeyframeAdd a keyframe at a time
removeKeyframeRemove a keyframe by ID

Playback

ToolDescription
playStart playback
pausePause playback
setClipSpeedSet clip playback speed
undoUndo the last action
redoRedo the last undone action
addMarkerAdd a timeline marker
getMarkersGet all markers
removeMarkerRemove a marker by ID

Transitions

ToolDescription
addTransitionAdd a transition between clips
removeTransitionRemove a transition

Masks

ToolDescription
getMasksGet masks on a clip
addRectangleMaskAdd a rectangle mask
addEllipseMaskAdd an ellipse mask
addMaskAdd a custom polygon mask
removeMaskRemove a mask
updateMaskUpdate mask properties
addVertexAdd a vertex to a mask path
removeVertexRemove a vertex from a mask path
updateVertexUpdate a vertex position

Stats and debug

ToolDescription
getStatsCurrent engine performance snapshot (FPS, decoder, drops, audio, GPU)
getStatsHistoryN snapshots over time with min/max/avg summary
getLogsFilter browser logs by level, module, or search text
getPlaybackTraceWebCodecs/VF pipeline events + health state for playback debugging

Bridge architecture

Development (HMR bridge)

In development the Vite dev server proxies HTTP requests to the running app via HMR:
POST /api/ai-tools → Vite server → HMR WebSocket → browser tab → aiTools.execute()
Implemented in src/services/aiTools/bridge.ts. Uses import.meta.hot.on to receive requests and import.meta.hot.send to return results.

Production (Native Helper bridge)

In production builds the Rust Native Helper proxies HTTP to the browser tab via WebSocket:
POST http://127.0.0.1:9877/api/ai-tools → Native Helper (HTTP :9877) →
  WebSocket (:9876) → browser tab → aiTools.execute()
Both modes converge at executeToolInternal() in src/services/aiTools/handlers/index.ts.

Undo support

All AI edits are undoable with Ctrl+Z. Batch operations (executeBatch) wrap multiple tool calls in a single history entry:
startBatch('AI: toolName')
// ... execute tools ...
endBatch()

Build docs developers (and LLMs) love