SiliconFlow Image Generator MCP Server
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., "@SiliconFlow Image Generator MCP ServerCreate a futuristic city skyline at sunset, save as city-sunset.png"
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.
SiliconFlow Image Generator MCP Server
一个功能强大的 Model Context Protocol (MCP) 服务器,通过 SiliconFlow API 实现高质量的图片生成。
✨ 功能特性
🎨 多模型支持 - 支持 Qwen、Flux 等多种图片生成模型
🚀 高性能 - 内置请求队列和并发控制(最多3个并发请求)
🔄 智能重试 - 自动重试机制(最多3次),采用指数退避策略
📁 自动保存 - 自动下载并保存生成的图片到本地文件系统
✅ 参数验证 - 完善的输入验证,包括文件名、扩展名、尺寸等
📊 详细日志 - 开发模式下提供详细的日志输出
🛡️ 错误处理 - 智能错误分类和处理,区分客户端错误和服务器错误
📦 灵活安装 - 支持 npm 全局安装、npx 直接使用和本地开发
Related MCP server: Seedream 4.0 MCP
📋 系统要求
Node.js: >= 18.0.0
npm 或 yarn
SiliconFlow API Key(从 SiliconFlow 官网 获取)
🚀 安装和设置
方法 1: 通过 npm 全局安装(推荐)
npm install -g @siliconflow/mcp-image-generator方法 2: 通过 npx 直接使用(无需安装)
npx @siliconflow/mcp-image-generator方法 3: 本地开发安装
git clone https://github.com/siliconflow/mcp-image-generator.git
cd mcp-image-generator
npm install⚙️ 配置 MCP 服务器
1. 获取 SiliconFlow API Key
注册或登录账户
进入控制台,在 API Keys 页面创建新的 API Key
复制生成的 API Key(格式类似:
sk-xxxxxxxxxxxx)
2. 配置 MCP 服务器
在您的 MCP 配置文件中(通常是 ~/.config/claude/settings.json 或类似路径),添加以下配置:
使用 npm 全局安装版本:
{
"mcpServers": {
"siliconflow-images": {
"command": "siliconflow-image-gen",
"args": [],
"env": {
"SILICONFLOW_API_KEY": "your_siliconflow_api_key_here"
}
}
}
}使用 npx 版本:
{
"mcpServers": {
"siliconflow-images": {
"command": "npx",
"args": ["-y", "@siliconflow/mcp-image-generator"],
"env": {
"SILICONFLOW_API_KEY": "your_siliconflow_api_key_here"
}
}
}
}使用本地开发版本:
{
"mcpServers": {
"siliconflow-images": {
"command": "node",
"args": ["/absolute/path/to/mcp-image-generator/index.js"],
"env": {
"SILICONFLOW_API_KEY": "your_siliconflow_api_key_here"
}
}
}
}3. 验证配置
配置完成后,重启您的 MCP 客户端(如 Claude Desktop),服务器应该会自动连接并可用。
📖 使用方法
配置完成后,在支持 MCP 的客户端中,您可以使用以下工具:
generate_image
根据文本提示词生成图片并保存到本地文件系统。
参数说明
参数 | 类型 | 必需 | 默认值 | 说明 |
| string | ✅ | - | 描述想要生成的图片的详细提示词(建议100-800字符,英文效果更佳) |
| string | ✅ | - | 保存的文件名,必须包含扩展名(如 |
| string | ❌ |
| 图片保存的相对路径(相对于当前工作目录) |
| string | ❌ |
| 使用的模型名称 |
| string | ❌ |
| 图片尺寸 |
支持的文件扩展名
.jpg/.jpeg.png.webp
支持的图片尺寸
1024x1024- 正方形720x1280- 竖屏1280x720- 横屏1664x928- 宽屏(默认)
支持的模型
Qwen/Qwen-Image(默认)black-forest-labs/FLUX.1-schnellblack-forest-labs/FLUX.1-dev以及其他 SiliconFlow 支持的图片生成模型
使用示例
示例 1: 生成博客封面
生成一张关于"科技未来感城市夜景"的博客封面图片,文件名为"tech-city-cover.png"示例 2: 生成头像
生成一个可爱的卡通猫咪头像,文件名为"cat-avatar.png",尺寸为1024x1024示例 3: 生成横幅
生成一张现代简约风格的横幅图片,主题是"数字化转型",文件名为"digital-banner.png",尺寸为1280x720返回结果
成功生成图片后,将返回以下信息:
图片生成成功!
📁 保存路径: /absolute/path/to/images/filename.png
📏 文件大小: 1234 KB
🎨 生成时间: 5.2s
⏱️ 总耗时: 5.3s
🔧 模型: Qwen/Qwen-Image
📐 尺寸: 1664x928🔧 工作原理
架构流程
用户请求 → MCP 客户端 → MCP 服务器 → SiliconFlow API
↓
图片生成
↓
下载图片
↓
保存到本地
↓
返回结果核心组件
请求队列管理器 (RequestQueue)
控制并发请求数量(默认最多3个)
防止 API 速率限制
优化资源使用
图片生成器 (ImageGenerator)
参数验证
API 调用
图片下载
文件保存
日志记录器 (Logger)
开发模式下输出详细日志
记录操作过程和错误信息
性能优化
并发控制: 最多3个并发请求,避免 API 速率限制
自动重试: 最多3次重试,采用指数退避策略(1s, 2s, 4s)
智能错误处理: 区分客户端错误(4xx)和服务器错误(5xx)
文件大小统计: 自动计算并显示文件大小
🛠️ 开发信息
项目结构
mcp-image-generator/
├── index.js # 主程序文件
├── package.json # 项目配置
├── README.md # 项目文档
├── LICENSE # MIT 许可证
└── .gitignore # Git 忽略文件依赖项
包名 | 版本 | 用途 |
| ^1.0.4 | MCP SDK |
| ^1.7.9 | HTTP 请求库 |
| ^16.4.7 | 环境变量管理 |
环境变量
变量名 | 必需 | 说明 |
| ✅ | SiliconFlow API 密钥 |
| ❌ | 环境模式(设置为 |
开发模式
启用开发模式以查看详细日志:
NODE_ENV=development siliconflow-image-gen或在 MCP 配置中添加:
{
"env": {
"SILICONFLOW_API_KEY": "your_api_key",
"NODE_ENV": "development"
}
}⚠️ 注意事项
API Key 安全
不要将 API Key 提交到版本控制系统
定期轮换 API Key
使用环境变量管理敏感信息
文件命名
文件名必须包含扩展名
避免使用特殊字符:
< > : " / \ | ? *建议使用有意义的文件名
提示词优化
英文提示词通常效果更好
建议长度:100-800 字符
最大长度:8000 字符
描述越详细,生成效果越好
性能考虑
图片生成通常需要 5-30 秒
并发请求受限于 API 速率限制
大尺寸图片生成时间更长
存储空间
确保有足够的磁盘空间
定期清理不需要的图片
默认保存在
./images目录
🔍 故障排除
错误:SILICONFLOW_API_KEY 环境变量未设置
症状: 服务器启动失败或工具调用失败
解决方案:
确保在 MCP 配置文件的
env部分正确设置了SILICONFLOW_API_KEY检查 API Key 格式是否正确(通常以
sk-开头)重启 MCP 客户端使配置生效
错误:API 请求失败 (401 Unauthorized)
症状: 返回 "API 请求失败 (401): Unauthorized"
解决方案:
检查 API Key 是否正确
确认 API Key 未过期或被撤销
验证 API Key 是否有足够的权限
错误:API 请求失败 (429 Too Many Requests)
症状: 返回 "API 请求失败 (429): Too Many Requests"
解决方案:
减少并发请求数量
等待一段时间后重试
检查账户配额是否已用完
错误:参数验证失败
症状: 返回 "参数验证失败: ..."
解决方案:
检查
prompt是否为非空字符串确保
filename包含有效的扩展名验证
image_size是否在支持的尺寸列表中检查文件名是否包含非法字符
错误:保存文件失败
症状: 返回 "保存文件失败: ..."
解决方案:
检查输出目录的写入权限
确保磁盘空间充足
验证文件名是否包含非法字符
检查路径是否过长
错误:图片生成失败,已尝试 3 次
症状: 返回 "图片生成失败,已尝试 3 次: ..."
解决方案:
检查网络连接是否正常
确认 SiliconFlow API 服务是否可用
验证账户余额是否充足
尝试使用不同的模型或参数
调试技巧
启用开发模式查看详细日志:
{
"env": {
"SILICONFLOW_API_KEY": "your_api_key",
"NODE_ENV": "development"
}
}日志将显示:
API 请求详情
响应状态
错误信息
性能指标
📝 更新日志
v1.0.0 (2024-12-25)
✨ 初始版本发布
🎨 支持 SiliconFlow API 图片生成
🚀 支持多种模型(Qwen、Flux 等)
📦 支持 npm 全局安装和 npx 使用
🔄 内置请求队列和并发控制
🛡️ 完善的错误处理和重试机制
📊 详细的日志记录和性能统计
✅ 完整的参数验证
🤝 贡献
欢迎提交 Issue 和 Pull Request!
贡献指南
Fork 本仓库
创建特性分支 (
git checkout -b feature/AmazingFeature)提交更改 (
git commit -m 'Add some AmazingFeature')推送到分支 (
git push origin feature/AmazingFeature)开启 Pull Request
📄 许可证
本项目采用 MIT 许可证 - 详见 LICENSE 文件
🔗 相关链接
💬 支持
如有问题或建议,请:
Made with ❤️ by SiliconFlow MCP Team
Available Tools
1 toolgenerate_imageA
使用 SiliconFlow API 生成图片并保存到本地文件系统。 支持异步轮询获取图片,避免超时问题。 适用于博客封面、头像等各种场景的图片生成。
性能优化:
支持并发控制(最多3个并发请求)
自动重试机制(最多3次)
智能错误处理和分类
文件大小统计
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | 使用的模型名称 | Qwen/Qwen-Image |
| prompt | Yes | 描述想要生成的图片的详细提示词(建议100-800字符,英文效果更佳) | |
| filename | Yes | 保存的文件名,例如 'blog-cover-01.png'(必须包含扩展名) | |
| image_size | No | 图片尺寸 | 1664x928 |
| output_dir | No | 图片保存的相对路径(相对于当前工作目录) | ./images |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It goes beyond a basic summary by mentioning asynchronous polling, concurrency control (max 3), automatic retry (max 3), intelligent error handling, and file size statistics. However, it does not disclose whether existing files are overwritten or what the return value looks like, which would be useful.
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 front-loaded with the main purpose and then provides additional context and performance optimizations. It is not overly long, though the bullet list could be condensed without losing value. Overall, it is well-structured and efficient.
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?
The tool has no output schema, so the description needs to clarify what the tool returns (e.g., file path, success message). It only says the image is saved to the local file system, leaving the return value ambiguous. The described behaviors and parameters are well covered, but the missing output information makes it incomplete.
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?
The input schema has 100% coverage for all five parameters, including descriptions, defaults, and enums. The description adds no extra parameter-specific meaning beyond the schema, so the baseline score of 3 is appropriate.
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 clearly states that it generates images using the SiliconFlow API and saves them to the local file system. It also mentions asynchronous polling and use cases (blog covers, avatars), making the tool's purpose specific and distinct, even without sibling tools.
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?
The description provides clear context for when to use the tool (e.g., blog covers, avatars) and mentions performance optimizations like concurrency and retry. It does not explicitly exclude any scenarios or name alternatives, but since no sibling tools exist, this is acceptable.
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 between tools. The tool's purpose is clearly stated in its description, making it unambiguous.
The tool name 'generate_image' follows a standard verb_noun convention, which is clear and predictable. Even with a single tool, the naming is consistent and appropriate.
Having only one tool is too few for a server that might support a broader image generation workflow. The description hints at various use cases but provides no additional management or utility tools, making the tool set feel underdeveloped.
The single tool covers the primary task of generating and saving an image, which is the core functionality. However, there are no additional tools for listing, retrieving, or managing generated images, which could be considered minor gaps depending on the workflow.
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/…
Generate images, video, music, voice and 3D through one API. 30 tools, 200+ models.
Multi-model AI image and video generator. 14 models behind one OAuth-secured MCP endpoint.
Image, video, music and text generation across 100+ models through one endpoint.
Related MCP Servers
- FlicenseNot gradedqualityFmaintenanceEnables AI image generation using Doubao's Seedream 4.0 model through natural language prompts. Automatically downloads generated images to local directories with configurable parameters like resolution, watermarks, and batch generation.8
- AlicenseAqualityAmaintenanceEnables AI image generation through Volcano Engine's Seedream 4.0 API, supporting text-to-image, image-to-image, multi-image fusion, and sequential generation with automatic local saving and Markdown support.521MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI-powered image generation using Volcengine's Doubao model with customizable aspect ratios (1:1, 4:3, 16:9, 3:4, 9:16) and file management. Supports high-quality text-to-image generation with automatic retry, error handling, and flexible save path configuration.21
- AlicenseNot gradedqualityCmaintenanceEnables image generation using Jimeng AI (Doubao Seedream 4.0) via APICore, supporting text-to-image, image-to-image, multi-image fusion, and batch generation.2MIT
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/Gzmomo001/mcp-image-generator'
If you have feedback or need assistance with the MCP directory API, please join our Discord server