Skip to main content
Glama
mikeyny

Image Generation MCP Server

by mikeyny

图像生成 MCP 服务器

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

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

特征

  • 根据文本提示生成图像

  • 可配置图像参数(分辨率、宽高比、质量)

  • 将生成的图像保存到指定目录

  • 完全符合 MCP 协议

  • 错误处理和验证

Related MCP server: Together AI Image Server

先决条件

  • 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 问题)

  • 服务器错误(文件系统、权限)

  • 未知错误(意外问题)

每个错误响应包括:

  • 错误代码

  • 人类可读的消息

  • 详细错误信息

执照

国际学习中心

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

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

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