Skip to main content

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
  • 可选: model (默认 z-image-turbo), size (默认 1024*1024), prompt_extend, watermark, negative_prompt

image_edit_generation - 编辑图像 (同步返回)

基于现有图像和文本提示生成新的编辑版本。

  • 必需: prompt, image (URL)
  • 可选: model (默认 qwen-image-edit-plus), negative_prompt

list_image_models - 获取模型列表

返回支持的图像模型列表及其详细说明(包括简介、分辨率限制等)。

快速开始

方式 1: 使用 uvx 直接运行 (推荐)

如果已安装 uv,无需下载代码即可运行:

# 需设置环境变量 DASHSCOPE_API_KEY
uvx --from bailian-imagegen-mcp-edited bailian-mcp-server

方式 2: 本地安装运行

# 安装包
pip install bailian-imagegen-mcp-edited

# 运行
bailian-mcp-server

配置指南

身份验证

您需要阿里云百炼平台的 API 密钥。

export DASHSCOPE_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxx"

1. Claude.app 配置 (桌面版)

编辑配置文件 (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json, Windows: %APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "bailian-image": {
      "command": "uvx",
      "args": [
        "--from",
        "bailian-imagegen-mcp-edited",
        "bailian-mcp-server"
      ],
      "env": {
        "DASHSCOPE_API_KEY": "sk-your-real-api-key"
      }
    }
  }
}

2. 魔搭社区 (ModelScope) 部署配置

如果您在魔搭 MCP 广场创建服务,请使用以下配置:

  • 托管类型: 可托管部署
  • 服务配置:
    {
      "mcpServers": {
        "bailian-image": {
          "command": "uvx",
          "args": [
            "--from",
            "bailian-imagegen-mcp-edited",
            "bailian-mcp-server"
          ],
          "env": {
            "DASHSCOPE_API_KEY": "sk-your-real-api-key"
          }
        }
      }
    }
    

3. VS Code 配置 (Cline/Roo 等插件)

在项目根目录创建 .vscode/mcp.json

{
  "mcp": {
    "servers": {
      "bailian-image": {
        "command": "uvx",
        "args": [
          "--from",
          "bailian-imagegen-mcp-edited",
          "bailian-mcp-server"
        ],
        "env": {
            "DASHSCOPE_API_KEY": "sk-your-real-api-key"
        }
      }
    }
  }
}

开发与调试

如果您从源码运行:

# 安装依赖
pip install -e .

# Stdio 模式运行
python bailian_mcpserver.py

# HTTP/SSE 模式运行 (用于远程部署调试)
python bailian_mcpserver.py --http

调试

使用 MCP Inspector 进行调试:

npx @modelcontextprotocol/inspector python bailian_mcpserver.py

许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bailian_imagegen_mcp_edited-0.1.6.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bailian_imagegen_mcp_edited-0.1.6-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file bailian_imagegen_mcp_edited-0.1.6.tar.gz.

File metadata

File hashes

Hashes for bailian_imagegen_mcp_edited-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c55c4732b6d78da21953d0820b188832970c7f4b75551e2930f374f0c4184889
MD5 2c36d87ff0fe40ebe51e709baefa6937
BLAKE2b-256 36c192404ddfba15fc99cb7633593b86f35e40f90d990e2300735389963b4e39

See more details on using hashes here.

File details

Details for the file bailian_imagegen_mcp_edited-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for bailian_imagegen_mcp_edited-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7ef2cf66c03c3f86cad624e222514af371843098db701f33e45e452c296e0326
MD5 fdd6564dcb02ffcbbbe30269264688c6
BLAKE2b-256 135623996ca3f8090ec22234fef9c8ecd8a565df433f55584bd821a9cfc5343b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page