capcut-mcp

mcp
Guvenlik Denetimi
Uyari
Health Uyari
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 5 GitHub stars
Code Gecti
  • Code scan — Scanned 2 files during light audit, no dangerous patterns found
Permissions Gecti
  • Permissions — No dangerous permissions requested

Bu listing icin henuz AI raporu yok.

SUMMARY

Direct AI manipulation of CapCut project files via Model Context Protocol. A local tool for AI agents built with Elixir and OTP.

README.md
  ____    _    ____   ____ _   _ _____   __  __  ____ ____  
 / ___|  / \  |  _ \ / ___| | | |_   _| |  \/  |/ ___|  _ \ 
| |     / _ \ | |_) | |   | | | | | |   | |\/| | |   | |_) |
| |___ / ___ \|  __/| |___| |_| | | |   | |  | | |___|  __/ 
 \____/_/   \_\_|    \____|\___/  |_|   |_|  |_|\____|_|    

An MCP (Model Context Protocol) server for CapCut, written in Elixir. Lets Claude read and edit CapCut projects directly -- no CapCut API needed. Works by reading and writing CapCut's local JSON project files.

Built just for fun in a "crazy" language. Elixir/OTP with GenServers, supervision trees, pattern matching and pipes everywhere.

What it does

Claude gets 19 tools to work with your CapCut projects:

Read & Inspect

Tool What Claude can do
list_projects Show all your CapCut drafts
get_project Inspect canvas size, FPS, duration, track count
get_timeline See all tracks, clips, and their timecodes
read_draft_json Return the full raw project JSON for debugging

Create, Remove & Add

Tool What Claude can do
create_project Create a new empty draft (custom size/FPS)
remove_project Delete a draft (list entry + folder, or only the entry)
add_text Add a text overlay at a specific time
add_clip Add a video or audio file to the timeline (validates file exists)

Modify Clips

Tool What Claude can do
set_clip_transform Position, scale, and rotate a clip
set_clip_opacity Set clip transparency (0.0 -- 1.0)
set_clip_volume Mute, normalize, or boost clip audio
set_clip_loop Enable/disable clip looping
set_clip_blend_mode Apply blend modes (Screen, Soft Light, Multiply, ...) from your local CapCut install
move_clip Reposition a clip on the timeline
trim_clip Set source in/out points and timeline duration
remove_clip Remove a clip by its segment ID
set_clip_keyframe Animate position, scale, rotation, opacity, colour or volume over time (one call per keyframe)

Text Animations

Tool What Claude can do
add_text_animation Give a text clip an intro/outro (fade, slide, blur, typewriter)
list_text_animations List the available animations and their default lengths

Example prompts once connected:

  • "List my CapCut projects"
  • "Add the text 'Intro' to project X at 0ms for 3 seconds"
  • "Show me the timeline of my latest project"
  • "Create a new 1080x1920 vertical project called 'Reel'"
  • "Set the screen recording clip to Screen blend mode"
  • "Move clip X to 5 seconds and set its opacity to 0.8"
  • "Mute the video on track 2 and loop the mascot clip"
  • "Fade the title in and let it fade out at the end"
  • "Let the logo slide up from below the frame during the first half second"

Requirements

  • Windows (projects in %LOCALAPPDATA%\CapCut\User Data\Projects\com.lveditor.draft) or macOS (projects in ~/Movies/CapCut/User Data/Projects/com.lveditor.draft)
  • Erlang/OTP 28 and Elixir 1.19+ (see Installation)
  • CapCut desktop app installed

Installation

Windows

1. Install Erlang OTP (if not already installed):

winget install Erlang.ErlangOTP

2. Install Elixir (no winget package -- download the zip):

