tasjian/visual_explanations_MCP_server
If you are the rightful owner of visual_explanations_MCP_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Visual Explanation MCP Server is designed to create animated visual explanations for scientific and educational concepts, providing both text explanations and interactive animations.
π¬ Visual Explanation MCP Server
An MCP (Model Control Protocol) server that creates animated visual explanations for scientific and educational concepts. Ask a question like "Why does the Earth have seasons?" and get both a text explanation and an interactive animation showing the Earth's orbit and axial tilt.
π Features
- AI-Powered Explanations: Uses OpenAI GPT or Anthropic Claude to generate detailed explanations
- Structured Animation Instructions: AI generates JSON instructions for creating visualizations
- Multiple Animation Types: 3D (Three.js), 2D SVG (D3.js), and Canvas-based animations
- Interactive Demo: Built-in web interface for testing
- Educational Focus: Optimized for science, physics, chemistry, and biology concepts
π Quick Start
Prerequisites
- Python 3.8+
- Node.js (for frontend dependencies, optional)
Installation
# Clone or download the project
cd vis_ex_MCP
# Method 1: Using the startup script (recommended)
./start_server.sh
# Method 2: Manual setup with virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Set API key (optional - will use mock responses without it)
export OPENAI_API_KEY="your-openai-key"
# OR
export ANTHROPIC_API_KEY="your-anthropic-key"
# Start the server
python run_server.py
Usage
- Web Demo: Open http://localhost:8000/demo
- API Endpoint: POST to http://localhost:8000/query
- API Documentation: http://localhost:8000/docs
π Supported Topics
The system works best with visual scientific concepts:
π Astronomy & Physics
- Earth's seasons - Shows orbital mechanics and axial tilt
- Wave interference - Demonstrates constructive/destructive interference
- Planetary motion - Orbital dynamics and gravitational effects
π¬ Biology & Chemistry
- Photosynthesis - Shows light energy conversion and molecular processes
- Cell division - Mitosis and meiosis animations
- Chemical reactions - Molecular interactions and bond formation
β‘ Engineering & Technology
- Electric circuits - Current flow and component behavior
- Mechanical systems - Gears, levers, and force transmission
- Signal processing - Waveforms and filtering
π― Example Queries
Try these questions in the demo:
"Why does the Earth have seasons?"
"How does photosynthesis work?"
"What happens in an electric circuit?"
"How do waves interfere with each other?"
"Why do objects fall at the same rate?"
π§ API Reference
POST /query
Request body:
{
"content": "Why does the Earth have seasons?"
}
Response:
{
"text_response": "The Earth has seasons because...",
"animation_instructions": {
"scene_type": "solar_system",
"actors": ["earth", "sun"],
"parameters": {
"earth_tilt": 23.5,
"orbit_radius": 4,
"animation_speed": 0.015
},
"timeline": [...],
"annotations": [...]
},
"html_animation": "<iframe>...</iframe>"
}
ποΈ Architecture
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β User Query βββββΆβ MCP Server βββββΆβ LLM Provider β
β "Why seasons?" β β (FastAPI) β β (OpenAI/Claude) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β Animation β
β Compiler β
ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β HTML + JS β
β Animation β
ββββββββββββββββββββ
Core Components
- MCP Server (
mcp_server.py
) - FastAPI server handling requests - LLM Integration (
llm_integration.py
) - Connects to AI providers - Animation Compiler - Converts instructions to JavaScript
- Template Library (
animation_templates.py
) - Reusable animation code
π¨ Animation Types
3D Animations (Three.js)
- Solar systems and planetary motion
- Molecular structures
- Mechanical systems
2D Vector (D3.js/SVG)
- Biological processes
- Flow diagrams
- Statistical visualizations
Canvas-based
- Wave phenomena
- Particle systems
- Circuit diagrams
π§ Configuration
Environment Variables
# Required for real LLM responses
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
# Server settings (optional)
MCP_PORT=8000
MCP_HOST=localhost
Template Customization
Add new animation templates in animation_templates.py
:
@staticmethod
def my_custom_animation() -> str:
return '''
// Your JavaScript animation code here
const scene = new THREE.Scene();
// ...
'''
π§ͺ Development
Project Structure
vis_ex_MCP/
βββ mcp_server.py # Main FastAPI server
βββ llm_integration.py # LLM provider connections
βββ animation_templates.py # JavaScript templates
βββ requirements.txt # Python dependencies
βββ run_server.py # Startup script
βββ README.md # This file
Adding New Animation Types
- Create template in
animation_templates.py
- Add scene type to LLM prompt in
llm_integration.py
- Update compiler in
mcp_server.py
- Test with demo interface
Testing
# Start development server with auto-reload (in virtual environment)
source venv/bin/activate
python run_server.py
# Or use the startup script
./start_server.sh
# Test API endpoint
curl -X POST "http://localhost:8000/query" \
-H "Content-Type: application/json" \
-d '{"content": "Why does the Earth have seasons?"}'
Virtual Environment Notes
The project now uses updated dependencies that avoid conflicts with other packages:
- FastAPI 0.116+ - Latest stable version
- Pydantic 2.9+ - Compatible with modern MCP tools
- Uvicorn 0.32+ - High-performance ASGI server
If you encounter dependency conflicts, always use a virtual environment:
π€ Contributing
- Fork the repository
- Create a feature branch
- Add your animation template or improvement
- Test with the demo interface
- Submit a pull request
π License
MIT License - feel free to use and modify for educational purposes.
π― Future Enhancements
- Voice narration with text-to-speech
- Interactive controls (sliders, buttons)
- Mobile-responsive animations
- More science topics (chemistry, advanced physics)
- Integration with educational platforms
- Real-time collaborative viewing
Built with β€οΈ for education and visual learning