Skip to main content
Glama

🎬 MoviePy MCP Server — Professional Documentation

Python Version License FastMCP MoviePy Status MCP

A production‑grade MCP (Model Context Protocol) server that exposes 40+ video editing, animation, and audio processing tools to AI agents.


📖 Table of Contents


Related MCP server: atsurae

📌 Overview

MoviePy MCP Server is a bridge between AI agents and professional video editing. Built on FastMCP and MoviePy, it provides a comprehensive suite of tools for:

  • ✂️ Video trimming, concatenation, and transformation

  • 🎨 Procedural animation generation

  • 🔊 Audio processing and mixing

  • 🖼️ Overlay composition (text, images, PiP)

  • 🧩 Custom animation with mathematical expressions

  • 🛠️ Utility functions (thumbnail, frame extraction, conversion)

All tools are exposed via the standard MCP protocol, making them callable by any MCP‑compatible client (e.g., Claude Desktop, custom agents).


🏗️ Architecture

The system is structured in layers, ensuring separation of concerns and scalability.

graph TB
    subgraph "AI Agent Layer"
        A[AI Assistant] --> B[MCP Client]
    end
    
    subgraph "MCP Server Layer"
        B --> C["FastMCP Server<br>main.py"]
        C --> D["Tool Registry<br>@mcp.tool() decorators"]
        D --> E1[Video Tools]
        D --> E2[Audio Tools]
        D --> E3[Animation Tools]
        D --> E4[Utility Tools]
    end
    
    subgraph "Core Processing Layer"
        E1 --> F[MoviePy Core]
        E2 --> F
        E3 --> F
        E4 --> F
        F --> G["FFmpeg Backend<br>via imageio-ffmpeg"]
        G --> H["Output Files<br>.mp4, .mp3, .png"]
    end
    
    subgraph "Storage Layer"
        H --> I[("moviepy_outputs/<br>uuid-named files")]
    end
    
    style A fill:#4CAF50,color:#fff
    style C fill:#2196F3,color:#fff
    style F fill:#FF9800,color:#fff
    style G fill:#9E9E9E,color:#fff

📦 Key Components

Component

Description

FastMCP

Manages the server lifecycle, tool registration, and protocol handling

MoviePy

Core video manipulation library (editing, compositing, effects)

Pillow

Image creation and rendering (for frame‑by‑frame animation)

NumPy

Fast numerical operations for pixel‑level manipulation

FFmpeg

Underlying encoder/decoder (managed by imageio‑ffmpeg)


🚀 Getting Started

✅ Prerequisites

  • Python 3.12+ (required for the project’s dependencies)

  • uv – the fast Python package installer and resolver

  • FFmpeg – installed automatically via imageio-ffmpeg, but you can also install it manually if needed.

📥 Installation

  1. Clone the repository

    git clone https://github.com/yourusername/MoviePy_MCP.git
    cd MoviePy_MCP
  2. Install dependencies

    uv sync

    This will install all dependencies defined in pyproject.toml.

  3. Verify the installation

    uv run python main.py

    You should see:

    MoviePy MCP Server
    Output directory: /path/to/moviepy_outputs
    Starting MCP server...

🧪 Quick Test

To ensure everything works, you can run a simple tool call via any MCP client. Alternatively, test the animation engine directly:

# In a Python script (or from the REPL after importing main)
from main import create_stick_figure_runner
video_path = create_stick_figure_runner(duration=3)
print(f"Video generated: {video_path}")

⚙️ Configuration

🔧 MCP Client Configuration

The server is designed to be launched by an MCP client (e.g., Claude Desktop, Cursor, etc.). Provide a configuration file similar to Config_Example.json:

{
    "MoviePy_MCP": {
        "command": "uv",
        "args": [
            "--directory",
            "/absolute/path/to/MoviePy_MCP",
            "run",
            "main.py"
        ]
    }
}

🌱 Environment Variables

Variable

Description

Default

OUTPUT_DIR

Output directory for all generated files

moviepy_outputs/

FPS

Default frames per second for new videos

30

