
Manim
STDIODocker-based environment for creating mathematical animations with Manim featuring CLI and API interfaces.
Docker-based environment for creating mathematical animations with Manim featuring CLI and API interfaces.
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.
This project provides:
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
Clone the repository:
git clone https://github.com/YOUR_USERNAME/manim-docker-mcp.git cd manim-docker-mcp
Build the Docker images:
docker compose build
Create a Python file in the animations
directory (see example below), then run:
docker compose run manim -pql animations/example.py ExampleScene
Start the API server:
docker compose up -d manim-api
Access the API documentation at http://localhost:8000/docs
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()
# 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"
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
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 |
-p
: Preview the output file-t
: Transparent background--save_last_frame
: Render only the last frame-c COLOR
: Set background colorGET /list-files?directory=/manim
POST /write-file?filepath=/manim/temp/example.py
POST /run-manim?filepath=/manim/temp/example.py&scene_name=CircleToSquare
GET /download-file?filepath=/media/videos/example/480p15/CircleToSquare.mp4
Full API documentation is available at the /docs
endpoint.
This project supports the Model Context Protocol (MCP), enabling AI assistants to:
Example MCP session:
User: Create an animation showing a circle morphing into a square
AI: I'll create that for you...
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))
Modify the docker-compose.yml
file to mount additional directories:
volumes: - ./my_custom_dir:/manim/custom
If you encounter issues:
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.