Skip to content
FunCoding

LeClap

Listed in the official MCP Registry

Compose and render video from one JSON template. Deterministic, runs locally, no generative model.

Star
36
Version
v0.3.4
License
MIT
Last commit
Dec 1, 2026

@leclap/mcp

Connect your AI agent to LeClap’s video engine. Discover samples, author a template, validate it, inspect real frames, revise and render. Start with the agent guide.

An MCP server that exposes the ffmpeg-video-composer engine as agent-callable video tools.

An AI agent (Claude Desktop, Cursor, …) is the LLM; this server helps it author a customized template with nice effects from the schema, then validates and renders it deterministically to an mp4. The server includes the 50 showcase samples through the shared packaged catalog, with creative direction, descriptors and required inputs. It works without the app or private creative-kit at runtime. Motion beyond the filter catalog is authored as an HTML layer with a motion map. The result is agent-composable, deterministic, reproducible video — the opposite of generative video models, which sample rather than render.

Tools

ToolDescription
get_samplesWithout id: sample metadata and required inputs, filtered by category/query → { samples }; with id: that sample with its self-contained template JSON
get_template_schemaThe JSON Schema for a template descriptor + a short authoring guide
get_motion_catalogMotion presets, camera, graphics, transitions, easing/time grammar, themes, platforms, genre doctrine and scene blueprints; { query, kind? } → ranked matches (a query matching nothing is logged to the catalog gap log)
validate_templateDry-run an inline descriptor (no render) → { valid, sectionCount, orientation, requiredClips, formFields, fields?, geometry?, featureWarnings? }; include: ["resolved"] adds resolved (the descriptor for fields/format), include: ["timeline"] adds timeline (sections, motion events, beats, cues)
compose_videoValidate an inline descriptor and render (one format of it, optionally, at resolution 720p, 1080p or 4k) → { outputPath, durationSeconds, sizeBytes, videoCodec, audioCodec, renderId }, plus a resource_link to the mp4
render_framesRender a native template and return still frames as PNG images + paths: at, atTransitions, perSection, sheet, safe, zoom, variants, looks
edit_templateJSON Patch operations over inline JSON, under expectedRevision, all-or-nothing → { template, revision, changedPaths }
probe_mediaInspect a local media file → codecs, duration, sample rate, size, and HDR / colour / bit depth / VFR / rotation traits
extract_styleReference image/clip under the media dir → { theme, styleGuide, confidence }: palette roles + WCAG contrast, grain, pacing (palette and pacing only)
extract_structureA reference clip's format (shots, rhythm, transitions, grounds, layout) as binding rules for a template. Format only; samples every 0.25 s for up to 2 minutes.
extract_brandA website's brand kit (name, colours, fonts, logo) as a theme and binding rules, saved under <media-dir>/brand-kits/<host>/. Needs --allow-network.
analyze_musicMeasure a local music file → { bpm, offset, beatsPerBar, confidence, usable, cues, globalBeats } for global.beats and cue:drop
analyze_soundRender an sfx[].sound (composed, or a preset with variations) → length, peak/RMS dBFS, centroid, high/low energy shares, attack, advisories + spectrogram and waveform PNGs
transcribe_mediaTranscribe a local audio/video file's speech with whisper.cpp, locally → { words, srt, language, confidence, advice } to pin into subtitles.words
get_capabilitiesLocal FFmpeg capability report (listings + one-frame probes) → each feature yes/no/unknown with a fix
open_in_builderTemplate → a leclap.dev/studio/builder#t=… link for a person to edit it; the template rides in the URL fragment (never sent to a server) → { url, length, mediaToRebind, warnings }

analyze_sound seeds a sound's noise and jitter with seed (default 0). To hear the exact render a template will play, pass the template's global.seed as seed and the cue's path as cue: "sections.intro.sfx[0]" for the first cue of the section named intro, "global.sfx[2]" for the third global cue. The tool then seeds the sound as the mix seeds that cue and returns the seed it used. Levels are floored at -120 dBFS, so a silent sound reads -120 and raises sound_silent.

Typical agent flow: get_samples → get_samples { id } → inspect requirements and customize media/copy → get_template_schema → validate_template (iterate until valid) → render_frames (look at the result; check safe zones with safe) → compose_video → read the returned outputPath. Author a fresh descriptor from the schema when no sample fits.

render_frames renders through a per-section cache under <output-dir>/.section-cache, so a second look after a small edit re-encodes only the sections that changed. It runs in the render worker under the same media-dir checks, slot cap, timeout and cancellation as compose_video, writes PNGs to <output-dir>/frames-<id>/, and inlines at most eight images (the sheets when sheet is set). Moments are seconds or time references on the whole video: "intro.end" (a section or an element id), "50%", "beat:8", "cue:drop + 0.1". validate_template with include: ["timeline"] lists the moments worth picking.