VIDEO_CODEC

Video codec for exports

libx264

AUDIO_CODEC

Audio codec

aac

PRESET

FFmpeg preset (ultrafast, fast, medium, slow)

medium

💡 You can set these in your shell before starting the server.


🛠️ Tool Reference

All tools are exposed as MCP tools with clear parameter names, types, and docstrings. The complete list is organised by category.

🎥 Video Editing Tools

Tool

Description

Parameters

Return

get_video_info

Retrieve metadata (duration, dimensions, fps)

input_path: str

dict with video info

trim_video

Extract a segment between start and end seconds

input_path: str, start: float, end: float, output_path: str = ""

dict with status and output path

change_speed

Adjust playback speed (0.5 = slow, 2.0 = fast)

input_path: str, speed: float, output_path: str = ""

dict with status and speed applied

resize_video

Resize by scale or explicit dimensions

input_path: str, width: int = 0, height: int = 0, scale: float = 0, output_path: str = ""

dict with status and output path

rotate_video

Rotate by given angle (degrees)

input_path: str, angle: float, output_path: str = ""

dict with status and output path

mirror_video

Mirror horizontally or vertically

input_path: str, direction: str = "horizontal", output_path: str = ""

dict with status and output path

crop_video

Crop to a rectangular region (pixel coordinates)

input_path: str, x1: int, y1: int, x2: int, y2: int, output_path: str = ""

dict with status and output path

merge_videos

Concatenate multiple videos in order

input_paths: list[str], output_path: str = ""

dict with status and clip count

reverse_video

Reverse the video playback

input_video: str

str path to reversed video

loop_video

Repeat the video N times

input_video: str, loops: int = 2

str path to looped video

split_video

Split at a given time, output two files

input_video: str, split_time: float

dict with part_1 and part_2 paths

freeze_frame

Hold a specific frame for a duration

input_video: str, freeze_time: float, freeze_duration: float = 2

str path to output video

fade_video

Apply fade‑in and/or fade‑out

input_video: str, fade_in: float = 1, fade_out: float = 1

str path to output video

crossfade_videos

Crossfade between two videos

video1: str, video2: str, transition_duration: float = 1

str path to output video


✍️ Text & Overlay Tools

Tool

Description

Parameters

Return

add_text

Add text overlay to a video

input_path: str, text: str, fontsize: int = 60, color: str = "white", position: str = "center", start: float = 0, duration: float = 5, output_path: str = ""

dict with status and output path

add_image_overlay

Overlay an image on the video

input_path: str, image_path: str, x: int = 0, y: int = 0, start: float = 0, duration: float = 5, scale: float = 1.0, opacity: float = 1.0, output_path: str = ""

dict with status and output path

picture_in_picture

Place one video inside another

main_video: str, small_video: str, x: int = 20, y: int = 20, scale: float = 0.3, start: float = 0, duration: float = 0, output_path: str = ""

dict with status and output path


🔊 Audio Tools

Tool

Description

Parameters

Return

add_audio

Add or replace audio track

input_path: str, audio_path: str, volume: float = 1.0, output_path: str = ""

dict with status and output path

fade_audio

Apply audio fade‑in/out

input_path: str, fade_in: float = 0, fade_out: float = 0, output_path: str = ""

dict with status and output path

remove_audio

Strip audio from video

input_video: str

str path to silent video

replace_audio

Replace existing audio with a new file

input_video: str, audio_file: str

str path to output video

adjust_volume

Change audio volume (0.0 = mute, 2.0 = double)

input_video: str, volume: float = 1.0

str path to output video

extract_audio

Extract audio as MP3

input_video: str

str path to MP3 file


🎨 Animation & Generation Tools

Tool

Description

Parameters

Return

create_custom_animation

General‑purpose multi‑object animation engine

duration: float = 5, width: int = 1280, height: int = 720, fps: int = 30, background: str = "#101018", objects: list = None, output_name: str = "custom_animation"

str path to generated video

create_stick_figure_runner

Pre‑built animated running stick figure

duration: float = 5, width: int = 1280, height: int = 720, background: str = "#87CEEB"

str path to video

create_animated_scene

Simple animated scenes (bouncing, horizontal, orbit, pulse, etc.)

scene_type: str = "bouncing", duration: float = 5, width: int = 1280, height: int = 720, background: str = "#101018", object_color: str = "#ffffff"

str path to video

create_moving_object_video

Moving geometric shape (circle, square, triangle)

duration: float = 5, width: int = 1280, height: int = 720, object_type: str = "circle", background: str = "#111111", object_color: str = "#ffffff"

str path to video

create_particle_animation

Particle field with random motion

duration: float = 5, width: int = 1280, height: int = 720, particle_count: int = 100, background: str = "#050510"

str path to video

create_animated_text

Text with various animation styles (fade, slide, zoom)

text: str, duration: float = 5, width: int = 1280, height: int = 720, font_size: int = 80, background: str = "#000000", text_color: str = "white", animation: str = "fade"

str path to video

create_slideshow_video

Create a video from a list of images

image_paths: list, seconds_per_image: float = 3, transition: str = "fade"

str path to video

create_gradient_animation

Animated moving colour gradient

duration: float = 5, width: int = 1280, height: int = 720

str path to video

create_countdown_video

Countdown from N to 1

seconds: int = 5, width: int = 1280, height: int = 720, background: str = "#000000"

str path to video

create_typing_text_video

Typewriter‑style text appearance

text: str, duration: float = 5, width: int = 1280, height: int = 720, font_size: int = 60

str path to video

create_bouncing_object

Physics‑based bouncing ball animation

duration: float = 5, width: int = 1280, height: int = 720, gravity: float = 900

str path to video

create_progress_bar_video

Animated progress/loading bar

duration: float = 5, width: int = 1280, height: int = 720

str path to video

create_background

Solid colour video background

width: int = 1280, height: int = 720, duration: float = 5, r: int = 0, g: int = 0, b: int = 0, output_path: str = ""

dict with status and output path

create_text_video

Complete video with centred text

text: str, duration: float = 5, width: int = 1280, height: int = 720, fontsize: int = 80, text_color: str = "white", background_color: tuple[int, int, int] = (0, 0, 0), output_path: str = ""

dict with status and output path


🛠️ Utility Tools

Tool

Description

Parameters

Return

export_video

Re‑encode video with quality preset

input_path: str, output_path: str = "", fps: int = 30, quality: str = "medium"

dict with status and output path

create_thumbnail

Extract a frame as PNG

input_video: str, time: float = 0

str path to PNG

extract_frame

Extract a specific frame as PNG

input_video: str, time: float

str path to PNG

zoom_animation

Smooth zoom‑in effect

input_video: str, zoom_amount: float = 1.3

str path to output video

pan_animation

Pan across the video (left/right/up/down)

input_video: str, direction: str = "left"

str path to output video


📊 Workflow Diagrams

General Video Editing Pipeline

flowchart TD
    A[Start] --> B[Load Input Video]
    B --> C{Choose Operation}
    C -->|Trim| D[Set start/end]
    C -->|Speed| E[Set speed factor]
    C -->|Resize| F[Set new dimensions]
    C -->|Rotate| G[Set angle]
    C -->|Merge| H[Load multiple videos]
    C -->|Overlay| I[Add text/image]
    D --> J[Process with MoviePy]
    E --> J
    F --> J
    G --> J
    H --> J
    I --> J
    J --> K[Write output with FFmpeg]
    K --> L[Save to moviepy_outputs/]
    L --> M[Return file path]

Custom Animation Rendering

flowchart LR
    subgraph Input
        A[Object definitions]
        B[Duration, resolution, fps]
        C[Background colour]
    end
    
    subgraph Processing
        D[Parse object list]
        E[For each frame t]
        F[Evaluate expressions<br/>with t]
        G[Render each object<br/>on a PIL canvas]
        H[Composite all objects]
        I[Convert to NumPy array]
    end
    
    subgraph Output
        J[Create MoviePy VideoClip]
        K[FFmpeg encoding]
        L[Output .mp4 file]
    end
    
    A --> D
    B --> D
    C --> D
    D --> E
    E --> F
    F --> G
    G --> H
    H --> I
    I --> J
    J --> K
    K --> L