(New-Object Net.WebClient).DownloadFile(
  'https://github.com/elixir-lang/elixir/releases/download/v1.19.5/elixir-otp-28.zip',
  "$env:USERPROFILE\elixir.zip"
)
Expand-Archive "$env:USERPROFILE\elixir.zip" -DestinationPath "$env:USERPROFILE\elixir"
[Environment]::SetEnvironmentVariable(
  'PATH',
  [Environment]::GetEnvironmentVariable('PATH','User') + ";$env:USERPROFILE\elixir\bin",
  'User'
)

macOS

brew install elixir

Both: clone and build

git clone https://github.com/burnshall-ui/capcut-mcp.git
cd capcut-mcp
mix deps.get

Then build the release -- the recommended way to run the server. It starts in about a second, never recompiles, and several instances can run side by side (MCP clients sometimes start two). Re-run it after every git pull.

# macOS / Linux
MIX_ENV=prod mix release --overwrite
# Windows (PowerShell)
$env:MIX_ENV="prod"; mix release --overwrite; Remove-Item Env:MIX_ENV

The start scripts start-mcp.sh (macOS) and start-mcp.bat (Windows) use the release if it exists and otherwise fall back to mix run --no-halt. Without a release, run mix compile once first so the first start doesn't print compiler output where the client expects JSON.

Smoke test (macOS; on Windows pipe into start-mcp.bat):

echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | ./start-mcp.sh

Expected: a JSON response with "name":"capcut-mcp", and the server exits once the input ends.

Connecting to Claude

Point your MCP client at the start script. Neither script needs editing -- they find the project folder from their own location.

Claude Desktop

Add the server to claude_desktop_config.json (Windows: %APPDATA%\Claude\, macOS: ~/Library/Application Support/Claude/):

{
  "mcpServers": {
    "capcut": {
      "command": "C:\\Users\\<you>\\capcut-mcp\\start-mcp.bat"
    }
  }
}

On macOS use "command": "/Users/<you>/capcut-mcp/start-mcp.sh". Restart Claude Desktop.

Claude Code

# macOS
claude mcp add capcut -- /Users/<you>/capcut-mcp/start-mcp.sh

# Windows (cmd /c lets Claude Code run the .bat file)
claude mcp add capcut -- cmd /c C:\Users\<you>\capcut-mcp\start-mcp.bat

Or check it into a project as .mcp.json:

{
  "mcpServers": {
    "capcut": {
      "command": "/Users/<you>/capcut-mcp/start-mcp.sh"
    }
  }
}

Tip: close a project in CapCut before Claude edits it. CapCut keeps an open project in memory and can overwrite Claude's changes when it saves.

Configuration

CapcutMcp.CapCut.PathDiscovery auto-discovers the CapCut projects folder. It checks, in order:

  1. The CAPCUT_PATH environment variable
  2. %LOCALAPPDATA%\CapCut\User Data\Projects\com.lveditor.draft -- the standard Windows location
  3. ~/Movies/CapCut/User Data/Projects/com.lveditor.draft -- the standard macOS location

If none resolves to an existing directory, the server still boots. The first tool call that needs disk access returns a descriptive error listing what was tried, so Claude can relay it back to you verbatim.

Override the discovered path (e.g. for a portable install) with CAPCUT_PATH, for example in the env block of the MCP config:

"env": { "CAPCUT_PATH": "D:\\CapCut\\Projects\\com.lveditor.draft" }

Blend mode discovery reads MixMode.json from CapCut's app resources: on Windows from %LOCALAPPDATA%\CapCut\Apps\<newest version>\Resources\MixMode, on macOS from /Applications/CapCut.app/Contents/Resources/MixMode. If CapCut lives elsewhere, set CAPCUT_APPS_PATH to the Apps folder (Windows) or the bundle's Resources folder (macOS). Only set_clip_blend_mode needs this.

Windows CapCut stores a project's timeline in draft_content.json, macOS CapCut in draft_info.json. The server reads and writes whichever file the project list (root_meta_info.json) names for that project.

Architecture

