GitHub Stars
1
User Rating
Not Rated
Forks
0
Issues
0
Views
0
Favorites
0
Manim MCP Server โ FULLY FUNCTIONAL
A Model Context Protocol (MCP) server that enables AI assistants to create and render mathematical animations using Manim.
๐ Status: Complete & Working
This MCP server successfully provides a complete animation workflow from script creation to video playback through a standardized MCP interface with beautiful web client.
โจ Features
- โ MCP Protocol Compliant: Full stdio-based MCP server implementation
- โ Web Interface: Beautiful browser-based client for script editing and rendering
- โ Animation Pipeline: Complete workflow from script creation to video playback
- โ Video Serving: Direct video playback in browser
- โ Multiple Tools: 6 MCP tools for comprehensive animation workflow
- โ Error Handling: Robust error management and logging
- โ Quality Options: Multiple rendering quality settings
๐ Quick Start
1. Start the MCP Bridge
python mcp_bridge.py
2. Open Web Client
Go to http://localhost:8002 in your browser
3. Create Animation
- Paste Manim code in the editor
- Set scene name and quality
- Click "Render Animation"
- Watch your animation appear!
๐งช Test Complete Workflow
python test_complete_workflow.py
Output:
๐ Starting Manim MCP Server Complete Workflow Test
============================================================
โ
Connected! Found 6 available tools
โ
Script created successfully!
โ
Animation rendered! Job ID: abc123...
โ
Animation result retrieved successfully!
๐ Complete workflow test successful!
๐ Available MCP Tools
| Tool | Description | Usage |
|---|---|---|
write_manim_script |
Create Python animation scripts | Write scripts to temp directory |
render_manim_animation |
Render animations with quality options | Generate MP4 videos from scripts |
get_animation_result |
Retrieve generated video files | Get download URLs for videos |
list_directories |
Explore workspace structure | Browse files and folders |
read_file |
Read existing script files | View script contents |
get_manim_help |
Get usage instructions | Learn how to use the server |
๐ฏ Example Usage
Simple Circle Animation
from manim import *
class SimpleCircle(Scene):
def construct(self):
circle = Circle(radius=1, color=BLUE)
self.play(Create(circle))
self.wait(1)
self.play(FadeOut(circle))
Complex Animation with Text
from manim import *
class MathDemo(Scene):
def construct(self):
# Create title
title = Text("Mathematical Animation", font_size=48)
self.play(Write(title))
self.wait(1)
# Create equation
equation = MathTex(r"e^{i\pi} + 1 = 0")
equation.next_to(title, DOWN, buff=1)
# Animate
self.play(Transform(title, Text("Euler's Identity", font_size=36).to_edge(UP)))
self.play(Write(equation))
self.wait(2)
๐ง API Integration
HTTP Bridge Endpoints
List Tools:
curl -X POST http://localhost:8002/mcp/tools/list
Render Animation:
curl -X POST -H "Content-Type: application/json" \
-d '{
"tool_name": "render_manim_animation",
"arguments": {
"scene_name": "MyScene",
"filepath": "/temp/my_script.py",
"quality": "low_quality"
}
}' \
http://localhost:8002/mcp/tools/call
Get Video:
curl http://localhost:8002/video/{job_id}.mp4
๐๏ธ Architecture
Web Client (Browser)
โ HTTP Requests
MCP HTTP Bridge (FastAPI)
โ stdio/JSON-RPC
MCP Server (manim_mcp_server.py)
โ subprocess calls
Manim CLI
โ file output
Output Directory โ Video Files
๐ Project Structure
manim-mcp/
โโโ manim_mcp_server.py # ๐ฏ Main MCP server
โโโ mcp_bridge.py # ๐ HTTP bridge for web clients
โโโ mcp_client.html # ๐ฅ๏ธ Beautiful web interface
โโโ test_complete_workflow.py # ๐งช Comprehensive test suite
โโโ SETUP_COMPLETE.md # ๐ Complete documentation
โโโ temp/ # ๐ Temporary script files
โโโ output/ # ๐ฌ Generated animation files
โโโ media/ # ๐๏ธ Manim's temporary media files
๐ MCP Client Integration
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"manim": {
"command": "python",
"args": ["/path/to/manim_mcp_server.py"]
}
}
}
VS Code MCP Extension
Use stdio transport to connect to manim_mcp_server.py
Custom Integration
Connect via stdio with JSON-RPC 2.0 following MCP protocol
๐ Success Metrics
- โ 100% MCP Compliance: Full protocol implementation
- โ End-to-End Functionality: Script โ Render โ View pipeline works
- โ Web Interface: User-friendly browser-based client
- โ File Management: Organized output with proper cleanup
- โ Error Handling: Graceful degradation and helpful messages
- โ Performance: Fast rendering with quality options
- โ Extensibility: Easy to add new tools and features
๐ Troubleshooting
Common Issues
MCP Bridge won't start:
# Kill any existing process
lsof -ti:8002 | xargs kill -9
python mcp_bridge.py
Animation won't render:
- Check scene name matches class name exactly
- Verify script syntax with
read_filetool - Use
get_manim_helpfor assistance
Can't see video:
- Ensure job completed successfully
- Check output directory permissions
- Use
get_animation_resultto verify file location
๐ 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
- Model Context Protocol for the standardized interface
- FastAPI for the web framework
Ready to use with any MCP client! ๐
For complete setup instructions and examples, see SETUP_COMPLETE.md
1
Followers
18
Repositories
0
Gists
7
Total Contributions