ModelScope Image MCP Server
Provides installation option for the MCP server directly from GitHub repository using git+https URL format
Provides installation and distribution of the MCP server package through the Python Package Index
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ModelScope Image MCP Servergenerate a cute puppy playing in a sunny meadow"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ModelScope Image MCP Server
English | 中文
An MCP (Model Context Protocol) server for generating images via the ModelScope image generation API. This server provides seamless integration with AI assistants, enabling them to create images through natural language prompts with robust async processing and local file management.
IMPORTANT: Earlier drafts of this README mentioned features like returning base64 data, negative prompts, and additional parameters. The current released code (see
src/modelscope_image_mcp/server.py) implements a focused minimal feature set: one toolgenerate_imagethat submits an async task and saves the resulting image locally. Planned / upcoming features are listed in the roadmap below.
Current Features
Asynchronous image generation using ModelScope async task API
Periodic task status polling (every 5 seconds, up to 2 minutes)
Saves the first generated image to a local file
Returns task status and image URL to the MCP client
Robust error handling + timeout messaging
Simple one-command start with
uvx
Related MCP server: Doubao Image/Video Generation MCP Server
Environment Variable
The server reads your credential from:
MODELSCOPE_SDK_TOKENIf it is missing, the server will raise an error. Obtain a token from: https://modelscope.cn/my/myaccesstoken
Set on Windows (cmd):
set MODELSCOPE_SDK_TOKEN=your_token_herePowerShell:
$env:MODELSCOPE_SDK_TOKEN="your_token_here"Unix/macOS bash/zsh:
export MODELSCOPE_SDK_TOKEN=your_token_hereInstallation & MCP Client Configuration
You can register the server directly in an MCP-compatible client (e.g. Claude Desktop) without a prior manual install thanks to uvx.
Option 1: PyPI (Recommended once published)
{
"mcpServers": {
"modelscope-image": {
"command": "uvx",
"args": ["modelscope-image-mcp"],
"env": {
"MODELSCOPE_SDK_TOKEN": "your_token_here"
}
}
}
}Option 2: Direct from GitHub
{
"mcpServers": {
"modelscope-image": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/zym9863/modelscope-image-mcp.git",
"modelscope-image-mcp"
],
"env": {
"MODELSCOPE_SDK_TOKEN": "your_token_here"
}
}
}
}Option 3: Local Development Checkout
git clone https://github.com/zym9863/modelscope-image-mcp.git
cd modelscope-image-mcp
uv syncThen configure MCP client entry using:
{
"mcpServers": {
"modelscope-image": {
"command": "uvx",
"args": ["--from", ".", "modelscope-image-mcp"],
"env": { "MODELSCOPE_SDK_TOKEN": "your_token_here" }
}
}
}Quick Local Smoke Test
# Run directly (local checkout)
uvx --from . modelscope-image-mcpWhen running successfully you should see log lines showing task submission and polling.
## Usage Examples
### Basic Image Generation
```jsonc
{
"name": "generate_image",
"arguments": {
"prompt": "A serene mountain landscape at sunset"
}
}Advanced Configuration
{
"name": "generate_image",
"arguments": {
"prompt": "A futuristic city with flying cars, cyberpunk style",
"model": "Qwen/Qwen-Image",
"size": "1024x1024",
"output_filename": "cyberpunk_city.png",
"output_dir": "./generated_images"
}
}Creative Prompts
Art Style: "in the style of Van Gogh", "watercolor painting", "digital art"
Composition: "close-up portrait", "wide-angle landscape", "bird's eye view"
Lighting: "dramatic lighting", "golden hour", "studio lighting"
Mood: "mysterious atmosphere", "vibrant colors", "minimalist design"
Best Practices
Be Specific: Detailed prompts produce better results than vague ones
Use References: Mention specific art styles, artists, or time periods
Experiment: Try variations of your prompt to find the best result
Organize Outputs: Use descriptive filenames and organized directories
Check Status: Monitor the async task status for long-running generations
generate_image
Creates an image from a text prompt using the ModelScope async API.
Parameters:
prompt (string, required): The text description of the desired image
model (string, optional, default: Qwen/Qwen-Image): Model name passed to API
size (string, optional, default: 1024x1024): Image resolution size, Qwen-Image supports: [64x64,1664x1664]
output_filename (string, optional, default: result_image.jpg): Local filename to save the first output image
output_dir (string, optional, default: ./outputs): Directory path where the image will be saved
Sample invocation (conceptual JSON sent by MCP client):
{
"name": "generate_image",
"arguments": {
"prompt": "A golden cat playing in a garden",
"size": "1024x1024",
"output_filename": "cat.jpg",
"output_dir": "./my_images"
}
}Sample textual response payload (returned to the client):
图片生成成功!
提示词: A golden cat playing in a garden
模型: Qwen/Qwen-Image
保存路径: /path/to/my_images/cat.jpg
输出目录: /path/to/my_images
文件名: cat.jpg
图片URL: https://.../generated_image.jpgNotes:
Only the first image URL is used (if multiple are ever returned)
If the task fails or times out you receive a descriptive message
No base64 data is currently returned (roadmap item)
Internal Flow
Submit async generation request with header
X-ModelScope-Async-Mode: truePoll task endpoint
/v1/tasks/{task_id}every 5 seconds (max 120 attempts ~= 2 minutes)On SUCCEED download first image and save via Pillow (PIL)
Return textual metadata to MCP client
Provide clear error / timeout messages otherwise
Roadmap
Planned enhancements (not yet implemented in server.py):
Optional base64 return data
Negative prompt & guidance parameters
Adjustable polling interval & timeout via arguments
Multiple image outputs selection
Streaming progress notifications
Development
# Install all (including dev) dependencies
uv sync --dev
# Run server module directly
uv run python -m modelscope_image_mcp.server
# Or via uvx using local source
uvx --from . modelscope-image-mcp
# Run with environment variable
MODELSCOPE_SDK_TOKEN=your_token_here uv run python -m modelscope_image_mcp.server
# Format code (if ruff is configured)
uv run ruff format .
# Lint code (if ruff is configured)
uv run ruff check . --fixProject Structure
modelscope-image-mcp/
├── src/modelscope_image_mcp/
│ ├── __init__.py
│ └── server.py # Main MCP server implementation
├── pyproject.toml # Project configuration and dependencies
├── uv.lock # Lock file for reproducible builds
├── README.md # This file
└── README-zh.md # Chinese documentationTroubleshooting
Symptom | Possible Cause | Action |
ValueError: 需要设置 MODELSCOPE_SDK_TOKEN 环境变量 | Token missing | Export / set environment variable then restart |
图片生成超时 | Slow model processing | Re-run; later we will expose longer timeout argument |
网络相关 httpx.TimeoutException | Connectivity issues | Check network / retry |
PIL cannot identify image file | Invalid image data received | Try a different prompt or model |
Permission denied when saving | Output directory permissions | Check write permissions or change output_dir |
No such file or directory | Output directory doesn't exist | Server will create it automatically, or specify existing path |
Changelog
1.0.1
Added size parameter support for customizable image resolution
Improved image generation with Qwen-Image model resolution range [64x64,1664x1664]
Enhanced documentation with size parameter usage examples
1.0.0
Major update with improved async handling and output directory support
Added configurable output directory parameter
Enhanced error handling and logging
Updated dependencies to use httpx for better async support
Fixed notification_options bug from initial release
0.1.0
Initial minimal implementation with async polling & local image save
Fixed bug:
notification_optionspreviously None causing AttributeError
License
MIT License
Contributing
PRs & issues welcome. Please describe reproduction steps for any failures.
Disclaimer
This is an unofficial integration example. Use at your own risk; abide by ModelScope Terms of Service.
Available Tools
1 toolgenerate_imageC
使用ModelScope生成图片
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | 图片生成提示词 | |
| model | No | 模型名称,默认为 Qwen/Qwen-Image | Qwen/Qwen-Image |
| size | No | 生成图像分辨率大小,Qwen-Image支持:[64x64,1664x1664],默认为 '1024x1024' | 1024x1024 |
| output_filename | No | 输出图片文件名,默认为 'result_image.jpg' | result_image.jpg |
| output_dir | No | 输出目录路径,默认为 './outputs' | ./outputs |
| poll_interval_seconds | No | 轮询基础间隔(秒),默认取环境变量或 5 | |
| max_poll_attempts | No | 最大轮询次数,默认取环境变量或 120(约 10 分钟) | |
| poll_backoff | No | 是否开启指数退避,默认取环境变量或 false | |
| max_poll_interval_seconds | No | 指数退避的最大间隔(秒),默认取环境变量或 30 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions ModelScope but doesn't disclose traits like rate limits, authentication needs, cost implications, or what happens during generation (e.g., polling behavior implied by parameters). This leaves significant gaps for a tool with 9 parameters.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise with a single sentence, '使用ModelScope生成图片', which is front-loaded and wastes no words. However, it may be overly terse given the tool's complexity, potentially sacrificing clarity for brevity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (9 parameters, no output schema, no annotations), the description is incomplete. It lacks details on output format, error handling, or behavioral context, making it inadequate for an AI agent to fully understand how to invoke and interpret results effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema fully documents all 9 parameters. The description adds no additional meaning beyond the schema, such as explaining parameter interactions or usage tips. Baseline 3 is appropriate as the schema handles the heavy lifting, but the description doesn't enhance understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description '使用ModelScope生成图片' clearly states the action (generate) and resource (image) but is vague about specifics. It doesn't differentiate from siblings (none exist) but lacks detail about what ModelScope is or the generation process. It's functional but minimal.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives, prerequisites, or context. The description only states what it does without any usage instructions or exclusions, leaving the agent to infer based on the tool name and parameters alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
With only one tool, there is no possibility of confusion or overlap between tools. The single tool 'generate_image' has a clearly distinct purpose that cannot be confused with any other tools in the set.
With only one tool, naming consistency is inherently perfect. The tool name 'generate_image' follows a clear verb_noun pattern, and there are no other tools to create inconsistency with.
A single tool for an image generation server is too minimal for the apparent scope. While image generation is a core function, typical image-related servers would include additional tools for variations, editing, or management tasks, making this feel incomplete.
The server is severely incomplete for an image generation domain. It only provides generation with no tools for editing images, creating variations, managing generated content, or handling different parameters or styles, which are common in such systems.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Create images and videos from prompts, with options for image mixing, reference images, and start/…
Create and manage AI image and video generations through Quriov's fixed public MCP tools.
Multi-model AI image and video generator. 14 models behind one OAuth-secured MCP endpoint.
Generate images, video, music, voice and 3D through one API. 30 tools, 200+ models.
Related MCP Servers
- FlicenseBqualityDmaintenanceEnables AI-powered text-to-image generation using Volcengine's API with support for multiple image sizes, customizable parameters like guidance scale and seed, and flexible output formats.1
- AlicenseAqualityCmaintenanceEnables AI image generation using Doubao Seedream models and video generation using Doubao Seedance models through Volcano Engine's API, supporting text-to-image, image-to-image, text-to-video, and task status queries.3263MIT
- AlicenseBqualityDmaintenanceEnables text-to-image generation through the ModelScope platform using the Qwen/Qwen-Image model. It supports customizable parameters such as negative prompts, resolution, and sampling steps within MCP-compatible clients.1181MIT
- AlicenseAqualityBmaintenanceEnables text-to-image generation using Alibaba Cloud's Qwen-Image models, supporting both synchronous and asynchronous modes with configurable parameters.4MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zym9863/modelscope-image-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server