Skip to main content
Glama
rmcendarfer2017

Image Generator MCP Server

图像生成器 MCP 服务器

使用 Replicate 生成图像并允许用户保存它们的 MCP 服务器。

成分

资源

服务器实现一个图像存储系统,其具有:

  • 用于访问单独生成的图像的自定义 image:// URI 方案

  • 每个图像资源都有一个基于其提示的名称、带有创建日期的描述以及 image/png mimetype

提示

服务器提供一个提示:

  • 生成图像:使用稳定扩散创建生成图像的提示

    • 可选的“style”参数来控制图像风格(现实/艺术/抽象)

    • 生成带有特定样式指导的提示模板

工具

该服务器实现了三个工具:

  • 生成图像:使用 Replicate 的稳定扩散模型生成图像

    • 将“prompt”作为必需的字符串参数

    • 可选参数包括“negative_prompt”、“width”、“height”、“num_inference_steps”和“guidance_scale”

    • 返回生成的图像及其 URL

  • save-image:将生成的图像保存到本地文件系统

    • 将“image_url”和“prompt”作为必需的字符串参数

    • 为图像生成唯一 ID,并将其保存到“generated_images”目录

  • list-saved-images:列出所有已保存的图像

    • 返回所有已保存图像及其元数据和缩略图的列表

Related MCP server: gemini-image-mcp

配置

复制 API 令牌

要使用此图像生成器,您需要一个复制 API 令牌:

  1. 在Replicate创建帐户

  2. 从https://replicate.com/account获取您的 API 令牌

  3. 根据提供的.env.example模板创建一个.env文件:

REPLICATE_API_TOKEN=your_replicate_api_token_here

重要提示: .env文件已通过.gitignore排除在版本控制之外,以防止意外泄露您的 API 令牌。切勿将敏感信息提交到您的代码库。

环境设置

  1. 克隆存储库:

git clone https://github.com/yourusername/image-generator.git
cd image-generator
  1. 创建并激活虚拟环境:

# Using venv
python -m venv .venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate
  1. 安装依赖项:

pip install -r requirements.txt
  1. 按照上述说明设置.env文件

快速入门

安装

克劳德桌面

在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

用法

服务器运行后,您可以:

  1. 使用带有描述性提示的“generate-image”工具生成图像

  2. 使用“save-image”工具,通过图片 URL 和提示保存生成的图片

  3. 使用“list-saved-images”工具查看所有已保存的图像

  4. 通过资源列表访问已保存的图像

发展

构建和发布

准备分发包:

  1. 同步依赖项并更新锁文件:

uv sync
  1. 构建软件包分发版:

uv build

这将在dist/目录中创建源和轮子分布。

  1. 发布到 PyPI:

uv publish

注意:您需要通过环境变量或命令标志设置 PyPI 凭据:

  • 令牌: --token或UV_PUBLISH_TOKEN

  • 或用户名/密码: --username / UV_PUBLISH_USERNAME和--password / UV_PUBLISH_PASSWORD

调试

由于 MCP 服务器通过 stdio 运行,调试起来可能比较困难。为了获得最佳调试体验,我们强烈建议使用MCP Inspector 。

您可以使用以下命令通过npm启动 MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory B:\NEWTEST\image-generator run image-generator

启动后,检查器将显示一个 URL,您可以在浏览器中访问该 URL 以开始调试。

Available Tools

3 tools
generate-imageC

Generate an image using Replicate's Stable Diffusion model

ParametersJSON Schema
NameRequiredDescriptionDefault
widthNo
heightNo
promptYes
guidance_scaleNo
negative_promptNo
num_inference_stepsNo

TDQS

C2.6/5.0
Behavior2/5

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

No annotations provided, so the description alone must disclose behavior. It only states image generation, but omits whether the image is returned directly, saved, or streamed. No mention of rate limits, authentication, or potential side effects.

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

Conciseness4/5

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

The description is a single sentence, concise and front-loaded. However, it might be too terse, sacrificing critical details. Every word earns its place, but more information would improve usability.

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?

