image-gen-mcp
Provides tools for generating and editing images through OpenAI image models, supporting configurable size, quality, output format, and related options.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@image-gen-mcp generate a photorealistic image of a cozy cabin in snowy mountains"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Image Gen MCP
TypeScript MCP server for generating and editing images through OpenAI image models.
The server registers generate_image and edit_image tools, then writes the returned
image bytes to disk. Stdio mode writes to the requested absolute filepath; SSE and
streamable HTTP auto-save files and return image URLs.
Env
Name | Required | Default | Description |
| No | AI SDK OpenAI default | OpenAI API URL prefix, for example |
| Yes | - | OpenAI API key. |
| No |
| OpenAI image model. |
| No |
| Directory for auto-saved files in SSE/HTTP mode. Docker defaults this to |
Related MCP server: openai-imagegen-mcp
Tool
generate_image
Arguments:
Name | Required | Default | Description |
| Yes | - | Image prompt. |
| Stdio | - | Stdio only. Absolute output path. Parent directories are created automatically. |
| No |
| Number of images, from |
| No |
|
|
| No |
|
|
| No | - |
|
| No |
|
|
| No | - | Compression level from |
| No | - |
|
| Stdio |
| Stdio only. Allow replacing existing output files. |
Known model size limits are validated before calling the upstream API. For example,
gpt-image-* models support 1024x1024, 1536x1024, and 1024x1536; dall-e-2
supports 256x256, 512x512, and 1024x1024.
For n > 1, a filepath like /tmp/image.png becomes /tmp/image-1.png,
/tmp/image-2.png, and so on.
In SSE and streamable HTTP modes, filepath and overwrite are not exposed. Generated
files are saved as ${FILE_DIR}/YYYY-MM-DD/<uuid>.<ext> and returned with URLs like
http://localhost:3000/file/YYYY-MM-DD/<uuid>.png.
edit_image
Arguments:
Name | Required | Default | Description |
| Yes | - | Edit instruction. |
| Yes | - | Absolute path to the source image to edit. |
| No | - | Optional absolute path to the edit mask image. |
| Stdio | - | Stdio only. Absolute output path. Parent directories are created automatically. |
| No |
| Number of edited images, from |
| No |
|
|
| No |
|
|
| No | - | Edited image background behavior. |
| No |
|
|
| No | - | Compression level from |
| No | - |
|
| Stdio |
| Stdio only. Allow replacing existing output files. |
The tool calls the OpenAI-compatible /images/edits endpoint with multipart form data.
Output files follow the same filepath and auto-save behavior as generate_image.
Development
pnpm install
pnpm devUseful checks:
pnpm check
pnpm buildStdio MCP Config
{
"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"
}
}
}
}Headers override the server-side env config; omit them to fall back to the env values. The Docker image runs streamable HTTP on port 3000.
SSE
The SSE transport lives in src/sse.ts and listens on PORT (default 4000)
at /mcp, with messages posted to /message. Run it directly with
pnpm start:sse; it is not started by the Docker image.
{
"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-mcpAvailable Tools
2 toolsedit_imageA
Edit image(s) with the OpenAI Images Edit API. SSE/HTTP transports auto-save files and return image URLs; stdio requires filepath.
Inputs: prompt (required), filepath (required), image_path (required), n, +8 more.
generate_imageA
Generate image(s) with the OpenAI Images API. SSE/HTTP transports auto-save files and return image URLs; stdio requires filepath.
Inputs: prompt (required), filepath (required), n, size, +6 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: one generates new images from scratch, the other edits existing images. There is no ambiguity between them.
Both tool names follow the same verb_noun pattern: generate_image and edit_image. The naming is consistent and predictable.
With only 2 tools, the server is on the thin side. While adequate for basic image generation and editing, it feels minimal and could reasonably include additional related operations.
The server covers the two primary actions for an image API service. Missing common operations like image variations or model listing, but the core generation and editing workflows are fully represented.
Maintenance
Related MCP Connectors
Generate and edit realistic images from a prompt. Returns the image and a download link.
Generate and edit images (PNG, transparent, GIF, SVG) with GPT Image and Nano Banana models.
Generate and edit images, create videos, quote credit costs, and retrieve private results.
Generate AI images and videos from any compatible MCP client.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables 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.12855 npm1MIT
- FlicenseNot gradedqualityDmaintenanceEnables image generation and editing via OpenAI's gpt-image-1 model, with options for saving, format control, and transparency.-
- AlicenseAqualityCmaintenanceEnables image generation and editing through OpenAI's gpt-image-2 model, supporting text-to-image, reference-guided generation, and editing with local files or URLs.22MIT
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to generate and edit images through any OpenAI-compatible image API, saving results as local files and returning absolute paths for immediate use.21 npmMIT