gpt-image-mcp
This server provides local MCP tools for generating and editing images via OpenAI-compatible GPT Image APIs, saving results to local disk.
check_endpoint: Validates the configured API endpoint by requesting the model list; returns configuration status, endpoint availability, whether the model is listed, and HTTP status—without generating or editing images.
generate_image: Creates an image from a text prompt, with options for size, quality, format (png/jpeg/webp), background, moderation, and output compression; returns local path, file URI, MIME type, byte size, and dimensions.
edit_image: Edits images or creates new ones from 1–16 local reference images, supporting prompt, optional mask, size, quality, format, background, input fidelity, and output compression; saves a new file without overwriting originals.
Local file handling: All outputs are saved under the configured output directory with date-based subfolders, use unique filenames, and are returned as absolute filesystem paths and file:// URIs—not public URLs.
Configuration: Behavior is controlled via environment variables such as API key, base URL, model name, output directory, timeout, response format, and default size/quality.
Provides image generation and editing through the OpenAI GPT Image API, enabling text-to-image creation, image editing with masks and reference images, and saving generated images locally.
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., "@gpt-image-mcp Generate an image of a cozy cabin in snowy mountains at sunset."
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.
中文 | English
gpt-image-mcp
A local stdio MCP server written in TypeScript. It calls GPT Image for text-to-image generation, image editing and reference-style creation. Images are saved on your machine, and the server returns absolute paths and file URIs.
Install and configure
Requires Node.js 22 or later, and an API key for OpenAI or a compatible provider that has access to the chosen model and available quota. Linux, macOS and Windows are supported. No manual install is needed; npx downloads and runs it.
MCP configuration (works with Claude Code, Claude Desktop, Cursor and other MCP clients):
{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["-y", "gpt-image-mcp"],
"env": {
"OPENAI_API_KEY": "your API key",
"OPENAI_BASE_URL": "https://your-provider/v1",
"IMAGE_GEN_MODEL": "image model name from your provider",
"IMAGE_GEN_OUTPUT_DIR": "~/pictures"
}
}
}
}Only OPENAI_API_KEY is required; the rest is optional. See Configuration below.
The first start downloads dependencies; later starts use the cache. Set the client's tool execution timeout to at least 360 seconds; the server's own API timeout defaults to 300 seconds.
Related MCP server: gpt-image-2-mcp
Companion Skill
The repository also ships an agent skill, skills/gpt-image-workflow, that teaches an agent when and how to use these tools (prompting, source vs. style-reference images, iteration, cost and timeout handling). The skill does not install or run this MCP server; you still configure the server and your API key yourself. It is released under the same MIT license as this repository. The skill is not part of the npm package; get it from the GitHub repository.
Configuration
Variable | Default | Description |
| required | OpenAI API key, injected through the client's environment variables |
|
| The official endpoint is used when unset or empty. A bare domain gets |
|
| Model shared by generation and editing. Provider model aliases are allowed; your account must have access |
|
| Output root, an absolute local path or |
|
| API request timeout in milliseconds; an integer of at least 1000 |
|
| How the API returns images: |
|
| Global default size as |
|
| Global default quality: |
OPENAI_BASE_URL takes the API base URL; unset, empty or whitespace-only values use the official endpoint. /v1 is appended only when the address has no path; an existing path is kept as configured so proxy prefixes and other versions are not broken. Trailing slashes are removed and /v1 is never appended twice.
You enter | API base URL actually used |
(unset) |
|
|
|
|
|
|
|
|
|
|
|
The server appends /images/generations, /images/edits or /models to the base URL, so do not enter a full image endpoint URL. If a custom path needs /v1, write it explicitly, for example /proxy/v1. HTTP and HTTPS are supported; a local proxy can use http://localhost:8080, and HTTPS is recommended for remote endpoints. The address must not contain credentials, a query string or a URL fragment.
Your key, prompts and input images are sent to the provider you configure. The server does not follow HTTP redirects, so enter the final API base URL directly.
A compatible provider must support the OpenAI Image API's JSON generation, multipart image editing, and the data[].b64_json or data[].url response shape. The server detects both response formats automatically. Some proxies do not support the response_format parameter for newer models; keeping the default IMAGE_GEN_RESPONSE_FORMAT works around that. Providers that only offer a chat interface or asynchronous task IDs are not supported.
Endpoint check and real capability verification
On startup the server only validates local configuration; it never probes the network or generates test images. To check the endpoint, call check_endpoint from your MCP client with {}, or run this after setting the environment variables:
gpt-image-mcp --checkThe check waits at most 30 seconds, never retries, and only requests GET /models; it does not call the image generation or editing endpoints. Result fields:
Field | Meaning |
|
|
|
|
| Whether the configured model appears in the returned list; |
| Always |
| HTTP status and an explanation; the key and raw upstream error messages are never echoed |
Some image services do not offer /models or do not list alias models, so a failed check or an unlisted model does not rule out image generation. The CLI exits with 0 when the model list is healthy and 1 otherwise; the exit code does not mean image capabilities passed or failed.
Real compatibility verification means running generate_image and edit_image once each and checking that the image is returned and saved. These calls may be billed, so start with quality: "low". A passing generation does not replace testing the edit endpoint, and does not guarantee that every parameter combination is supported by the provider.
File naming and paths
Images are saved as output-root/yyyy/MM/dd/file-name. The date is the local time of your computer at save time, with the month and day zero-padded; UTC dates are not used. Saving after midnight goes into a new directory automatically.
File names come from a built-in playful word list: "adjective + animal + action + wonder + random suffix". No language model is called to name files:
cozy-otter-paints-moonlight-7d3a9b2c.png
sassy-capybara-juggles-marshmallows-c8e2a104.webp
dreamy-axolotl-brews-stardust-f0914abc.jpgDefault path examples:
Linux: /home/<user>/gpt-image-mcp/images/2026/09/10/cozy-otter-paints-moonlight-7d3a9b2c.png
macOS: /Users/<user>/gpt-image-mcp/images/2026/09/10/cozy-otter-paints-moonlight-7d3a9b2c.png
Windows: C:\Users\<user>\gpt-image-mcp\images\2026\09\10\cozy-otter-paints-moonlight-7d3a9b2c.pngThe output root stays fixed and images are archived by date. File names use only lowercase ASCII letters, hyphens and a random suffix, which avoids reserved characters and case collisions. Files are always created exclusively, so a name collision picks a new name and an existing image is never overwritten. Directories containing non-ASCII characters or spaces are supported; uri uses standard URL encoding. Images produced by older versions stay where they are and are not migrated.
In the result, path is a local path and uri is a file:// URI; neither is a public download URL. The calling client must be able to access the file system of the machine running the server, and whether the image is displayed inline depends on the client. For image-to-image, use the path returned by a previous call directly.
Tools
generate_image
{
"prompt": "An otter painting under the moonlight, warm hand-drawn illustration, soft brush strokes",
"size": "1024x1024",
"quality": "medium",
"format": "png"
}edit_image
{
"prompt": "Keep the subject and composition of image 1, take the palette and brush strokes from image 2, and change the background to a rainy night street",
"images": ["/absolute/path/original.png", "/absolute/path/style-reference.webp"],
"quality": "high"
}For local edits, add mask with the local path of a mask. The mask must be a PNG with an alpha channel and the same dimensions as the first source image; fully transparent areas mark the parts you want edited. The mask is guidance for the model and does not guarantee pixel-exact boundaries.
Parameter | Default and range |
| Required, 1 to 32000 characters after trimming whitespace |
| Default |
| Default |
| Default |
| Default |
| Generation only. Default |
| Optional integer 0 to 100; only applies to |
| Editing only. Optional |
| Required for editing: 1 to 16 local PNG, JPEG or WebP files; each under 50 MiB, at most 100 MiB in total |
| Optional for editing: local PNG mask path; under 50 MiB |
Input image paths must be absolute local paths or start with ~/. Each call produces one new image and never modifies the input files.
On success the result carries both MCP text and structuredContent with identical content:
{
"images": [{
"path": "/Users/<user>/gpt-image-mcp/images/2026/09/10/cozy-otter-paints-moonlight-7d3a9b2c.png",
"uri": "file:///Users/<user>/gpt-image-mcp/images/2026/09/10/cozy-otter-paints-moonlight-7d3a9b2c.png",
"mimeType": "image/png",
"bytes": 123456,
"width": 1024,
"height": 1024
}],
"model": "gpt-image-2.5-sunburst"
}Failures return isError: true with an explanation. Automatic retries are disabled. A timeout or disconnect does not mean the upstream did not run the request, and calling again may be billed again. If generation succeeds but saving locally fails, this is reported explicitly and the generation endpoint is not called again. Client cancellation is passed on to the API request, but it cannot guarantee that billing for work already started upstream is cancelled.
For real acceptance testing, run one text-to-image and one image-to-image call with quality: "low" to confirm model access, network, image results and how your client displays them.
License
Available Tools
3 toolscheck_endpoint端点检查ARead-onlyIdempotent
请求当前端点的模型列表,检查响应格式和模型是否在列表中。不会发送生图或编辑请求;即使检查通过,图片能力仍需实际调用验证。
Inputs: no named parameters. Returns: model, editing, message, generation, +4 more
edit_image编辑与参考创作A
读取本机图片,按提示词编辑、替换背景,或参考风格和构图生成新图。请明确各参考图的作用和需要保留的内容;可传遮罩引导局部编辑。保存新文件并返回绝对路径,不覆盖原图。调用会产生 API 费用。
Inputs: images (required), prompt (required), mask, size, +5 more. Returns: model, images
generate_image文生图A
根据提示词调用 GPT Image 生成一张图片,保存到本机并返回绝对路径和文件 URI。调用会产生 API 费用。
Inputs: prompt (required), size, format, quality, +3 more. Returns: model, images
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: check_endpoint validates API connectivity, generate_image creates new images, and edit_image modifies existing images. There is no meaningful overlap between these operations, so an agent can confidently select the right tool.
All tool names follow the same verb_noun snake_case pattern: check_endpoint, generate_image, edit_image. This makes the tool set highly predictable and easy to reason about.
Three tools is well-scoped for a focused GPT Image MCP server: endpoint validation, generation, and editing cover the core functionality without unnecessary bloat. Each tool earns its place.
The set covers the primary image lifecycle: checking endpoint availability, generating images, and editing existing images. Minor gaps exist, such as no explicit model listing or image variation/upscale capabilities, but the core workflows are complete enough for most use cases.
Maintenance
Related MCP Connectors
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
MCP server exposing the YourImageShare upload API (upload/list/delete) as tools for AI agents.
Generate and edit images and generate videos with Nanobananana's remote MCP server.
Generate images and videos with Seedance, Veo, Wan, Grok, GPT-Image and Nano Banana via one MCP.
Related MCP Servers
- FlicenseAqualityAmaintenanceWraps the Micu image API as an MCP server for generating, editing, batch processing, and multi-reference image fusion, supporting GPT-image-2 and Grok models.5333-
- AlicenseAqualityCmaintenanceExposes OpenAI's gpt-image-2 (image generation and editing) as an MCP server for tools like generate_image, edit_image, and iterative edit sessions.613MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables generating, editing, and multi-turn editing of images using OpenAI's gpt-image models directly from Claude or any MCP client.41MIT
- AlicenseAqualityAmaintenanceMCP server for Google Gemini media generation, exposing tools for generating and editing images, video, music, and async operations via stdio.13936 npmMIT