openai-imagegen-mcp
This MCP server lets you generate and edit images through an OpenAI-compatible Images API, save originals locally, and retrieve results from long-running jobs.
Generate images from English text prompts with selectable model, size, quality, complexity, background, moderation, output format/compression, and image count.
Create animated GIFs using GIF-only frame count and frame duration options.
Edit local PNG/JPEG/WebP images or use up to 16 local reference images; target edits with a mask or markup PNG.
Save generated/edited images under
IMAGEGEN_HOMEby workspace, returning original paths plus downscaled previews, without overwriting existing files.Handle slow image jobs by returning
status: "running"with ajob_id, then collect the result withget_image_result.Use either OpenAI or a compatible endpoint configured through environment variables, keeping the API key out of tool arguments.
Allows generating and editing images with GPT Image models through the OpenAI Images API or compatible endpoints, including prompt-based generation, image edits with masks or markup, multiple outputs, size/quality/format controls, and job result retrieval.
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., "@openai-imagegen-mcp Generate a watercolor illustration of a fox reading in a cozy library"
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.
openai-imagegen-mcp
An MCP server that generates and edits images with GPT Image 2.6 through the OpenAI Images API or a compatible endpoint. Images are saved to local files, and tools return a downscaled preview plus the path of each original.
This server is built and tuned for the Claude desktop app. Other MCP clients can use it, but the experience may not be as polished: for example, a client may display the preview as well as the original, may not collapse the preview, or may only show a file path.
Models
Each call can choose a model with the model option. No other model names are accepted. Results report the model that made the image.
Model | Best for |
| Fast iteration |
| Demanding requirements for detail, layout or edit accuracy |
This server follows the latest GPT Image generation, and older models are dropped when a new one arrives.
Related MCP server: GPT-Image MCP Server
Requirements
Node.js 22 or later
An API key for OpenAI or a compatible service. OpenAI may require organization verification for GPT Image models.
Setup
Add the server to your MCP client's configuration:
{
"mcpServers": {
"imagegen": {
"command": "npx",
"args": ["-y", "openai-imagegen-mcp"],
"env": {
"OPENAI_API_KEY": "sk-...",
"OPENAI_BASE_URL": "https://api.openai.com/v1"
}
}
}
}The base URL and API key are configured here, not passed as tool arguments, so the key stays out of conversations and a prompt cannot redirect it to another host.
npx may keep using a cached version. To always run the newest release, use openai-imagegen-mcp@latest in args.
Configuration
Variable | Default | Description |
| required | API key sent to the endpoint. |
|
| API root. |
|
| Folder that holds saved images. Must be an absolute path or start with |
|
| How long one tool call waits before returning a job. Must be shorter than your client's tool timeout. |
|
| Timeout for each request to the API. |
|
| Most images allowed in one call, from 1 to 10. |
Tools
generate_image
Creates images from a prompt. Options: model, size, quality, complexity, background, output_format (png, jpeg, webp, gif), output_compression, n, frame_count, frame_duration_ms, moderation and workspace.
edit_image
Edits local images or uses them as references. images takes up to 16 local PNG, JPEG or WebP paths, and the first one is the image being edited. To target part of it, add either mask or markup, a transparent PNG with annotations showing where to edit. With a mask, describe the complete final image in the prompt, not only the change. The other options match generate_image, except that output_format is limited to png, jpeg and webp, and the GIF frame options are not available.
get_image_result
Collects the result of a job by job_id.
Saved images and previews
Images are saved as <IMAGEGEN_HOME>/<workspace>/<job_id>.<ext>, with a number added when one call returns several images. The calling model cannot choose the location or the file name. If an image belongs somewhere else, the model copies it there and keeps the original, as the tool instructions ask.
workspace is the caller's current working directory, and only its last segment is used. An MCP server usually cannot see that directory itself. Without workspace, the server falls back to CLAUDE_PROJECT_DIR, then to its own working directory, then to a folder named default. Images are not cleaned up automatically.
Each result also includes a downscaled JPEG preview for the model to look at. A call's previews stay within 75 KB in total, because clients limit tool results and rarely document how. Long edges go up to 1024 pixels when the size allows. If no preview fits, the result has the path only. A GIF preview shows the first frame.
Previews are for the model only. The tool instructions require the model to show users the original file, and results mark the preview with the assistant audience and the link to the original with the user audience. How far this is honored depends on the client: some ignore audience annotations and may display the preview, and some cannot display local files at all. If a client gives the model a scratchpad folder path, the instructions require the model to copy the original there and share the copy with SendUserFile, because the Claude desktop app may not display images from other folders in the conversation. The instructions also ask the model to write no text until the original is shared, because some clients collapse a preview into a small thumbnail only while tool calls run back to back.
Prompts
Prompts must be written in English. Text that should appear in the image stays in its original language, in quotes. The tool descriptions ask the calling model to follow this rule; the server does not check it, because quoted text can be in any language.
Long-running images
Complex images can take a couple of minutes, while some MCP clients give up on a tool call after about 60 seconds. To work in every client, each call waits for a limited time:
If the image finishes within
IMAGEGEN_WAIT_SECONDS, the call returns it directly.Otherwise the call returns
status: "running"and ajob_id, and the job keeps running.get_image_resultwaits again and returns the result, orrunningif it needs another call.
{
"status": "completed",
"job_id": "img_a1b2c3d4e5f6",
"elapsed_seconds": 18,
"model": "gpt-image-2.6-flare",
"images": [
{
"path": "/Users/me/.openai-imagegen-mcp/my-site/img_a1b2c3d4e5f6.png",
"uri": "file:///Users/me/.openai-imagegen-mcp/my-site/img_a1b2c3d4e5f6.png",
"mime_type": "image/png",
"bytes": 1482133,
"preview": { "width": 768, "height": 768, "bytes": 61240 }
}
],
"usage": { "total_tokens": 1234 }
}Cancelling the call that started a job also cancels the job. After that call has returned a job_id, a job cannot be cancelled and runs to the end.
Jobs live in the server's memory. Results stay available for an hour, and a job in progress is lost if the server is killed. If the client just disconnects, the server finishes the jobs in progress, saves their images and then exits.
Compatible endpoints
OPENAI_BASE_URL can point at any service that implements the Images API and offers these models under their official names. Responses may use b64_json, a data URL or a url to download. Limits such as allowed sizes and quality levels are left for the service to enforce, so its own error is returned to the caller.
Some gateways drop fields they do not recognize without reporting an error, and the server cannot detect that. If markup, complexity or the GIF frame options do not behave as expected, check whether the gateway forwards these fields. On a gateway with a pass-through setting, enabling it for the image models usually solves this.
Local file safety
Input files are checked by content, and only real PNG, JPEG or WebP images up to 50 MB are uploaded.
workspaceonly names a folder, so files cannot be written outsideIMAGEGEN_HOME.Existing files are never overwritten.
Development
npm installnpm testTests run the built server over stdio against a local fake of the Images API, so they make no paid requests.
License
Available Tools
3 toolsedit_imageEdit imageA
Edit local images, or create a new image from local reference images, and save the result to local files. Returns downscaled previews and the paths of the originals. The first image is the one edited; the others serve as references. If the result has status "running", call get_image_result with its job_id.
Inputs: images (required), prompt (required), n, mask, +10 more. Returns: next, error, usage, images, +4 more
generate_imageGenerate imageA
Generate images from a text prompt and save them to local files. Returns downscaled previews and the paths of the originals. Supports raster output and animated GIF. If the result has status "running", call get_image_result with its job_id.
Inputs: prompt (required), n, size, model, +9 more. Returns: next, error, usage, images, +4 more
get_image_resultGet image resultARead-only
Wait for and return the result of a job that generate_image or edit_image reported as "running". Waits for a limited time; if the result still has status "running", call this tool again.
Inputs: job_id (required). Returns: next, error, usage, images, +4 more
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 maps to a distinct action: creating new images, editing/conditioning on existing images, and polling an async job. The descriptions explicitly cross-reference each other (generate/edit tell you to call get_image_result when status is "running"), leaving no ambiguity about selection.
All three names are snake_case verb_noun(ish) forms: generate_image, edit_image, get_image_result. The only slight deviation is the longer 'get_image_result' suffix pattern, but it still follows the convention predictably.
Three tools is at the low end of the ideal range, but each is clearly necessary for the domain: creation, editing, and async result retrieval. Nothing feels redundant or bloated.
The core lifecycle (generate, edit, poll async result) is covered with no dead ends, since the async pattern is explicitly handled. Minor gaps exist: no job listing/cancellation and no metadata or parameter-enumeration tool, though these are workable around.
Maintenance
Related MCP Connectors
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Generate and edit images (PNG, transparent, GIF, SVG) with GPT Image and Nano Banana models.
Generate AI images and videos from your agent: list models, start jobs, and fetch the results.
Generate and edit images: article covers, pet portraits, product shots. Each call spends credits.
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.12263 npm1MIT
- AlicenseBqualityDmaintenanceEnables generating images from text or transforming existing images using GPT-Image-compatible APIs, with support for OpenAI and Agnes AI backends.2MIT
- 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
- AlicenseAqualityDmaintenanceEnables generating and editing images through OpenAI image models, with configurable output as saved files or returned URLs.2MIT