ModelScope-Image-Generation-MCP
支持使用ModelScope上的模型进行文本到图像的生成。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"modelscope-image-gen-mcp": {
"args": [
"ms_image_gen_mcp"
],
"command": "uvx",
"env": {
"MODELSCOPE_API_KEY": "YOUR_MODELSCOPE_TOKEN"
}
}
}
}
该服务需要配置环境变量:MODELSCOPE_API_KEY
可用工具 (3 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
search_models 5 个参数
Search for models on ModelScope.
该工具无需必填参数,直接调用即可
text_to_image 7 个参数 需填 1 项
Generate an image from the input description using ModelScope API, it returns the image URL. Args: description: the description of the image to be generated, containing the desired elements and visual features. model: the model name to be used for image generation, default is "Qwen/Qwen-Image".
必填参数:description
text_image_to_image 8 个参数 需填 2 项
Generate an image from the input description and input image_url using ModelScope API, it returns the image URL. Args: description: the description of the image to be generated, containing the desired elements and visual features. image_url: the image URL to be used as the input image for image generation. model: the model name to be used for image generation, default is "black-forest-labs/FLUX.1-Kontext-dev".
必填参数:description、image_url
服务介绍
ModelScope 图像生成 MCP
一个强大的模型上下文协议(MCP)服务器,集成了 ModelScope 的图像生成功能,通过聊天界面实现无缝的 AI 图像创建和模型发现。
功能特性
- 🔍 模型发现:使用关键词搜索和探索 ModelScope 上的模型,支持高级筛选选项
- 🎨 文本生成图像:使用最先进的模型从文本描述生成高质量图像
- 🖼️ 图像转换图像:基于文本提示转换现有图像,实现创意编辑
- 📊 模型分析:按热度、下载量或修改日期对模型进行排序
- 🚀 简单集成:与支持 MCP 的聊天客户端无缝集成
可用工具
模型搜索工具
🔍 search_models - 搜索和发现 ModelScope 上的模型
| 参数 | 类型 | 描述 | 示例 |
|---|---|---|---|
query |
string | 搜索关键词 | "Flux", "SDXL", "" |
task |
string | 按任务类型筛选(可选) | "text-to-image" |
libraries |
string | 按库类型筛选(可选) | "LoRA" |
sort |
string | 排序方式(可选) | "DownloadsCount", "StarsCount", "GmtModified" |
limit |
integer | 结果数量 (1-30)(可选) | 10 |
图像生成工具
🎨 generate_image_url_from_text - 从文本描述创建图像
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
description |
string | 图像生成的文本提示 | 必需 |
model |
string | 默认使用的模型 ID | "Qwen/Qwen-Image" |
✍️ generate_image_url_from_text_and_image_url - 转换现有图像
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
description |
string | 图像转换的文本提示 | 必需 |
image_url |
string | 输入图像的 URL | 必需 |
model |
string | 默认使用的模型 ID | "black-forest-labs/FLUX.1-Kontext-dev" |
热门可用模型
- 文本生成图像:
Qwen/Qwen-Image(默认) - 图像转换图像:
black-forest-labs/FLUX.1-Kontext-dev(默认) - 还有 10000+ 模型可通过 ModelScope 平台获得!
配置
步骤 1:获取 API 密钥
从 ModelScope API 密钥 获取您的 API 密钥以访问 API。
步骤 2:配置 MCP 客户端
将以下配置添加到您的 MCP 客户端(例如,Cherry Studio、Claude Desktop):
{
"MS-ImgGen-MCP": {
"command": "uvx",
"args": ["ms_image_gen_mcp@latest"],
"env": {
"MODELSCOPE_API_KEY": "YOUR_MODELSCOPE_API_KEY"
}
}
}
开发者
前置要求
- Python 3.11+:运行 MCP 服务器所需
- ModelScope API 密钥:从 ModelScope 获取 API 访问权限
- Node.js(可选):MCP Inspector 调试所需
安装
通过 pip 安装软件包:
pip install ms-image-gen-mcp
使用 MCP Inspector 调试
用于开发和调试,使用 MCP Inspector:
npx @modelcontextprotocol/inspector -e MODELSCOPE_API_KEY=YOUR_MODELSCOPE_API_KEY python -m ms_image_gen_mcp
版本历史
| 版本 | 更改内容 |
|---|---|
| 1.2.0 | 转换为异步 API |
| 1.1.0 | 添加模型搜索和图像到图像生成 |
| 1.0.0 | 初始发布,支持文本到图像生成 |