mcp-bridge-manim

No description

GitHub Stars

1

User Rating

Not Rated

Forks

0

Issues

0

Views

0

Favorites

0

README
Manim MCP Server โœ… FULLY FUNCTIONAL

License: Apache 2.0 MCP Manim Status

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_file tool
  • Use get_manim_help for assistance

Can't see video:

  • Ensure job completed successfully
  • Check output directory permissions
  • Use get_animation_result to verify file location
๐Ÿ“œ License

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

๐Ÿ™ Acknowledgements

Ready to use with any MCP client! ๐ŸŽŠ

For complete setup instructions and examples, see SETUP_COMPLETE.md

Author Information
Abdullah Naeem

Building the future, One commit at a time, my future not yours.

Pakistan

1

Followers

18

Repositories

0

Gists

7

Total Contributions

Top Contributors

Threads