zhouxiaoka/autoclip is an MIT-licensed, local-first AI video clipper (about 20k stars) with a desktop app, a CLI and an MCP server. This is a source reading at commit f884b77: I cloned the repo and read backend/mcp_server.py, backend/services/zero_key_pipeline.py, backend/services/mcp_jobs.py, server.json, .mcp.json and docs/MCP.en.md. I only looked at the MCP surface, not the desktop UI or rendering engine internals.
Companion tutorial: how to install and drive it is on Cui.Guru: Let your coding agent clip long videos into Shorts with AutoClip MCP.
The workflow in motion
Architecture
The server is a single stdio process built on the MCP Python SDK (mcp_server.py tries the 2.x MCPServer, then falls back to 1.x FastMCP). It exposes two ways to get a result. The classic route is start_quick_output followed by polling get_quick_output_status; the model call happens inside AutoClip, using the desktop settings or AUTOCLIP_API_KEY. The zero-key route splits the job in two so the model call happens in the host agent instead.
The job registry is the part worth stealing. mcp_jobs.py opens with its contract: “Disk-backed status for CLI and MCP jobs. A missing record is unknown. A record whose worker process is gone is interrupted. Project files alone never mean the job completed.” The server also keeps an in-memory job map for the legacy tools, but this disk-backed registry can be queried across processes. Note that get_quick_output_status first asks quick.status() (which reads Studio state) and falls back to mcp_jobs.lookup for invalid ids or missing projects; the contract above describes that fallback.
The core design idea
Make the agent the planner and the server the renderer. In the zero-key route the server never calls a model. prepare_media ingests a local file or an HTTPS YouTube/Bilibili URL, reuses a supplied SRT or transcribes the video, and returns a project_id plus the subtitles. The function is documented as making zero LLM calls, but its transcription step tries local SenseVoice and then an automatic recognizer selection that can pick a cloud recognizer if your saved settings say so, so only a supplied SRT or an explicitly local setup guarantees a fully offline run. It can also return ok: true with no srt_path if transcription fails. The host agent, which is already an LLM with its own subscription, decides which moments are worth clipping. render_from_plan then turns that decision into files. The server’s own instructions describe it as reusing the current Claude Code, Codex, Cursor or Gemini subscription quota, and both tool results carry "llm_calls": 0.
The boundary between the two halves is a strict schema, not free text. The plan is validated by pydantic models with extra="forbid", so unknown fields are rejected instead of silently ignored:
# backend/services/zero_key_pipeline.py
class ExternalClipSpec(BaseModel):
model_config = ConfigDict(extra="forbid", allow_inf_nan=False)
id: Optional[str] = Field(default=None, pattern=r"^[a-zA-Z0-9_-]{1,64}$")
title: str = Field(min_length=1, max_length=200)
start: Optional[float] = Field(default=None, ge=0)
end: Optional[float] = Field(default=None, gt=0)
scenes: Optional[list[ExternalSceneSpec]] = Field(default=None, max_length=30)
hook: str = Field(default="", max_length=120)
...
A clip needs start/end or scenes (non-empty scenes take precedence); a validator turns a lone range into one scene and each scene must be at least 0.5 s. Source-duration checks happen per clip while rendering, so a bad later clip can fail after earlier ones were produced. A plan holds 1 to 20 clips. The template id is checked against the registry (is_valid_style) before the rendering loop starts, and platform aliases such as reels and shorts are normalised to instagram_reels and youtube_shorts.
Job honesty is enforced in code. A running record whose process has vanished is reported as interrupted, and the process check compares the stored creation time to guard against PID reuse:
# backend/services/mcp_jobs.py
def _process_alive(record):
pid = record.get('pid')
...
proc = psutil.Process(pid)
...
return abs(proc.create_time() - float(created)) <= 0.05
Tool exposure is also dynamic. cancel_job and list_styles are registered only while the mcp_v2_tools feature flag is on: _sync_v2_tools() runs inside a wrapped list_tools and calls server.add_tool or server.remove_tool to match. Legacy tools get a deprecated: prefix and a deprecated meta flag in the same wrapper. The server also wraps call_tool to record telemetry through mcp_telemetry; I did not read what it records or where it goes.
# backend/mcp_server.py
async def _list_tools():
_sync_v2_tools()
return [_present_tool(tool) for tool in await _original_list_tools()]
server.list_tools = _list_tools
Secrets stay out of the tool surface: server.json declares AUTOCLIP_API_KEY as an optional secret environment variable, and .mcp.json forwards it with a 120 s startup timeout for the first uvx download.
Takeaways
- Splitting “understand” from “execute” lets an MCP server avoid owning a model at all: the agent plans, the server validates and renders.
- A strict,
extra="forbid"schema is the contract that cuts down malformed agent-authored plans, though per-clip checks still happen at render time. - For long jobs, persist status on disk and derive state from the record plus process liveness. Never infer success from files that happen to exist.
- Feature-flagged tools via a wrapped
list_toolsgive you a gradual rollout path without separate server builds.
Want a custom agent or MCP integration built for your own workflow? Get in touch at cui.guru/contact.
Click to load Disqus comments