Claude (stdin/stdout JSON-RPC 2.0)
  └── MCP.Server          GenServer -- stdin loop, dispatches messages
        └── MCP.Dispatcher  Pure -- routes tool calls by name
              └── Tools.*       Pure -- one module per tool (19 tools)
                    ├── TimelineHelper   Shared -- segment lookup, validation, UUID
                    ├── BlendModes       ETS-cached -- discovers CapCut MixMode resources
                    └── ProjectStore     GenServer -- project cache + disk I/O
                          ├── PathDiscovery  Pure -- resolves projects root (env / LOCALAPPDATA / ~/Movies)
                          ├── Reader         Pure -- reads JSON files, picks the draft file
                          └── Writer         Pure -- writes JSON files (atomic + backup)

OTP supervision tree:

CapcutMcp.Application
  ├── CapCut.ProjectStore      (permanent)
  └── MCP.Supervisor           (rest_for_one)
        ├── MCP.Server         (permanent)
        └── MCP.StdinReader    (transient)

If a process crashes, its supervisor restarts it. When the client closes stdin, the server stops the whole VM cleanly (exit status 0). The ProjectStore caches parsed project JSON in ETS with read-through loading; a cached draft is only used while its file on disk is unchanged, so edits saved in CapCut are picked up instead of being overwritten. BlendModes caches MixMode.json in an ETS table after the first read.

Every write to a draft file or to root_meta_info.json first copies the old version to .bak and uses an atomic rename (write .tmp -> rename) to prevent corruption if the process is killed mid-write. create_project never reuses an existing folder and refuses to touch a project list it cannot parse.

Observability

Every tools/call goes through :telemetry.span/3 in CapcutMcp.MCP.Dispatcher, so duration and outcome are exposed as structured events — no custom logging plumbing in individual tools. The two core subsystems (ProjectStore cache and BlendModes loader) emit their own events too, and the boundary-hardening pass (Reader path-trust check) emits its own rejection event, so a single telemetry handler can answer "which tool was slow, was it cache-bound or disk-bound, and did any corrupt metadata get filtered on the way in?".

Emitted events:

Event Measurements Metadata
[:capcut_mcp, :tool, :execute, :start] :system_time, :monotonic_time :tool, :request_id
[:capcut_mcp, :tool, :execute, :stop] :duration, :monotonic_time :tool, :request_id, :result, :reason?
[:capcut_mcp, :tool, :execute, :exception] :duration, :monotonic_time :tool, :request_id, :kind, :reason, :stacktrace
[:capcut_mcp, :cache, :hit] :count (always 1) :id
[:capcut_mcp, :cache, :miss] :count (always 1) :id
[:capcut_mcp, :cache, :write] :count (always 1) :id, :reason (:load | :update | :create)
[:capcut_mcp, :blend_modes, :load] :duration :result (:ok | :error), :count?, :path?, :reason?
[:capcut_mcp, :draft, :schema_version] :count (always 1) :version (String.t() | nil), :supported (boolean)
[:capcut_mcp, :meta, :rejected] :count (always 1) :reason (:path_outside_root), :path (String.t())

A default log handler in CapcutMcp.Telemetry is attached on boot and prints one line per tool call to stderr (stdout belongs to the protocol), e.g.:

12:34:56.789 [info] request_id=42 tool=add_text result=ok duration=8.24ms

