Skip to main content
Glama

Image Gen MCP

用于通过 OpenAI 图像模型生成和编辑图像的 TypeScript MCP 服务器。

服务器注册 generate_imageedit_image 工具,然后将返回的图像字节写入磁盘。Stdio 模式写入请求的绝对文件路径;SSE 和 streamable HTTP 自动保存文件并返回图像 URL。

环境变量

名称

必填

默认值

描述

BASE_URL

AI SDK 的 OpenAI 默认值

OpenAI API URL 前缀,例如 https://api.openai.com/v1。根 URL 会自动追加 /v1

API_KEY

-

OpenAI API 密钥。

MODEL

gpt-image-2

OpenAI 图像模型。

FILE_DIR

./data

SSE/HTTP 模式下自动保存文件的目录。Docker 默认其为 /data

Related MCP server: OpenAI GPT-Image MCP Server

工具

generate_image

参数:

名称

必填

默认值

描述

prompt

-

图像提示词。

filepath

Stdio

-

仅限 Stdio。绝对输出路径。父目录会自动创建。

n

1

图像数量,从 13

size

auto

auto256x256512x5121024x10241536x10241024x15361792x10241024x1792

quality

medium

lowmediumhighauto

background

-

transparentopaqueauto

output_format

png

pngjpegjpgwebpjpg 会作为 jpeg 发送。

output_compression

-

压缩级别,从 0100

moderation

-

autolow

overwrite

Stdio

false

仅限 Stdio。允许替换现有输出文件。

在调用上游 API 之前,会先验证已知的模型尺寸限制。例如,gpt-image-* 模型支持 1024x10241536x10241024x1536dall-e-2 支持 256x256512x5121024x1024

n > 1 时,类似 /tmp/image.png 的文件路径会变成 /tmp/image-1.png/tmp/image-2.png,依此类推。

在 SSE 和 streamable HTTP 模式下,filepathoverwrite 不会被暴露。生成的文件会保存为 ${FILE_DIR}/YYYY-MM-DD/<uuid>.<ext>,并通过类似 http://localhost:3000/file/YYYY-MM-DD/<uuid>.png 的 URL 返回。

edit_image

参数:

名称

必填

默认值

描述

prompt

-

编辑指令。

image_path

-

待编辑源图像的绝对路径。

mask_path

-

可选的编辑蒙版图像绝对路径。

filepath

Stdio

-

仅限 Stdio。绝对输出路径。父目录会自动创建。

n

1

编辑后的图像数量,从 13

size

auto

auto256x256512x5121024x10241536x10241024x15361792x10241024x1792

quality

medium

lowmediumhighauto

background

-

编辑后图像的背景行为。

output_format

png

pngjpegjpgwebpjpg 会作为 jpeg 发送。

output_compression

-

压缩级别,从 0100

moderation

-

autolow

overwrite

Stdio

false

仅限 Stdio。允许替换现有输出文件。

该工具通过 multipart 表单数据调用兼容 OpenAI 的 /images/edits 端点。输出文件遵循与 generate_image 相同的文件路径和自动保存行为。

开发

pnpm install
pnpm dev

有用的检查:

pnpm check
pnpm build

Stdio MCP 配置

{
  "mcpServers": {
    "image-gen-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["image-gen-mcp"],
      "env": {
        "BASE_URL": "https://api.openai.com/v1",
        "API_KEY": "sk-...",
        "MODEL": "gpt-image-2"
      }
    }
  }
}

Streamable HTTP

{
  "mcpServers": {
    "image-gen-mcp": {
      "type": "http",
      "url": "http://localhost:3000/mcp",
      "headers": {
        "openai-base-url": "https://api.openai.com/v1",
        "openai-api-key": "sk-...",
        "openai-model": "gpt-image-2"
      }
    }
  }
}

请求头会覆盖服务端的环境变量配置;省略它们则回退到环境变量值。Docker 镜像在 3000 端口上运行 streamable HTTP。

SSE

SSE 传输层位于 src/sse.ts,在 /mcp 上监听 PORT(默认 4000),消息发布到 /message。可以通过 pnpm start:sse 直接运行;Docker 镜像不会启动它。

{
  "mcpServers": {
    "image-gen-mcp": {
      "type": "sse",
      "url": "http://localhost:4000/mcp",
      "headers": {
        "openai-api-key": "sk-..."
      }
    }
  }
}

Docker

docker build -t image-gen-mcp .
docker run --rm -p 3000:3000 \
  # 也可忽略apiKey,让使用方 headers 中传递
  -e BASE_URL=https://api.openai.com/v1 \
  -e API_KEY=sk-... \
  -e MODEL=gpt-image-2 \
  -v image-gen-data:/data \
  image-gen-mcp
Install Server
F
license - not found
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Generate AI images, video, music, and sound effects, and upscale them, from any MCP client.

  • LLM chat, text summarization and AI image generation

  • OCR, transcription, file extraction, and image generation for AI agents via MCP.

View all MCP Connectors

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

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