Animation Expression Evaluation

flowchart TD
    A["Expression String<br>e.g., '300 + 100*sin(t*4)'"] --> B[AST Parse]
    B --> C{Safe?}
    C -->|Yes| D[Evaluate with t]
    C -->|No| E[Raise ValueError]
    D --> F[Return numeric value]
    
    subgraph "Allowed Functions & Operators"
        G[+, -, *, /, **, %]
        H[sin, cos, tan, abs, sqrt]
        I[min, max, pi]
    end
    
    F --> G
    F --> H
    F --> I

💡 Examples

🎬 1. Create a Full Animated Scene

result = create_custom_animation(
    duration=5,
    width=1280,
    height=720,
    background="#1a1a2e",
    objects=[
        {
            "type": "circle",
            "x": {"expression": "640 + 300*sin(t*2)"},
            "y": {"expression": "360 + 200*cos(t*1.5)"},
            "radius": 40,
            "color": "#ff6b6b",
            "rotation": {"expression": "t*60"}
        },
        {
            "type": "rectangle",
            "x": {"expression": "640 + 200*cos(t*3)"},
            "y": {"expression": "360 + 150*sin(t*2.5)"},
            "width": 80,
            "height": 80,
            "color": "#4ecdc4",
            "rotation": {"expression": "t*90"}
        },
        {
            "type": "text",
            "text": "🎬 AI Animation",
            "x": 640,
            "y": 80,
            "font_size": 64,
            "color": "#ffffff"
        }
    ]
)
print(f"Video saved to: {result}")

🏃 2. Generate a Stick Figure Running

video = create_stick_figure_runner(
    duration=4,
    width=800,
    height=600,
    background="#a8d8ea"
)

✂️ 3. Edit an Existing Video

# Trim, speed up, and add a watermark
info = get_video_info("input.mp4")
trimmed = trim_video("input.mp4", start=10, end=30)
fast = change_speed(trimmed["output"], speed=1.5)
watermarked = add_text(
    fast["output"],
    text="© 2026 My Studio",
    fontsize=40,
    color="white",
    position=("right", "bottom")
)

🔊 4. Extract and Process Audio

# Extract audio, then add it back with volume boost
audio_path = extract_audio("video.mp4")
video_with_audio = add_audio("video.mp4", audio_path, volume=1.8)

🖼️ 5. Picture‑in‑Picture

result = picture_in_picture(
    main_video="presentation.mp4",
    small_video="speaker.mp4",
    x=20,
    y=20,
    scale=0.25
)

🧪 Performance & Benchmarks

Tests were performed on a MacBook Pro M1, 16GB RAM with SSD storage. Average times for common operations:

Operation

Duration

File Size (approx)

CPU Usage

Trim 10‑sec segment

2.1 s

5.2 MB

~80%

Change speed (2×)

2.8 s

3.0 MB

~85%

Resize 720p → 480p

3.0 s

2.1 MB

~75%

Rotate 90°

3.5 s

6.0 MB

~80%

Merge two 10‑sec clips

4.2 s

10.5 MB

~90%

Add text overlay

2.5 s

5.8 MB

~70%

Custom animation (5 sec, 3 objects)

5.0 s

4.0 MB

~95%

Particle animation (100 particles)

4.5 s

3.5 MB

~90%

Note: Times depend on input file size, codec, and system load. The server uses libx264 with medium preset by default.


⚠️ Error Handling

The server implements robust error checking:

  • File Existence: All input_path parameters are validated before processing.

  • Invalid Parameters: Type and range checks (e.g., positive duration, non‑zero speed) raise descriptive ValueError.

  • Audio Presence: Audio‑related tools will fail gracefully if the video has no audio track.

  • Expression Safety: Animation expressions are parsed with ast and a whitelist of functions/operators to prevent arbitrary code execution.

  • Output Directory: The moviepy_outputs/ directory is created automatically.

