阿里云百炼-通义万相图像生成MCP服务器
Project description
MCP Server Bailian Image
阿里云百炼-通义万相图像生成MCP服务器
功能特性
- 🎨 文生图功能: 基于通义万相2.1/2.2文生图V2版API
- 🚀 多模型支持: 支持wan2.2-t2i-flash、wan2.2-t2i-plus等多种模型
- 🎯 精确控制: 支持正向提示词、反向提示词、图像尺寸、生成数量等参数
- ⚡ 同步调用: 使用DashScope SDK进行同步调用,简化使用流程
- 🔧 易于集成: 标准MCP协议,可与支持MCP的AI助手无缝集成
安装
从PyPI安装
pip install mcp-server-bailian-image
从源码安装
git clone https://github.com/aliyun/mcp-server-bailian-image.git
cd mcp-server-bailian-image
pip install -e .
配置
1. 获取API Key
- 访问阿里云百炼控制台
- 创建应用并获取API Key
- 确保已开通通义万相文生图服务
2. 设置环境变量
# Windows
set DASHSCOPE_API_KEY=your_api_key_here
# Linux/macOS
export DASHSCOPE_API_KEY=your_api_key_here
使用方法
启动MCP服务器
# 使用uvx启动(推荐)
uvx mcp-server-bailian-image
# 或者直接传入API Key
uvx mcp-server-bailian-image --api-key your_api_key_here
在Claude Desktop中配置
在Claude Desktop的配置文件中添加以下配置:
{
"mcpServers": {
"bailian-image": {
"command": "uvx",
"args": ["mcp-server-bailian-image"],
"env": {
"DASHSCOPE_API_KEY": "your_api_key_here"
}
}
}
}
支持的工具
text2imagev2
基于通义万相文生图V2版API的文生图工具。
参数说明:
prompt(必填): 正向提示词,描述期望生成的图像内容negative_prompt(可选): 反向提示词,描述不希望出现的内容model(可选): 模型名称,默认为wan2.2-t2i-flashsize(可选): 图像尺寸,默认为1024*1024n(可选): 生成图片数量,取值范围1-4,默认为1
支持的模型:
wan2.2-t2i-flash: 万相2.2极速版(推荐)wan2.2-t2i-plus: 万相2.2专业版(推荐)wanx2.1-t2i-turbo: 万相2.1极速版wanx2.1-t2i-plus: 万相2.1专业版wanx2.0-t2i-turbo: 万相2.0极速版
支持的图像尺寸:
1024*1024(默认)720*12801280*7201024*576576*1024
使用示例:
# 基础文生图
result = await call_tool("text2imagev2", {
"prompt": "一只坐着的橘黄色的猫,表情愉悦,活泼可爱,逼真准确"
})
# 使用反向提示词
result = await call_tool("text2imagev2", {
"prompt": "雪地,白色小教堂,极光,冬日场景,柔和的光线",
"negative_prompt": "人物",
"model": "wan2.2-t2i-plus",
"size": "1280*720",
"n": 2
})
错误处理
常见错误及解决方案:
-
API Key未设置
错误: DASHSCOPE_API_KEY environment variable is required 解决: 设置环境变量或通过命令行参数传入API Key -
模型不支持
错误: Unsupported model: xxx 解决: 使用支持的模型名称 -
图像尺寸不支持
错误: Unsupported size: xxx 解决: 使用支持的图像尺寸
开发
环境要求
- Python 3.8+
- DashScope SDK
- MCP SDK
本地开发
# 克隆仓库
git clone https://github.com/aliyun/mcp-server-bailian-image.git
cd mcp-server-bailian-image
# 安装依赖
pip install -e .
# 运行测试
python -m pytest
# 启动开发服务器
python -m mcp_server_bailian_image.server
许可证
MIT License
相关链接
支持
如有问题或建议,请提交Issue。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_bailian_image-1.0.4.tar.gz.
File metadata
- Download URL: mcp_server_bailian_image-1.0.4.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10df48dfe1305a7bea99b10aa6c77d3166c9f65611e6566e0a7c39ca2f1b3682
|
|
| MD5 |
c86216148ce549cefc4467b1a4f32fc0
|
|
| BLAKE2b-256 |
0aafac57ab033edbaa0d64e8dd5a216924da847796f35f4f57df1257be138d05
|
File details
Details for the file mcp_server_bailian_image-1.0.4-py3-none-any.whl.
File metadata
- Download URL: mcp_server_bailian_image-1.0.4-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
275ada9bd1cef02eeedad00ef5ca6deb6f23820d4696a8c75472664813576480
|
|
| MD5 |
7e35e2cb31a0e9c6c15fbd76291b06e5
|
|
| BLAKE2b-256 |
edbcfc62e83f57a0c987ca9de69cc81fafbbbb9781c35ac99977e1e3dd04d49e
|