Claude Desktop collects stderr in its MCP log (mcp-server-capcut.log in Claude's logs folder). Logger.metadata is populated early in the pipeline (request_id, and tool inside a tool call), so every log line further down the stack -- including inside individual tools -- is tagged with its request.

Errors raised by a tool ("Segment not found", "Invalid start_ms") are returned as a normal result with isError: true, so Claude sees the message and can correct its call. Unknown tools and missing or malformed arguments are JSON-RPC errors.

[:capcut_mcp, :draft, :schema_version] fires on every successful read_draft and additionally triggers a Logger.warning when the draft's new_version field is missing or not in CapcutMcp.CapCut.Reader.supported_versions/0 — the server still reads the draft, it just flags that the on-disk schema is untested.

[:capcut_mcp, :meta, :rejected] fires when list_projects encounters a root_meta_info.json entry whose draft_fold_path resolves outside the configured CAPCUT_PATH. The entry is dropped from the response (so tool callers can't be tricked into reading or writing arbitrary files through a corrupt/malicious meta file), and a Logger.warning is emitted alongside the telemetry event.

The cache and blend-modes events are emitted but not logged by default (they're chatty on hit paths). Attach your own handler if you want a running hit-rate or a disk-load audit trail:

:telemetry.attach_many(
  "my-cache-counter",
  [
    [:capcut_mcp, :cache, :hit],
    [:capcut_mcp, :cache, :miss]
  ],
  fn [_, _, kind], _measurements, _metadata, _cfg ->
    :counters.add(my_counter_ref, kind_to_idx(kind), 1)
  end,
  nil
)

To pipe events into Prometheus, OpenTelemetry, Datadog, etc., attach your own handler; the application code does not need to change.

Development

# Run tests
mix test

# Code style (strict)
mix credo --strict

# Static analysis (first run builds PLT, ~1-2 min)
mix dialyzer

# Coverage (HTML report at cover/excoveralls.html)
mix coveralls          # console summary
mix coveralls.html     # full HTML report

# Format check
mix format --check-formatted

# Build the release used by the start scripts
MIX_ENV=prod mix release --overwrite

# Run with a custom CapCut path
CAPCUT_PATH="C:/path/to/projects" mix run --no-halt

# Interactive Elixir shell with the app running
iex -S mix run --no-halt

Known Limitations

  • Export/render -- not possible via this server (CapCut has no CLI for export; only UI automation could do it)
  • Cloud projects -- only local drafts are accessible
  • Effects and templates -- can reference CapCut's built-in effect IDs but can't create new ones; the exact IDs vary by CapCut version
  • Open projects -- CapCut can overwrite changes to a project that is open in its editor when it saves; close the project first
  • Media length -- add_clip does not read the file's real length; the clip length you give (default 5 s) is also stored as the source length
  • Keyframes and text animations -- follow the JSON that pyCapCut writes; not yet verified in a real CapCut install
  • macOS -- reading and editing existing projects is supported; whether CapCut for macOS opens projects created by create_project is untested (the project-list schema was captured on Windows)
  • CapCut format changes -- CapCut updates may change the JSON schema; tested against v8.3.0 on Windows

Tech Stack

  • Elixir 1.19 / OTP 28 -- because why not
  • Jason -- JSON encode/decode
  • :telemetry -- structured events for every tool call
  • Credo (--strict) -- zero issues
  • Dialyzer (:underspecs, :error_handling, :unknown) -- zero warnings
  • ExUnit -- 255 tests + 15 stream_data property tests + 12 doctests (incl. JSON-RPC integration tests with telemetry assertions on tools + cache + blend-modes + schema-version + meta-rejected events, path-discovery fallbacks, a boundary fuzz test that hammers every registered tool with random StreamData.term() arguments, timeline-mutation invariants like update_segment roundtrip, ensure_timerange idempotency and insert_segment count preservation, and a latin1-stdio regression test for the UTF-8 transport)
  • StreamData -- property-based tests for TimelineHelper (UUID format, segment roundtrip, track insertion invariants, validate_timing domain) and for the tools/call request boundary (no random payload may crash the dispatcher)
  • ExCoveralls -- ~90% line coverage on application code (remaining gaps are the stdin-loop I/O layer and a few lazy disk helpers)

Credits

  • Text animation IDs and the keyframe/animation JSON layout come from pyCapCut.
  • The fork MadeByAdi/capcut-mcp-full found the stdio encoding bug and the missing clip object on text; its work on macOS support, the release setup, keyframes and text animations was adapted here.

Yorumlar (0)

Sonuc bulunamadi