Wan2GP MCP Server
Enables AI assistants to generate videos from text prompts and images by interfacing with a Wan2GP Gradio server. It provides tools for high-quality video generation, queue management, and model discovery through the Model Context Protocol.
README
Wan2GP MCP Server
A Model Context Protocol (MCP) server that provides AI assistants (like Claude Desktop) with access to Wan2GP video generation capabilities.
Overview
This MCP server communicates with a running Wan2GP Gradio instance to generate videos from text prompts and images. It's designed to work with Wan2GP installations via StabilityMatrix or standalone setups.
Features
- Text-to-Video: Generate videos from text descriptions
- Image-to-Video: Animate static images with text prompts
- Queue Management: View and manage generation queue
- Model Listing: Discover available video generation models
- LoRA Support: List available LoRA adapters
- Health Monitoring: Check Wan2GP server status
Architecture
Claude Desktop (MCP Client)
↓ stdio (JSON-RPC 2.0)
Wan2GP MCP Server
↓ HTTP requests
Wan2GP Gradio Server (localhost:7860)
Prerequisites
-
Wan2GP Server: A running Wan2GP Gradio instance
- Install via StabilityMatrix or manually
- Start the Gradio server:
python wgp.py --server-name 0.0.0.0 --server-port 7860
-
Python 3.10+: Required for the MCP server
-
Claude Desktop (optional): For MCP integration
Installation
1. Clone or Download
cd /path/to/your/projects
git clone <this-repo> wan2gp-mcp-server
cd wan2gp-mcp-server
2. Install Dependencies
pip install -r requirements.txt
3. Configure Server URL
Edit config.json to match your Wan2GP server URL:
{
"wan2gp_url": "http://localhost:7860",
"timeout": 300,
"max_concurrent_tasks": 3,
"default_model": "wan",
"default_resolution": "1280x720",
"output_directory": "./output"
}
Or set via environment variable:
export WAN2GP_URL="http://localhost:7860"
export WAN2GP_TIMEOUT="300"
Usage
Standalone Testing
Test the MCP server directly:
python wan2gp_mcp_server.py
In another terminal, test with an MCP client or inspect the logs.
Claude Desktop Integration
-
Add to Claude Desktop Config
Locate Claude Desktop's config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- Windows:
-
Merge the Configuration
Add the
wan2gpserver to themcpServerssection:{ "mcpServers": { "wan2gp": { "command": "python", "args": [ "/absolute/path/to/wan2gp-mcp-server/wan2gp_mcp_server.py" ], "env": { "WAN2GP_URL": "http://localhost:7860", "WAN2GP_TIMEOUT": "300", "LOG_LEVEL": "INFO" } } } }Important: Use absolute paths in the
argssection. -
Restart Claude Desktop
Claude will load the MCP server on startup.
-
Use in Claude
Now you can ask Claude to generate videos:
Generate a 5-second video of a cat walking through a sunny gardenClaude will use the MCP server to submit the generation task.
MCP Tools
The server provides the following tools:
generate_text_to_video
Generate a video from text description.
Parameters:
prompt(required): Text description of the videonegative_prompt: Things to avoid in the videoresolution: Video resolution (e.g., "1280x720", "1920x1080")video_length: Number of frames (49 ≈ 2 seconds at 24fps)num_inference_steps: Number of denoising steps (20-50 recommended)guidance_scale: How strongly to follow the prompt (1-20)seed: Random seed (-1 for random)model_type: Model to use (wan, hunyuan, ltx, etc.)output_filename: Custom output filename
Example:
generate_text_to_video(
prompt="A cat walking through a sunny garden, slow motion",
resolution="1280x720",
num_inference_steps=25,
guidance_scale=7.5
)
generate_image_to_video
Animate a static image based on a text prompt.
Parameters:
image_path(required): Path to the input imageprompt(required): How the image should animate/movenegative_prompt: Things to avoid in the videomotion_scale: How much motion to generate (0.5-2.0)video_length: Number of framesnum_inference_steps: Number of denoising stepsguidance_scale: How strongly to follow the promptseed: Random seed (-1 for random)model_type: Model to use
Example:
generate_image_to_video(
image_path="/path/to/image.jpg",
prompt="Camera slowly zooms in, clouds drift across the sky",
motion_scale=1.2
)
health_check
Check if Wan2GP server is running and accessible.
Returns:
{
"status": "healthy",
"url": "http://localhost:7860",
"version": "10.951"
}
list_models
List all available video generation models.
Returns:
[
{
"name": "Wan2.1 T2V",
"id": "t2v_2_2",
"type": "text_to_video",
"resolution": "480p-8K",
"vram_requirement": "16GB+"
}
]
list_loras
List available LoRA adapters.
get_queue
Get the current generation queue.
cancel_task
Cancel a queued generation task.
MCP Resources
The server provides the following resources:
wan2gp://models- List available models (JSON)wan2gp://loras- List available LoRAs (JSON)wan2gp://queue- Current generation queue (JSON)wan2gp://health- Server health status (JSON)
Troubleshooting
"Cannot connect to Wan2GP server"
- Ensure Wan2GP Gradio server is running
- Check the URL in
config.jsonmatches your server - Verify the server port (default: 7860)
"Flash-Attention version conflict"
This is a Wan2GP environment issue, not related to the MCP server. Ensure Wan2GP's dependencies are correctly installed:
# In Wan2GP environment
pip install flash-attn==2.7.4
Claude Desktop doesn't show MCP tools
- Check Claude Desktop logs:
Help > Developer > Show Logs - Verify absolute paths in config
- Ensure Python is in system PATH
- Test the server manually:
python wan2gp_mcp_server.py
Development
Running Tests
# Test client
python tests/test_client.py
# Test with MCP inspector
npx @modelcontextprotocol/inspector python wan2gp_mcp_server.py
Adding New Tools
Edit wan2gp_mcp_server.py and add a new tool using the @mcp.tool decorator:
@mcp.tool
async def my_new_tool(param: str) -> str:
"""Tool description."""
client = await get_client()
# ... implementation
return "result"
Configuration Reference
config.json
| Key | Type | Default | Description |
|---|---|---|---|
wan2gp_url |
string | http://localhost:7860 |
Wan2GP Gradio server URL |
timeout |
number | 300 |
Request timeout in seconds |
max_concurrent_tasks |
number | 3 |
Maximum concurrent generations |
default_model |
string | wan |
Default model to use |
default_resolution |
string | 1280x720 |
Default video resolution |
output_directory |
string | ./output |
Where to save generated videos |
Environment Variables
| Variable | Description | Default |
|---|---|---|
WAN2GP_URL |
Override Wan2GP server URL | http://localhost:7860 |
WAN2GP_TIMEOUT |
Override request timeout | 300 |
LOG_LEVEL |
Logging level | INFO |
License
This MCP server is provided as-is for use with Wan2GP.
Credits
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。