Aliyun Bailian Image Generation MCP Server
Project description
阿里云百炼生图 MCP 服务器
一个 Model Context Protocol 服务器,提供阿里云百炼平台的图像生成和编辑功能。该服务器使LLM能够调用阿里云百炼API来生成、编辑图像,支持多种图像分辨率、多模型选择(Qwen, Z-Image, Wan系列)和自定义参数。
本次更新亮点:
- 全异步架构:完美适配 MCP SSE 协议,不会阻塞服务器心跳。
- 直接返回结果:无需二次查询,生图请求直接返回图片 URL。
- 多模型支持:新增 Qwen-Image, Wan (万相) 系列等多个模型支持。
可用工具
generate_image - 生成图像 (同步返回)
使用文本提示词生成图像,请求等待生成完成后直接返回图片链接。
必需参数:
prompt(string): 正向提示词,描述期望生成的图像内容
可选参数:
model(string): 指定模型,默认为 "z-image-turbo"。支持 "qwen-image-max", "wan2.2-t2i-plus" 等。详细列表请使用list_image_models查看。size(string): 输出图像分辨率,默认 "10241024"。支持格式如 "10241024", "1280*720" 等。prompt_extend(bool): 是否开启prompt智能改写,默认 truewatermark(bool): 是否添加水印标识,默认 falsenegative_prompt(string): 反向提示词,描述不希望出现的内容
注意:生成图片数量 (
n) 现已强制为 1 张,不再支持自定义数量。
image_edit_generation - 编辑图像 (同步返回)
基于现有图像和文本提示生成新的编辑版本。
必需参数:
prompt(string): 编辑指令提示词image(string): 输入图像的URL
可选参数:
model(string): 编辑模型,默认为 "qwen-image-edit-plus"。negative_prompt(string): 反向提示词
list_image_models - 获取模型列表
返回支持的图像模型列表及其详细说明(包括简介、分辨率限制等)。
安装
使用 uv (推荐)
使用 uv 时无需特定安装。我们将使用 uvx 直接运行 MCP 服务器。
使用 pip
或者,您可以通过 pip 安装:
pip install -e .
安装后,可以作为脚本运行:
python -m src.gen_images.bailian_mcpserver
配置
身份验证
您需要阿里云百炼平台的 API 密钥。建议通过环境变量配置:
export DASHSCOPE_API_KEY="your_api_key_here"
为 Claude.app 配置
将以下内容添加到您的 Claude 设置:
{
"mcpServers": {
"bailian-image": {
"command": "uvx",
"args": [
"--from",
"my-mcp-servers",
"bailian-mcp-server"
],
"env": {
"DASHSCOPE_API_KEY": "sk-your-api-key"
}
}
}
}
为 VS Code 配置
在工作区中创建 .vscode/mcp.json 文件:
{
"mcp": {
"servers": {
"bailian-image": {
"type": "stdio",
"command": "uvx",
"args": [
"--from",
"my-mcp-servers",
"bailian-mcp-server"
],
"env": {
"DASHSCOPE_API_KEY": "sk-your-api-key"
}
}
}
}
}
示例交互
1. 查询可用模型
{
"name": "list_image_models",
"arguments": {}
}
2. 生成图像
{
"name": "generate_image",
"arguments": {
"prompt": "一只可爱的橙色小猫坐在阳光明媚的窗台上",
"model": "wan2.2-t2i-plus",
"size": "1024*1024"
}
}
响应(直接返回 URL):
{
"image_url": "https://dashscope-result-cn-beijing.oss-cn-beijing.aliyuncs.com/...",
"request_id": "req_87654321",
"model": "wan2.2-t2i-plus"
}
3. 编辑图像
{
"name": "image_edit_generation",
"arguments": {
"prompt": "将猫的颜色改为白色",
"image": "https://example.com/original_image.jpg",
"model": "qwen-image-edit-plus"
}
}
响应:
{
"image_url": "https://example.com/edited_image.jpg",
"request_id": "req_11223344"
}
运行模式
该服务器支持两种运行模式:
Stdio 模式 (默认)
python -m src.gen_images.bailian_mcpserver
HTTP 模式 (团队服务)
python -m src.gen_images.bailian_mcpserver --http
调试
您可以使用 MCP 检查器来调试服务器:
npx @modelcontextprotocol/inspector python -m src.gen_images.bailian_mcpserver
贡献
我们鼓励贡献来帮助扩展和改进阿里云百炼生图 MCP 服务器。
许可证
该项目采用 MIT 许可证。
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 bailian_imagegen_mcp_edited-0.1.0.tar.gz.
File metadata
- Download URL: bailian_imagegen_mcp_edited-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e299c1b84397e1c4ccbcccbb55f82cc326345565edc69a997e069619c219be67
|
|
| MD5 |
d322441d489c530b525ad29e31aaffa4
|
|
| BLAKE2b-256 |
b960466527bcf5efeb3393644ef09fe01c1fcc0f34d8748866add8fb04b45db5
|
File details
Details for the file bailian_imagegen_mcp_edited-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bailian_imagegen_mcp_edited-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26c7a04bc024b44a90f0fecb482c095ad07d61bb339e8b7b7c6cc2484f625dd7
|
|
| MD5 |
96067f9cbdaa67a1df7fcf2563d5f29b
|
|
| BLAKE2b-256 |
a6c74652e77bb90fe0e208ba9389b6b4fdc61af40c735d5555d7eb102a08ea77
|