Skip to main content
Glama

Image Generation MCP Server

by mikeyny

图像生成 MCP 服务器

使用 Replicate 的black-forest-labs/flux-schnell模型生成图像的MCP(模型上下文协议)服务器实现。

理想情况下与 Cursor 的 MCP 功能一起使用,但可以与任何 MCP 客户端一起使用。

特征

  • 根据文本提示生成图像
  • 可配置图像参数(分辨率、宽高比、质量)
  • 将生成的图像保存到指定目录
  • 完全符合 MCP 协议
  • 错误处理和验证

先决条件

  • Node.js 16+
  • 复制 API 令牌
  • 适用于 MCP 的 TypeScript SDK

设置

  1. 克隆存储库
  2. 安装依赖项:
    npm install
  3. 通过更新apiToken常量,直接在src/imageService.ts代码中添加您的 Replicate API 令牌:
    // No environment variables are used since they can't be easily set in cursor const apiToken = "your-replicate-api-token-here";

    **注意:**如果与 Claude 一起使用,您可以在根目录中创建一个.env文件并在那里设置您的 API 令牌:

    REPLICATE_API_TOKEN=your-replicate-api-token-here
    然后构建项目:
    npm run build

用法

与游标一起使用:

  1. 前往“设置”
  2. 选择功能
  3. 向下滚动到“MCP 服务器”
  4. 点击“添加新的 MCP 服务器”
  5. 将类型设置为“命令”
  6. 将命令设置为: node ./path/to/dist/server.js

API 参数

范围类型必需的默认描述
prompt细绳是的-图像生成的文字提示
output_dir细绳是的-保存生成的图像的服务器目录路径
go_fast布尔值错误的启用更快的生成模式
megapixels细绳“1”分辨率质量(“1”、“2”、“4”)
num_outputs数字1生成的图像数量(1-4)
aspect_ratio细绳“1:1”宽高比(“1:1”、“4:3”、“16:9”)
output_format细绳“webp”图像格式(“webp”、“png”、“jpeg”)
output_quality数字80压缩质量(1-100)
num_inference_steps数字4去噪步数(4-20)

示例请求

{ "prompt": "black forest gateau cake spelling out 'FLUX SCHNELL'", "output_dir": "/var/output/images", "filename": "black_forest_cake", "output_format": "webp" "go_fast": true, "megapixels": "1", "num_outputs": 2, "aspect_ratio": "1:1" }

示例响应

{ "image_paths": [ "/var/output/images/output_0.webp", "/var/output/images/output_1.webp" ], "metadata": { "model": "black-forest-labs/flux-schnell", "inference_time_ms": 2847 } }

错误处理

服务器处理以下错误类型:

  • 验证错误(无效参数)
  • API 错误(重复 API 问题)
  • 服务器错误(文件系统、权限)
  • 未知错误(意外问题)

每个错误响应包括:

  • 错误代码
  • 人类可读的消息
  • 详细错误信息

执照

国际学习中心

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

hybrid server

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

使用户能够使用 Replicate 的模型从文本提示生成图像,具有可配置的参数和完全的 MCP 协议兼容性。

  1. 特征
    1. 先决条件
      1. 设置
        1. 用法
          1. API 参数
            1. 示例请求
              1. 示例响应
                1. 错误处理
                  1. 执照

                    Related MCP Servers

                    • A
                      security
                      A
                      license
                      A
                      quality
                      A MCP server that enables Claude and other MCP-compatible assistants to generate images from text prompts using Together AI's image generation models.
                      Last updated -
                      1
                      2
                      TypeScript
                      MIT License
                      • Apple
                      • Linux
                    • -
                      security
                      A
                      license
                      -
                      quality
                      Provides image generation capabilities using the Flux Schnell model on Replicate, allowing users to create images from text prompts.
                      Last updated -
                      1
                      JavaScript
                      MIT License
                    • -
                      security
                      A
                      license
                      -
                      quality
                      A MCP server that integrates with Cursor IDE to generate images based on text descriptions using JiMeng AI, allowing users to create and save custom images directly within their development environment.
                      Last updated -
                      160
                      Python
                      MIT License
                      • Apple
                      • Linux
                    • -
                      security
                      -
                      license
                      -
                      quality
                      A TypeScript-based MCP server that lets users generate images using OpenAI's dall-e-3 model by providing a prompt and image name.
                      Last updated -
                      1

                    View all related MCP servers

                    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/mikeyny/ai-image-gen-mcp'

                    If you have feedback or need assistance with the MCP directory API, please join our Discord server