Image Generation MCP Server

by Ichigo3766
Verified

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Provides text-to-image generation capabilities by connecting to a Stable Diffusion WebUI instance, allowing image generation, model selection, and image upscaling through the API.

image-gen MCP 服务器

使用稳定的 Diffusion WebUI API(ForgeUI/AUTOMATIC-1111)提供文本到图像生成功能的 MCP 服务器。

安装

先决条件

  • Node.js
  • 访问已启用 API 的稳定 Diffusion WebUI 实例
  • WebUI 启动时必须启用--api标志

设置

  1. 克隆存储库:
git clone https://github.com/Ichigo3766/image-gen-mcp.git cd image-gen-mcp
  1. 安装依赖项:
npm install
  1. 构建服务器:
npm run build
  1. 将服务器配置添加到您的环境中:
{ "mcpServers": { "image-gen": { "command": "node", "args": [ "/path/to/image-gen-mcp/build/index.js" ], "env": { "SD_WEBUI_URL": "http://your-sd-webui-url:7860", "SD_AUTH_USER": "your-username", // Optional: if authentication is enabled "SD_AUTH_PASS": "your-password", // Optional: if authentication is enabled "SD_OUTPUT_DIR": "/path/to/output/directory", "SD_RESIZE_MODE": "0", // Optional: upscaling mode (0=multiplier, 1=dimensions) "SD_UPSCALE_MULTIPLIER": "4", // Optional: default upscale multiplier "SD_UPSCALE_WIDTH": "512", // Optional: default upscale width "SD_UPSCALE_HEIGHT": "512", // Optional: default upscale height "SD_UPSCALER_1": "R-ESRGAN 4x+", // Optional: default primary upscaler "SD_UPSCALER_2": "None" // Optional: default secondary upscaler } } } }

将环境变量替换为您的值:

  • SD_WEBUI_URL :您的稳定 Diffusion WebUI 实例的 URL
  • SD_AUTH_USER :基本身份验证的用户名(如果启用)
  • SD_AUTH_PASS :基本身份验证的密码(如果启用)
  • SD_OUTPUT_DIR :生成的图像的保存目录
  • SD_RESIZE_MODE :默认放大模式(0 表示乘数,1 表示尺寸)
  • SD_UPSCALE_MULTIPLIER :当 resize_mode 为 0 时默认的放大倍数
  • SD_UPSCALE_WIDTH :resize_mode 为 1 时的默认目标宽度
  • SD_UPSCALE_HEIGHT :resize_mode 为 1 时的默认目标高度
  • SD_UPSCALER_1 :默认主升频器模型
  • SD_UPSCALER_2 :默认二级升频器模型

特征

工具

  • generate_image - 使用稳定扩散生成图像
    • 参数:
      • prompt (必需):所需图像的文本描述
      • negative_prompt :需要从图像中排除的内容
      • steps :采样步数(默认值:4,范围:1-150)
      • width :图像宽度(默认值:1024,范围:512-2048)
      • height :图像高度(默认值:1024,范围:512-2048)
      • cfg_scale :CFG 比例(默认值:1,范围:1-30)
      • sampler_name :采样算法(默认值:“欧拉”)
      • scheduler_name :调度程序算法(默认值:“简单”)
      • seed :随机种子(-1 表示随机)
      • batch_size :要生成的图像数量(默认值:1,最大值:4)
      • restore_faces :启用面部恢复
      • tiling :生成可平铺的图像
      • output_path :生成图像的自定义输出路径
  • get_sd_models - 获取可用的稳定扩散模型列表
    • 无需参数
    • 返回模型名称数组
  • set_sd_model - 设置活动的稳定扩散模型
    • 参数:
      • model_name (必需):要设置为活动的模型的名称
  • get_sd_upscalers - 获取可用的升级器模型列表
    • 无需参数
    • 返回升频器名称数组
  • upscale_images - 使用稳定扩散对一个或多个图像进行升级
    • 参数:
      • images (必需):要放大的图像文件路径数组
      • resize_mode :0 为乘数模式,1 为维度模式(默认值:来自环境)
      • upscaling_resize :当 resize_mode=0 时放大倍数(默认值:来自环境)
      • upscaling_resize_w :当 resize_mode=1 时,目标宽度(以像素为单位)(默认值:来自环境)
      • upscaling_resize_h :当 resize_mode=1 时,目标高度(以像素为单位)(默认值:来自环境)
      • upscaler_1 :主要升级模型(默认值:来自环境)
      • upscaler_2 :二级升频器模型(默认值:来自环境)
      • output_path :放大图像的自定义输出目录

发展

对于使用自动重建的开发:

npm run watch

错误处理

常见问题及解决方案:

  1. 确保您的稳定扩散 WebUI 使用--api标志运行
  2. 检查是否可以从运行 MCP 服务器的位置访问 WebUI URL
  3. 如果使用身份验证,请确保凭据正确
  4. 验证输出目录是否存在并且具有写入权限
  5. 放大时,确保输入图像文件存在且可读

执照

此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

与 Stable Diffusion WebUI 集成的 MCP 服务器可通过简单的 API 调用提供文本到图像生成和图像升级功能。

  1. Installation
    1. Prerequisites
    2. Setup
  2. Features
    1. Tools
  3. Development
    1. Error Handling
      1. License
        ID: o3a86vil7b