The Tongyi Wanxiang MCP server provides a TypeScript-based implementation of the Model Context Protocol (MCP) that allows Large Language Models (LLMs) to directly access Alibaba Cloud's Tongyi Wanxiang text-to-image and text-to-video generation capabilities.
You can quickly set up the server by adding it to your configuration:
{
"mcpServers": {
"tongyi-wanxiang": {
"command": "npx",
"args": [
"-y",
"tongyi-wanx-mcp-server@latest"
],
"env": {
"DASHSCOPE_API_KEY": "<your Tongyi Wanxiang API key>"
}
}
}
}
If you want to run the server directly:
# Install and run with npx
npx tongyi-wanx-mcp-server@latest
Make sure to set the DASHSCOPE_API_KEY
environment variable with your API key.
The server provides several MCP tools for image and video generation:
Use the wanx-t2i-image-generation
tool to start an image generation task:
Parameters:
prompt
: Description of the image you want to generatenegative_prompt
: Elements you don't want in the imageExample:
{
"prompt": "A scenic mountain landscape with a lake at sunset",
"negative_prompt": "people, buildings, text"
}
The tool returns a task ID that you'll use to retrieve the results.
Use the wanx-t2i-image-generation-result
tool to get the results:
Parameters:
task_id
: The task ID from the previous stepExample:
{
"task_id": "your-task-id-here"
}
The response will include the URL to the generated image.
Use the wanx-t2v-video-generation
tool:
Parameters:
prompt
: Description of the video you want to generateExample:
{
"prompt": "Waves crashing on a beach at sunset"
}
Use the wanx-t2v-video-generation-result
tool:
Parameters:
task_id
: The task ID from the previous stepExample:
{
"task_id": "your-task-id-here"
}
The response will include the URL to the generated video.
You can customize image generation with these optional parameters:
wanx2.1-t2i-turbo
1024*1024
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "tongyi-wanxiang" '{"command":"npx","args":["-y","tongyi-wanx-mcp-server@latest"],"env":{"DASHSCOPE_API_KEY":"<\u4f60\u7684\u901a\u4e49\u4e07\u76f8 API \u5bc6\u94a5>"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"tongyi-wanxiang": {
"command": "npx",
"args": [
"-y",
"tongyi-wanx-mcp-server@latest"
],
"env": {
"DASHSCOPE_API_KEY": "<\u4f60\u7684\u901a\u4e49\u4e07\u76f8 API \u5bc6\u94a5>"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"tongyi-wanxiang": {
"command": "npx",
"args": [
"-y",
"tongyi-wanx-mcp-server@latest"
],
"env": {
"DASHSCOPE_API_KEY": "<\u4f60\u7684\u901a\u4e49\u4e07\u76f8 API \u5bc6\u94a5>"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect