Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

manim-mcp

MCP.Pizza Chef: wstcpyt

manim-mcp is a Dockerized server providing a reproducible environment to create mathematical animations using Manim. It exposes a web API with Model Context Protocol (MCP) integration, enabling AI assistants to interact directly for animation creation and management. Features include CLI and REST API interfaces, script upload, and animation download, making it ideal for automated math visualization workflows.

Use This MCP server To

Generate mathematical animations via HTTP API calls Integrate AI assistants to create and modify Manim scripts Upload custom Manim scripts for rendering animations Download rendered animations for presentations or educational content Automate math animation generation in AI-enhanced workflows Use containerized Manim environment for consistent rendering results

README

Manim MCP

License: Apache 2.0 Docker Manim API

A Docker-based environment for creating mathematical animations with Manim, featuring both a CLI interface and a web API with Model Context Protocol (MCP) support for AI assistants.

πŸ“‘ Overview

This project provides:

  1. Containerized Manim Environment: Run Manim in an isolated, reproducible Docker environment
  2. Web API: Create and manage Manim animations via HTTP requests
  3. MCP Integration: Direct interaction with AI assistants like Claude
  4. File Management: Upload scripts and download generated animations

πŸš€ Quick Start

Prerequisites

  • Docker and Docker Compose installed on your system

Installation

Option 1: Use the Prebuilt Image (Recommended)

Simply pull the prebuilt image from Docker Hub:

docker pull wstcpyt/manim-docker-mcp:latest

Then run it with docker-compose:

docker compose up -d

Option 2: Build Locally

  1. Clone the repository:

    git clone https://github.com/YOUR_USERNAME/manim-docker-mcp.git
    cd manim-docker-mcp
  2. Build the Docker images:

    docker compose build

Usage

CLI Mode

Create a Python file in the animations directory (see example below), then run:

docker compose run manim -pql animations/example.py ExampleScene

API Mode

Start the API server:

docker compose up -d manim-api

Access the API documentation at http://localhost:8000/docs

🎬 Creating Animations

Basic Example

Create a file animations/example.py:

from manim import *

class CircleToSquare(Scene):
    def construct(self):
        circle = Circle()
        circle.set_fill(BLUE, opacity=0.5)

        square = Square()
        square.set_fill(RED, opacity=0.5)

        self.play(Create(circle))
        self.wait()
        self.play(Transform(circle, square))
        self.wait()

Running the Animation

# CLI mode with preview (-p), low quality (-ql)
docker compose run manim -pql animations/example.py CircleToSquare

# API mode
curl -X POST "http://localhost:8000/run-manim?filepath=/manim/temp/circle_example.py&scene_name=CircleToSquare&quality=low_quality"

πŸ“‚ Project Structure

manim-docker-mcp/
β”œβ”€β”€ animations/           # Manim animation scripts
β”œβ”€β”€ app/                  # FastAPI application
β”œβ”€β”€ media/                # Generated animations (CLI mode)
β”œβ”€β”€ output/               # Generated animations (API mode)
β”œβ”€β”€ temp/                 # Temporary files
β”œβ”€β”€ uploads/              # Uploaded animation scripts
β”œβ”€β”€ Dockerfile            # Docker image definition
β”œβ”€β”€ docker-compose.yml    # Docker Compose configuration
└── README.md             # This file

πŸ”§ Configuration

Quality Settings

Flag Resolution Frame Rate Best For
-ql 480p 15fps Quick previews
-qm 720p 30fps General use
-qh 1080p 60fps Presentations
-qk 1440p 60fps Production videos

Other Useful Flags

  • -p: Preview the output file
  • -t: Transparent background
  • --save_last_frame: Render only the last frame
  • -c COLOR: Set background color

🌐 API Documentation

Core Endpoints

List Files

GET /list-files?directory=/manim

Write File

POST /write-file?filepath=/manim/temp/example.py

Run Animation

POST /run-manim?filepath=/manim/temp/example.py&scene_name=CircleToSquare

Download Animation

GET /download-file?filepath=/media/videos/example/480p15/CircleToSquare.mp4

Full API documentation is available at the /docs endpoint.

πŸ€– AI Assistant Integration (MCP)

This project supports the Model Context Protocol (MCP), enabling AI assistants to:

  1. Create Manim scripts based on natural language descriptions
  2. Run animations and provide download links
  3. Browse and manage generated media files

Example MCP session:

User: Create an animation showing a circle morphing into a square
AI: I'll create that for you...

πŸ” Advanced Usage

Custom LaTeX

The container includes a minimal LaTeX installation. Custom LaTeX can be used in animations:

formula = MathTex(r"\int_{a}^{b} f(x) \, dx = F(b) - F(a)")
self.play(Write(formula))

Mounting Custom Directories

Modify the docker-compose.yml file to mount additional directories:

volumes:
  - ./my_custom_dir:/manim/custom

πŸ› οΈ Troubleshooting

Common Issues

  • Docker not running: Make sure Docker daemon is running
  • Permission errors: The container needs write access to mounted volumes
  • Missing media: Check the correct output directory (media/ for CLI, output/ for API)

Getting Help

If you encounter issues:

  1. Check the Manim documentation
  2. Search existing GitHub issues
  3. Create a new issue with details about your problem

πŸ“œ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ™ Acknowledgements

  • Manim Community for the amazing animation engine
  • FastAPI for the web framework
  • Model Context Protocol for AI integration

manim-mcp FAQ

How do I deploy the manim-mcp server?
Deploy by running the provided Docker container with Docker Compose for an isolated environment.
Can I upload my own Manim scripts?
Yes, the server supports uploading custom Manim scripts via its API for rendering.
How does MCP integration benefit animation workflows?
MCP allows AI assistants like Claude to interact directly with the server to generate and manage animations programmatically.
What interfaces does manim-mcp provide?
It offers both a CLI interface and a RESTful web API for flexible interaction.
Is the environment reproducible across different systems?
Yes, the Docker container ensures consistent and isolated Manim execution on any host.
Can I download animations after rendering?
Yes, the server supports downloading generated animations through its API.
What prerequisites are needed to run manim-mcp?
Docker and Docker Compose must be installed on your system to run the containerized server.
Does manim-mcp support real-time animation generation?
While primarily designed for batch rendering, API calls can be automated for near real-time workflows.