Given 6 parameters, no output schema, and no annotations, the description is incomplete. It fails to clarify whether output is a URL, base64, or file path. Critical for an agent to use correctly.

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

Parameters1/5

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

Schema description coverage is 0%, and the description provides no explanation of parameters beyond their existence. Values like 'guidance_scale', 'num_inference_steps', and 'negative_prompt' are left undefined. The agent must infer their purpose from names or defaults.

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 'Generate an image using Replicate's Stable Diffusion model', which identifies the verb (generate), resource (image), and model. It distinguishes from siblings 'list-saved-images' and 'save-image'. However, it could be more precise by specifying 'from a text prompt'.

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?

No guidance on when to use this tool versus alternatives. No mention of prerequisites, output handling, or when not to use it. The description assumes the agent already knows to use this for generation.

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

list-saved-imagesA

List all saved images

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.7/5.0
Behavior2/5

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

With no annotations, the description carries full burden. It only states 'List all saved images' but lacks details on pagination, ordering, or behavior when no images 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 with one short sentence, front-loaded with the key action and resource. No wasted words.

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

Completeness5/5

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

Given no parameters and a simple output (likely an array of saved images), the description fully explains the tool's purpose without needing further elaboration.

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

Parameters4/5

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

There are no parameters, and schema coverage is 100%. The description implicitly means no arguments are needed, which is sufficient and adds no extra confusion.

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

Purpose5/5

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

The description clearly states the verb 'List' and the resource 'all saved images'. It distinguishes this tool from its siblings 'generate-image' and 'save-image' by specifying a different action.

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 the sibling tools. It does not state any prerequisites or context for using this list operation.

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

save-imageC

Save a generated image

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes
image_urlYes
custom_filenameNoCustom filename for the saved image (without extension). If not provided, a UUID will be used.
target_directoryNoDirectory path where the image should be saved. If not provided, defaults to the MCP server's images directory.

TDQS

C2.5/5.0
Behavior2/5

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

With no annotations, the description bears full responsibility for behavioral disclosure. It only states 'Save a generated image' without detailing side effects (e.g., whether it overwrites existing files, required permissions, or error handling). This is insufficient for an agent to understand the tool's behavior beyond a basic save operation.

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

Conciseness3/5

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

The description is a single sentence, which is concise, but it sacrifices informativeness. It could be restructured to include key details without being verbose. Every sentence should add value, and this one is too vague.

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

Completeness1/5

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

Given the tool's complexity (4 parameters, no output schema, no annotations), the description is extremely incomplete. It does not explain return values, error conditions, or the result of saving. The agent cannot reliably invoke this tool based solely on this description.

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?

Schema coverage is 50% (custom_filename and target_directory have descriptions in schema, but required params prompt and image_url do not). The description adds no information about any parameter, failing to compensate for the missing schema descriptions. It does not explain what image_url or prompt mean for this tool.

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 'Save a generated image' clearly identifies the verb (save) and resource (generated image), and it distinguishes from sibling tools 'generate-image' (which creates but does not persist) and 'list-saved-images' (which lists existing saves). However, it could be more specific about the storage location or context.

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 vs alternatives. It does not state that this should be used after an image is generated, nor does it mention scenarios where this tool might be inappropriate. With siblings like generate-image and list-saved-images, explicit usage context is missing.

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. 3 tool updatesv1.0.1
    • First observedgenerate-image
    • First observedlist-saved-images
    • First observedsave-image

TDQS

B3.2/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: generating images, listing saved images, and saving images. No overlap or ambiguity.

Naming Consistency5/5

All tools follow a consistent verb_noun snake_case pattern (generate-image, list-saved-images, save-image), making them predictable.

Tool Count4/5

3 tools is appropriate for a focused image generator server, covering the core workflow. Slightly minimal but not overly sparse.

Completeness4/5

Covers generation, listing, and saving. Missing a delete or update tool, but the core lifecycle is intact and agents can work without major gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers