Skip to main content

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

  1. 访问阿里云百炼控制台
  2. 创建应用并获取API Key
  3. 确保已开通通义万相文生图服务

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-flash
  • size (可选): 图像尺寸,默认为 1024*1024
  • n (可选): 生成图片数量,取值范围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*1280
  • 1280*720
  • 1024*576
  • 576*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
})

错误处理

常见错误及解决方案:

  1. API Key未设置

    错误: DASHSCOPE_API_KEY environment variable is required
    解决: 设置环境变量或通过命令行参数传入API Key
    
  2. 模型不支持

    错误: Unsupported model: xxx
    解决: 使用支持的模型名称
    
  3. 图像尺寸不支持

    错误: 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。

Metadata

Release files for mcp-server-bailian-image 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-bailian-image 1.0.4
File Size Uploaded Provenance
mcp_server_bailian_image-1.0.4.tar.gz 16.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-bailian-image 1.0.4
File Interpreter ABI Platform
mcp_server_bailian_image-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / mcp_server_bailian_image-1.0.4.tar.gz

Download URL mcp_server_bailian_image-1.0.4.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
10df48dfe1305a7bea99b10aa6c77d3166c9f65611e6566e0a7c39ca2f1b3682
BLAKE2b-256 checksum
How to use checksums
0aafac57ab033edbaa0d64e8dd5a216924da847796f35f4f57df1257be138d05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / mcp_server_bailian_image-1.0.4-py3-none-any.whl

Download URL mcp_server_bailian_image-1.0.4-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
275ada9bd1cef02eeedad00ef5ca6deb6f23820d4696a8c75472664813576480
BLAKE2b-256 checksum
How to use checksums
edbcfc62e83f57a0c987ca9de69cc81fafbbbb9781c35ac99977e1e3dd04d49e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Security for mcp-server-bailian-image 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page