All errors are returned as structured MCP error responses (or raised as exceptions during tool execution).


🤝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository.

  2. Create a feature branch (git checkout -b feature/your-feature).

  3. Commit your changes with clear messages.

  4. Push to the branch (git push origin feature/your-feature).

  5. Open a Pull Request against the main branch.

🧑‍💻 Development Setup

⚡ TL;DR

# Clone your fork


git clone https://github.com/yourusername/MoviePy_MCP.git
cd MoviePy_MCP

# Install with dev dependencies
uv sync 

#Run Main.py script
uv run main.py


📄 License

This project is licensed under the MIT License – see the LICENSE file for details.


Made with ❤️ by Sahil Kumar

⬆ Back to Top

Available Tools

42 tools
add_audioC

Add or replace the audio track of a video.

Inputs: audio_path (required), input_path (required), volume, output_path. Returns: object

add_image_overlayC

Add an image on top of a video.

Inputs: image_path (required), input_path (required), x, y, +5 more. Returns: object

add_textC

Add text overlay to a video.

Inputs: text (required), input_path (required), color, start, +4 more. Returns: object

adjust_volumeB

Change video's audio volume.

1.0 = original 0.5 = half volume 2.0 = double volume 0.0 = mute

Inputs: input_video (required), volume.

change_speedB

Change video playback speed.

speed: 0.5 = slow motion 1.0 = normal 2.0 = 2x faster

Inputs: speed (required), input_path (required), output_path. Returns: object

create_animated_sceneB

Create a procedural animated video completely from scratch.

scene_type:

  • bouncing

  • horizontal

  • vertical

  • diagonal

  • orbit

  • pulse

Useful when the user asks for a simple animated scene without providing source footage.

Inputs: width, height, duration, background, +2 more.

create_animated_textC

Create an animated text video.

animation:

  • fade

  • slide_left

  • slide_right

  • slide_up

  • slide_down

  • zoom

Inputs: text (required), width, height, duration, +4 more.

create_backgroundC

Create a solid-color video background.

Inputs: b, g, r, width, +3 more. Returns: object

create_bouncing_objectC

Create a physics-inspired bouncing ball animation.

Inputs: width, height, gravity, duration.

create_countdown_videoC

Create a countdown animation.

Inputs: width, height, seconds, background.

create_custom_animationA

Create a complete multi-object animated video from scratch.

This is a general-purpose procedural animation engine.

Multiple objects can exist in the same scene.

Supported object types: circle rectangle line triangle ellipse text

Every object can independently animate: x y rotation scale opacity size

Animation values can use expressions involving: t sin() cos() tan() abs() sqrt() pi()

Example:

{ "type": "circle", "x": { "expression": "300 + 100sin(t4)" }, "y": 300, "radius": 40, "color": "#ffffff" }

Objects are rendered in list order. Later objects appear on top of earlier objects.

This allows complex scenes such as: stick figures cars rockets planets bouncing balls animated logos simple characters UI animations kinetic typography

Inputs: fps, width, height, objects, +3 more.

create_gradient_animationC

Generate an animated moving gradient video.

Inputs: width, height, duration.

create_moving_object_videoC

Create a video with a moving geometric object.

object_type: circle, square, triangle

Inputs: width, height, duration, background, +2 more.

create_pan_animationC

Create a camera-like pan across an oversized video.

direction: left, right, up, down

Inputs: input_video (required), direction.

create_particle_animationC

Create an animated particle field from scratch.

Inputs: width, height, duration, background, +1 more.

create_progress_bar_videoC

Create an animated loading/progress bar.

Inputs: width, height, duration.

create_slideshow_videoB

Create a video slideshow from image files.

image_paths: list of image paths. transition:

  • fade

  • none

Inputs: image_paths (required), transition, seconds_per_image.

create_stick_figure_runnerA

Create a complete animated stick-figure running scene.

Includes: head body left arm right arm left leg right leg ground shadow

The complete character is created from multiple independently animated shapes.

Inputs: width, height, duration, background.

create_text_videoC

Create a complete video containing centered text.

Inputs: text (required), width, height, duration, +4 more. Returns: object

create_thumbnailC

Extract a frame from a video and save it as PNG.

Inputs: input_video (required), time.

create_typing_text_videoC

Create a typing-machine style text animation.

Inputs: text (required), width, height, duration, +1 more.

create_zoom_animationC

Apply a smooth zoom-in effect to a video.

Inputs: input_video (required), zoom_amount.

crop_videoB

Crop a video using pixel coordinates.

Inputs: x1 (required), x2 (required), y1 (required), y2 (required), +2 more. Returns: object

crossfade_videosC

Crossfade from one video into another.

Inputs: video1 (required), video2 (required), transition_duration.

export_videoC

Export a video as MP4.

quality: ultrafast fast medium slow

Inputs: input_path (required), fps, quality, output_path. Returns: object

extract_audioC

Extract audio from a video.

Inputs: input_video (required).

extract_frameC

Extract a specific video frame as PNG.

Inputs: time (required), input_video (required).

fade_audioC

Apply audio fade-in and/or fade-out.

Inputs: input_path (required), fade_in, fade_out, output_path. Returns: object

fade_videoB

Apply video fade-in and fade-out.

Inputs: input_video (required), fade_in, fade_out.

freeze_frameC

Freeze a selected frame and hold it for a duration.

Inputs: freeze_time (required), input_video (required), freeze_duration.

get_video_infoB

Get basic information about a video.

Returns:

  • duration

  • width

  • height

  • fps

Inputs: input_path (required). Returns: object

loop_videoC

Repeat a video multiple times.

Inputs: input_video (required), loops.

merge_videosC

Concatenate multiple videos sequentially.

Inputs: input_paths (required), output_path. Returns: object

mirror_videoB

Mirror a video horizontally or vertically.

Inputs: input_path (required), direction, output_path. Returns: object

picture_in_pictureC

Put one video on top of another video.

Inputs: main_video (required), small_video (required), x, y, +4 more. Returns: object

remove_audioC

Remove audio from a video.

Inputs: input_video (required).

replace_audioC

Replace the video's existing audio.

Inputs: audio_file (required), input_video (required).

resize_videoC

Resize a video.

Use either: width + height OR: scale

Example: scale=0.5 scale=2

Inputs: input_path (required), scale, width, height, +1 more. Returns: object

reverse_videoC

Reverse a video.

Inputs: input_video (required).

rotate_videoC

Rotate a video by the specified angle.

Inputs: angle (required), input_path (required), output_path. Returns: object

split_videoC

Split a video into two separate files.

Inputs: split_time (required), input_video (required).

trim_videoC

Trim a video between start and end seconds.

Inputs: end (required), start (required), input_path (required), output_path. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.7/5.0

    Scored across 42 tools

    Disambiguation2/5

    Several tools blur together: add_audio explicitly includes 'add or replace', overlapping with replace_audio; create_thumbnail and extract_frame both save a PNG frame; and create_custom_animation is a general-purpose engine that can reproduce many dedicated generators like create_bouncing_object, create_animated_scene, and create_animated_text. The editing tools are mostly distinct, but the creation tools have serious boundary confusion.

    Naming Consistency4/5

    The vast majority of tools follow a clean snake_case verb_noun pattern: create_, add_, get_, trim_, resize_, merge_, etc. The only notable deviation is picture_in_picture, which uses a noun phrase without a leading verb, but overall the naming is predictable and consistent.

    Tool Count2/5

    42 tools is well beyond the well-scoped range for an MCP server. Many of the creation tools are highly redundant template variations that could be consolidated into a smaller set, especially since create_custom_animation already provides generalized procedural animation.

    Completeness4/5

    The server covers a broad video editing lifecycle: importing/inspecting video, trimming, splitting, merging, transforming, audio editing, overlays, effects, and export. Minor gaps like color filters, subtitle support, or additional export formats exist, but most common video editing workflows are supported without dead ends.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers