This server provides Model Context Protocol (MCP) access to Alibaba Cloud's Tongyi Wanxiang API for AI-powered text-to-image and text-to-video generation.
Capabilities include:
- Generate images from text prompts (with optional negative prompts) using the
wanx-t2i-image-generation
tool - Retrieve generated images using task IDs via the
wanx-t2i-image-generation-result
tool - Generate videos from text prompts using the
wanx-t2v-video-generation
tool - Retrieve generated videos using task IDs via the
wanx-t2v-video-generation-result
tool
Integrates with Alibaba Cloud's Tongyi Wanxiang AI to provide text-to-image and text-to-video generation capabilities, allowing users to create high-quality AI-generated images and videos through Tongyi Wanxiang's APIs
通义万相 MCP 服务器
这是一个基于 TypeScript 的 Model Context Protocol (MCP) 服务器,专门提供阿里云通义万相的文生图(Text-to-Image)和文生视频(Text-to-Video)能力。该服务器通过 MCP 协议,允许大语言模型(LLM)直接调用通义万相的图像和视频生成 API。
功能特点
- 文生图能力集成:接入阿里云通义万相文生图 API,支持高质量的 AI 图像生成
- 文生视频能力集成:接入阿里云通义万相文生视频 API,支持高质量的 AI 视频生成
- 异步任务处理:支持长时间运行的图像和视频生成任务,通过异步轮询获取最终结果
- MCP 协议支持:符合 Model Context Protocol 规范,可与支持 MCP 的 LLM 无缝协作
环境要求
- Node.js >= 16.x
- npm >= 8.x 或 pnpm
如何使用
以百炼平台举例
如何开发
安装依赖
构建与运行
API 使用
该服务器提供以下 MCP 工具:
1. 文生图生成(wanx-t2i-image-generation)
启动图像生成任务,返回任务 ID。
参数:
prompt
: 图像生成提示词negative_prompt
: 负面提示词(不希望在图像中出现的元素)
返回:
- 包含
task_id
的任务信息
2. 获取生成结果(wanx-t2i-image-generation-result)
通过任务 ID 获取图像生成结果。
参数:
task_id
: 由文生图生成工具返回的任务 ID
返回:
- 图像生成结果,包含图像 URL
3. 文生视频生成(wanx-t2v-video-generation)
启动视频生成任务,返回任务 ID。
参数:
prompt
: 视频生成提示词
返回:
- 包含
task_id
的任务信息
4. 获取视频生成结果(wanx-t2v-video-generation-result)
通过任务 ID 获取视频生成结果。
参数:
task_id
: 由文生视频生成工具返回的任务 ID
返回:
- 视频生成结果,包含视频 URL
项目结构
通义万相 API 参数说明
文生图 API 支持的参数
- model: 模型名称,默认为
wanx2.1-t2i-turbo
- size: 图像尺寸,默认为
1024*1024
- n: 生成图像数量,默认为 1
- seed: 随机种子,用于复现结果
- prompt_extend: 是否启用提示词扩展,默认为 true
- watermark: 是否添加水印,默认为 false
高级配置
您可以在 src/config.ts
中修改以下配置:
- pollingInterval: 轮询任务状态的间隔时间(毫秒)
- maxRetries: 最大轮询次数
- defaultModel: 默认使用的模型
注意事项
- 请确保您有有效的通义万相 API 访问权限和密钥
- 图像生成是一个异步过程,可能需要数秒到数十秒不等
- 视频生成过程耗时较长,可能需要数分钟到十几分钟不等
- 视频生成状态查询可能会多次失败,系统会自动重试,请耐心等待
- 请合理设置轮询间隔和最大重试次数,以适应您的使用场景
- 对于视频生成任务,建议增加最大重试次数和轮询间隔时间
参考资料
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
A TypeScript-based Model Context Protocol server that enables large language models to directly invoke Alibaba Cloud's Tongyi Wanxiang text-to-image generation API.
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol server that enables large language models to upload files directly to Alibaba Cloud Object Storage Service (OSS), supporting multiple OSS configurations and specified upload directories.Last updated -104TypeScript
- AsecurityAlicenseAqualityA Model Context Protocol server that enables AI agents to interact with Alibaba Cloud DataWorks through standardized interfaces, allowing seamless management of DataWorks resources and operations via the DataWorks Open API.Last updated -1691419TypeScriptApache 2.0
- -securityFlicense-qualityA Model Context Protocol server that provides AI models with real-time trending content from 18 major Chinese internet platforms, including Weibo, Zhihu, and Bilibili.Last updated -5TypeScript
- AsecurityAlicenseAqualityA TypeScript-based Model Context Protocol server that integrates with Volcengine's Jimeng AI image generation service, allowing users to generate AI images through simple tool calls.Last updated -142TypeScriptMIT License