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: replicate-flux-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 问题)

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

  • 未知错误(意外问题)

每个错误响应包括:

  • 错误代码

  • 人类可读的消息

  • 详细错误信息

执照

国际学习中心

Available Tools

1 tool
generate-imageC

Generate an image based on a prompt

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes
output_dirYesFull absolute path to output directory. For Windows, use double backslashes like 'C:\\Users\\name\\path'. For Unix/Mac use '/path/to/dir'. Always use the proper path otherwise you will get an error.
filenameNoBase filename to save the image(s) with
go_fastNo
megapixelsNo
num_outputsNo
aspect_ratioNo
output_formatNo
output_qualityNo
num_inference_stepsNo

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the core action (generating images from prompts) but lacks critical behavioral details like whether this is a local or cloud operation, rate limits, authentication requirements, error handling, or what happens when files are saved. The description doesn't contradict annotations since none exist.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 5 words, front-loaded with the core functionality. Every word earns its place, and there's no wasted text or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 10 parameters, no annotations, no output schema, and low schema description coverage, the description is severely inadequate. It doesn't explain what the tool returns, how outputs are structured, error conditions, or provide enough context for an agent to use it effectively beyond the most basic invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With only 20% schema description coverage, the description must compensate but fails to do so. It mentions 'based on a prompt' which hints at one parameter but doesn't explain the other 9 parameters or their relationships. The description adds minimal value beyond what's already in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('generate') and resource ('image'), and specifies it's based on a prompt. It's unambiguous about what the tool does, though it doesn't distinguish from siblings since there are none.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, nor any context about prerequisites or limitations. It simply states what the tool does without indicating appropriate use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool update
    • First observedgenerate-image

TDQS

B3/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion or overlap between tools. The single tool 'generate-image' has a clear and distinct purpose for image generation based on prompts.

Naming Consistency5/5

The single tool name 'generate-image' follows a clear verb_noun pattern. Since there is only one tool, consistency is inherently perfect with no deviations or mixed conventions to evaluate.

Tool Count2/5

A single tool is too few for a server named 'Image Generation MCP Server', which suggests a broader scope. While it covers basic generation, typical image generation domains might include variations, edits, or management tools, making this feel thin and incomplete.

Completeness2/5

The tool surface is severely incomplete for image generation. It only provides generation, with no tools for editing, resizing, filtering, or managing images, leaving obvious gaps that will limit agent capabilities in this domain.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers