image-gen-mcp
Image Gen MCP
用于通过 OpenAI 图像模型生成和编辑图像的 TypeScript MCP 服务器。
服务器注册 generate_image 和 edit_image 工具,然后将返回的图像字节写入磁盘。Stdio 模式写入请求的绝对文件路径;SSE 和 streamable HTTP 自动保存文件并返回图像 URL。
环境变量
名称 | 必填 | 默认值 | 描述 |
| 否 | AI SDK 的 OpenAI 默认值 | OpenAI API URL 前缀,例如 |
| 是 | - | OpenAI API 密钥。 |
| 否 |
| OpenAI 图像模型。 |
| 否 |
| SSE/HTTP 模式下自动保存文件的目录。Docker 默认其为 |
Related MCP server: OpenAI GPT-Image MCP Server
工具
generate_image
参数:
名称 | 必填 | 默认值 | 描述 |
| 是 | - | 图像提示词。 |
| Stdio | - | 仅限 Stdio。绝对输出路径。父目录会自动创建。 |
| 否 |
| 图像数量,从 |
| 否 |
|
|
| 否 |
|
|
| 否 | - |
|
| 否 |
|
|
| 否 | - | 压缩级别,从 |
| 否 | - |
|
| Stdio |
| 仅限 Stdio。允许替换现有输出文件。 |
在调用上游 API 之前,会先验证已知的模型尺寸限制。例如,gpt-image-* 模型支持 1024x1024、1536x1024 和 1024x1536;dall-e-2 支持 256x256、512x512 和 1024x1024。
当 n > 1 时,类似 /tmp/image.png 的文件路径会变成 /tmp/image-1.png、/tmp/image-2.png,依此类推。
在 SSE 和 streamable HTTP 模式下,filepath 和 overwrite 不会被暴露。生成的文件会保存为 ${FILE_DIR}/YYYY-MM-DD/<uuid>.<ext>,并通过类似 http://localhost:3000/file/YYYY-MM-DD/<uuid>.png 的 URL 返回。
edit_image
参数:
名称 | 必填 | 默认值 | 描述 |
| 是 | - | 编辑指令。 |
| 是 | - | 待编辑源图像的绝对路径。 |
| 否 | - | 可选的编辑蒙版图像绝对路径。 |
| Stdio | - | 仅限 Stdio。绝对输出路径。父目录会自动创建。 |
| 否 |
| 编辑后的图像数量,从 |
| 否 |
|
|
| 否 |
|
|
| 否 | - | 编辑后图像的背景行为。 |
| 否 |
|
|
| 否 | - | 压缩级别,从 |
| 否 | - |
|
| Stdio |
| 仅限 Stdio。允许替换现有输出文件。 |
该工具通过 multipart 表单数据调用兼容 OpenAI 的 /images/edits 端点。输出文件遵循与 generate_image 相同的文件路径和自动保存行为。
开发
pnpm install
pnpm dev有用的检查:
pnpm check
pnpm buildStdio 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-mcpMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables image generation using OpenAI's DALL-E and GPT-Image models directly through the Model Context Protocol. It allows users to create and save images with fine-grained control over parameters like size, quality, and background transparency.46MIT
- AlicenseAqualityCmaintenanceEnables image generation and editing using OpenAI's GPT Image API (gpt-image-1, 1.5, 2) with support for multi-image generation, history management, and batch processing.121,7841MIT
- FlicenseNot gradedqualityDmaintenanceProvides AI agents and coding assistants with image generation and editing capabilities using OpenAI's GPT-image-1 model, with support for local or Supabase storage.3
- FlicenseNot gradedqualityDmaintenanceEnables image generation and editing via OpenAI's gpt-image-1 model, with options for saving, format control, and transparency.
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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