validate_template also reports, render-free, text that would run off the frame or out of title-safe, collide with other text, sit under a band, be too small, lack contrast, or sit over footage with no box, outline or shadow. Those findings arrive on the optional geometry field — one line each, saying what to change, and the field is absent entirely when there is nothing to fix. They are advisory: valid stays true. A line ending (approx: …) says why it is an estimate: the font could not be read, the text carries a {{ variable }} that only resolves at render time, or a section declares no duration. When a font is not bundled, the server fetches it from the LeClap asset catalog (5s timeout); offline, it estimates.

Pass render: true to validate_template to also render the sections that hold text and measure their contrast from real pixels — it settles text over images, grades and looks that the render-free check can only call unknown. It costs seconds (two renders of those sections), goes through the same media-dir sandbox as compose_video, reads assets from the media dir, and runs in the same forked render worker under the same timeout. It adds a render field (measured, seconds, and unavailable when it could not render — no FFmpeg with drawtext, a failed render, or a timeout); the render-free findings come back either way.

Discover samples before authoring

get_samples is always available. It reads packaged data only: no media downloads or repository access. Without id it lists, filtered by optional category (templates, typography, effects, overlays, evidence) and case-insensitive query (up to 4000 characters). With id (1–200 characters) it returns that sample.

{ "name": "get_samples", "arguments": { "category": "typography" } }
{ "name": "get_samples", "arguments": { "id": "web-app-promo" } }

Results include identical JSON in text and structuredContent; with id, the descriptor sits at template alongside its metadata. Unknown IDs return isError with a discovery hint. Required inputs include named clips and durations/capture hints, form fields and limits, variables/defaults/placeholders, assets and effective preset font files (source: "preset"). Replace the sample copy, supply clips by userVideoPaths and form values by fields, customize global.variables, then pass template to validate_template and compose_video. Referenced partials are embedded in the descriptor.

Preview videos/posters and media are not bundled. Supply or replace authored asset references and fonts; relative references must resolve under the configured media directory. The source, showcasePath and preview values describe authoring/showcase locations, not installed local files. To save descriptor JSON outside MCP, use leclap samples export <id> --output <new-file>.

Recipe: video evidence for a pull or merge request

An agent working on a code change can use LeClap to package visual evidence for review:

  1. Collect a short, real screen recording and state what the reviewer should inspect.
  2. Author or reuse a review template such as examples/agentic-pr-video, or its evidence-video skill, which renders the packaged before/after evidence template from one content file.
  3. Call validate_template until the descriptor is valid.
  4. Call compose_video with the recording in userVideoPaths and the review context in fields.
  5. Attach the returned outputPath to the PR or MR beside the diff.

The MCP server renders and returns a local artifact. It does not upload to GitHub or GitLab; that remains an explicit step in the surrounding agent workflow.

Prompt

compose-video — a guided authoring prompt (surfaces as /compose-video in clients like Claude Desktop). Takes optional goal, orientation and creativeDirection arguments and primes the agent with the schema, the premium building-block recipes (which filters give which look, the bundled font list, the on-device filter allowlist), and the validate_template → compose_video loop.

creativeDirection is a plain-text visual brief (1–4000 characters). The prompt guides the agent to store it in meta.creativeDirection, translate it into explicit settings and motion, vary layouts by scene purpose, and inspect entrance, settling and ending against the brief. get_template_schema exposes the metadata contract. It is reference material; the renderer does not interpret the prose. Review it with render_frames, which needs an engine render and frame extraction. These are prompt arguments, not extra compose_video arguments. See the creative-direction workflow and examples.

Run

# published — no checkout needed
npx -y @leclap/mcp
# or from a checkout: build the engine + this server, then start it over stdio
pnpm --filter ffmpeg-video-composer build
pnpm --filter @leclap/mcp build
node packages/leclap-mcp/dist/index.js

It speaks MCP over stdio (stdout is the protocol channel — all diagnostics go to stderr). The published bin is leclap-mcp.

FFmpeg. compose_video renders with the engine's FFmpeg: system FFmpeg first, then the bundled ffmpeg-static. ffmpeg-static ships no ffprobe. Templates with transitions, music, whole-video overlays or project_video clips need one, and so does probe_media. On that path a render stops before encoding and names the missing binary. Installing FFmpeg (brew install ffmpeg, sudo apt install ffmpeg) provides both. The optional ffprobe-static package, installed next to the server, also works.

Built on the MCP TypeScript SDK (@modelcontextprotocol/server), tracking the current protocol revision. Clients on an older revision keep working — the stdio entry serves both eras from the same tool definitions.

Configuration

SettingFlagEnvDefault
Output dir--output-dirLECLAP_MCP_OUTPUT_DIR~/.leclap/renders
Media allowlist / assets root--media-dirLECLAP_MCP_MEDIA_DIR~/.leclap/media
Template fonts dir--fonts-dirLECLAP_MCP_FONTS_DIRUnset; global.fonts read from the media dir
Raw filters opt-in--allow-raw-filtersLECLAP_MCP_ALLOW_RAW_FILTERSOff; raw filters are allow-listed
Network opt-in--allow-networkLECLAP_MCP_ALLOW_NETWORKOff
Stage/worker timeout--render-timeout-msLECLAP_MCP_RENDER_TIMEOUT_MS600000 ms (10 min)
Catalog gap log--catalog-gap-logLECLAP_MCP_CATALOG_GAP_LOGcatalog-gaps.jsonl, always under the output dir

--allow-network lets extract_brand fetch websites over HTTPS from public hosts only (private, loopback and link-local addresses, credentials in the URL and non-HTTPS redirects are refused; size and time are capped). Off by default, and the tool is not registered without it.

The fonts dir is read-only: a template's global.fonts[].src resolves there first, then in the media dir, and nowhere else (realpath-checked, so a traversal or a symlink out is refused); fonts are never fetched. validate_template and compose_video both fail on a declared font they cannot read.

Raw filters in agent templates are checked against the engine's raw filter allow-list: a filter outside it is the validation error filter_not_allowed, and get_capabilities reports the mode (rawFilters). The raw filters opt-in restores the raw pass-through for trusted local templates only, and the server says so on stderr at start-up. A render-time deny-list stays on, but it is best-effort: a trusted template can still write files (absolute paths included, through an option the deny-list does not know) and reach the network. A drawtext fontfile is a bare font name (fonts from the media dir go through global.fonts).

Precedence is flag → environment → default. Paths resolve from the server's working directory; supplied ~ values are not expanded. A bare boolean flag, =true / =1, or environment true / 1 enables it; explicit =false / =0 overrides the environment. See the complete engine configuration reference for host configuration, output precedence, stage deadlines and cache behavior.

compose_video uses mediaDir as the engine's assetsDir and creates one buildDir per render. Its fields (strings, numbers or booleans: form values and the declared global.fields, each coerced to its type), userVideoPaths and locale arguments bind media/copy, and format picks one composition of a template with formats; its template.global controls orientation and fps. Codec, quality-tier and FFmpeg segment-concurrency fields are library host settings, not arbitrary MCP tool arguments.

A template can declare its inputs in global.fields (typed: text, color, url, media, number, enum, time; see the template reference). validate_template lists them as fields and reports field_undefined, field_unused, field_type_mismatch and field_missing_required among its advisories; compose_video and render_frames refuse a missing required value or one that fails its type before rendering; and validate_template with include: ["resolved"] shows the descriptor those fields produce.

An inputs[] entry of type: "html" lays out a card, badge or price tag in HTML and CSS (a flexbox subset; see HTML layers). compose_video and render_frames draw it into a transparent PNG and composite it like an image. Its images must be template assets under the media dir (or PNG/JPEG data URIs); remote URLs and absolute paths are refused. validate_template reports html_unsupported_css, html_unsupported_markup, html_font_unknown, html_missing_field and html_overflow (the layer laid out against its box), and fails on html_too_large. get_template_schema explains the input, and get_motion_catalog lists the CSS subset and four layout recipes under html.

Fifteen tools are always registered: get_samples, get_template_schema, get_motion_catalog, validate_template, edit_template, compose_video, render_frames, probe_media, extract_style, extract_structure, analyze_music, analyze_sound, transcribe_media, get_capabilities and open_in_builder. --allow-network adds extract_brand. The server ships no effect renderer: a template with a type: "effect" section is refused by validate_template and compose_video with effect_backend_unavailable; animate the look with an HTML layer (inputs[].type "html" with a motion map). Every tool's name and description is sent to the agent on each turn, so the surface stays small: 0.5.0 folded patch_template into edit_template, list_samples and get_sample into get_samples, and dropped ping (MCP has a protocol ping); see the CHANGELOG migration table.

open_in_builder hands a template to a person: it returns https://leclap.dev/studio/builder#t=v1.… (baseUrl for a locale prefix such as /fr or a local dev server), plus mediaToRebind and warnings. The template rides compressed in the URL fragment, which browsers never send to a server, so nothing is uploaded and no LeClap server exists to receive it. Local paths and media:// uploads cannot travel in a link; the builder opens those scenes empty for the person to fill again. Media under a URL scheme the builder does not load (anything but http(s), data:, library:// and media://) is listed with reason unsupported_scheme and dropped the same way. A baseUrl on another origin than https://leclap.dev (a local dev server included) adds a warning: the page served there can read the template in the fragment, so the agent should say where the link points before sharing it.

edit_template applies a JSON Patch (RFC 6902) to inline template JSON under expectedRevision: the batch is all-or-nothing and the result must validate. The web template builder exposes the same vocabulary to in-browser agents through WebMCP: get_template_schema, get_motion_catalog, validate_template, edit_template (JSON Patch) and render_frames mean the same there, and both surfaces compute the same revision for the same JSON.

Captions from speech: pin, then review. transcribe_media runs whisper.cpp on the host (the audio never leaves it) and returns { words, srt, language, confidence, advice }, word times in seconds into the file. Either pin them into the section's subtitles.words (subtract clip.from), or put subtitles: { transcribe: { from: "self" } } on the section and let compose_video transcribe and pin before it renders. Show the words to the user before publishing; lowConfidence: true means some were likely misheard. The tool never downloads a model: the operator fetches it once with leclap transcribe --download-model (or sets LECLAP_WHISPER_DOWNLOAD=1 in the server environment).

Each render writes to <output-dir>/<renderId>/. Local input files (userVideoPaths, probe_media, extract_style, analyze_music, transcribe_media) must resolve inside the media-dir (symlink-safe containment check). The media-dir default is deliberately narrow — pointing it at ~ would let any tool call read the whole home directory.

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json (absolute paths only — env values are not tilde-expanded):

{
  "mcpServers": {
    "leclap": {
      "command": "npx",
      "args": ["-y", "@leclap/mcp"],
      "env": {
        "LECLAP_MCP_OUTPUT_DIR": "/abs/path/to/Movies/leclap-renders",
        "LECLAP_MCP_MEDIA_DIR": "/abs/path/to/Movies"
      }
    }
  }
}

From a checkout, swap the command for "command": "node" with "args": ["/abs/path/to/ffmpeg-video-composer/packages/leclap-mcp/dist/index.js"].

Then ask the agent to "compose a 10-second vertical title card with a fade-in and music, then render it" — it fetches the schema, authors a descriptor, validates it, and renders. Open the returned outputPath. Or ask it to list samples, retrieve web-app-promo, replace the copy and bind your screen recording, then validate and render.

Inspector

npx @modelcontextprotocol/inspector node packages/leclap-mcp/dist/index.js

Architecture

compose_video never runs the compile in the server process. The core logs to stdout during a render (including pino writing directly to fd 1), which would corrupt the MCP JSON-RPC stream — so the render runs in a forked child worker (dist/render-worker.js) and the result returns over the IPC channel, never the child's stdout. This also gives clean error capture (the parent buffers the worker's logs), render timeouts, and DI state isolation between renders.

compose_video returns a resource_link pointing at the rendered file rather than inlining megabytes of base64 — the client opens or fetches it. Render progress is written to stderr ([compose_video] render <id> NN%), not sent as a protocol notification: the per-request log channel is deprecated in the current revision, and stdout is reserved for JSON-RPC framing.

Security is inherited from the core: FFmpeg runs via execFile (no shell); remote template URLs are SSRF-guarded (private/metadata IPs + redirects blocked, http(s) only); descriptors are safeParse-validated; local file paths are containment-checked against the media dir. A media path that is neither an http(s) URL nor a catalog path (pictures/…, videos/…) must exist under the media dir: compose_video and render_frames reject it before rendering, naming the path and the media dir, and it is never fetched remotely.

Tests

pnpm --filter @leclap/mcp test              # vitest unit tests (mocked render)
pnpm --filter @leclap/mcp test:integration  # cucumber BDD over real stdio + a real render

The integration suite spawns the built server over stdio and renders a self-contained color-card template end to end — the regression guard proving the stdio framing survives a real (pino-heavy) compile.

Not yet (future)

Streamable HTTP transport, MCP resources (leclap://templates/{name}), client-visible progress notifications, remote-URL probing, an async job API.


Part of the LeClap monorepo.

Similar MCP servers

Official

markitdown

Convert various file formats (PDF, Word, Excel, images, audio) to Markdown.

MImicrosoft/markitdown199k876 new stars in the last 7 days

HyperFrames by HeyGen

Official HyperFrames by HeyGen: the best AI video editor in chat. Captions, motion graphics, MP4.

HEheygen-com/hyperframes94k4,558 new stars in the last 7 days

Featured

tldraw

Collaborate with agents on a canvas: draw shapes and run code live.

TLtldraw/tldraw52k101 new stars in the last 7 days

Next AI Draw.io

draw.io diagrams your AI agent draws on a live browser canvas that you can also edit by hand

DADayuanJiang/next-ai-draw-io37k125 new stars in the last 7 days

Featured

mcp-for-blender

Let your agent model, build and edit 3D scenes in Blender.

AHahujasid/mcp-for-blender37k991 new stars in the last 7 days

screenpipe

Search your local screen recordings, audio transcripts, and computer activity from screenpipe.

SCscreenpipe/screenpipe23k83 new stars in the last 7 days