openai-imagegen-mcp
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-mcpGenerate 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.
Models
Each call can choose a model with the model option. No other model names are accepted.
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 only displays images from certain folders and gives the model a session scratchpad, the instructions ask the model to copy the original there before sharing it.
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,
"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.
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images, at most 4. | |
| mask | No | Local path of a mask for the first image, with an alpha channel. Transparent areas mark what to replace. Describe the complete final image in the prompt, not only the change. Cannot be combined with markup. | |
| size | No | "auto" or WIDTHxHEIGHT, such as 1024x1024, 1536x1024 or 1024x1536. Custom sizes use multiples of 16 and an aspect ratio from 1:3 to 3:1. | |
| model | No | gpt-image-2.6-flare is the default and suits fast iteration. gpt-image-2.6-sunburst suits work with demanding requirements for detail, layout or edit accuracy. | |
| images | Yes | Local paths of PNG, JPEG or WebP input images. | |
| markup | No | Local path of a transparent PNG with annotations showing where to edit, the same dimensions as the first image. Cannot be combined with mask. | |
| prompt | Yes | Description of the desired image or edit. Must be written in English. Keep text that should appear in the image in its original language, in quotes. | |
| quality | No | Rendering quality. Use low for drafts. Compare medium and high for small text or dense information. | |
| workspace | No | Your current working directory. Only its last segment is used, to name the folder that groups saved images. Omit it if you do not know the directory; never guess. | |
| background | No | Transparent cannot be used with output_format jpeg. | |
| complexity | No | How much the model plans before rendering. Defaults to high, which suits dense text and layouts but takes longer. Start with low for targeted edits. | |
| moderation | No | ||
| output_format | No | Defaults to png. | |
| output_compression | No | Compression level for jpeg or webp output. |
Output Schema
| Name | Required | Description |
|---|---|---|
| next | No | |
| error | No | |
| usage | No | |
| images | No | |
| job_id | No | |
| status | Yes | |
| elapsed_seconds | No | |
| revised_prompts | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnly=false, openWorld=true, idempotent=false and destructive=false, and the description adds real context: results are written to local files, previews are downscaled while originals keep full paths, and the call can return an asynchronous "running" status. It omits cost/latency implications, moderation behavior, and what overwriting an existing output path does.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Four short sentences, front-loaded with the core capability, then the image-ordering rule, then the async follow-up. Nothing is repeated from the title and no sentence is filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need limited explanation, and the description still covers the async continuation path and file outputs. With 14 parameters, the description reasonably leans on the 93%-covered schema, though it could say more about how mask/markup and n interact with the edit target.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is already 93%, so the schema carries most parameter meaning. The description still adds a non-obvious semantic rule for the `images` array ordering (first = target, rest = references) plus the file-write behavior, which the schema does not convey.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States concrete verbs and resources: edit local images or create a new image from local reference images, then save results to local files. This clearly separates it from a pure text-to-image generator like generate_image because it requires local input images, but it never names that sibling explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides actionable routing: the first image is the one edited, the rest are references, and if the returned status is "running" the agent must call get_image_result with the job_id. It does not state when to prefer generate_image over this tool or when editing is inappropriate.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images, at most 4. | |
| size | No | "auto" or WIDTHxHEIGHT, such as 1024x1024, 1536x1024 or 1024x1536. Custom sizes use multiples of 16 and an aspect ratio from 1:3 to 3:1. | |
| model | No | gpt-image-2.6-flare is the default and suits fast iteration. gpt-image-2.6-sunburst suits work with demanding requirements for detail, layout or edit accuracy. | |
| prompt | Yes | Description of the desired image or edit. Must be written in English. Keep text that should appear in the image in its original language, in quotes. | |
| quality | No | Rendering quality. Use low for drafts. Compare medium and high for small text or dense information. | |
| workspace | No | Your current working directory. Only its last segment is used, to name the folder that groups saved images. Omit it if you do not know the directory; never guess. | |
| background | No | Transparent cannot be used with output_format jpeg. | |
| complexity | No | How much the model plans before rendering. Defaults to high, which suits dense text and layouts but takes longer. Start with low for targeted edits. | |
| moderation | No | ||
| frame_count | No | GIF only. Number of frames. | |
| output_format | No | Defaults to png. Access to gif can depend on the account. | |
| frame_duration_ms | No | GIF only. Delay per frame in milliseconds. | |
| output_compression | No | Compression level for jpeg or webp output. |
Output Schema
| Name | Required | Description |
|---|---|---|
| next | No | |
| error | No | |
| usage | No | |
| images | No | |
| job_id | No | |
| status | Yes | |
| elapsed_seconds | No | |
| revised_prompts | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations declare a non-read-only, non-idempotent, open-world write, and the description adds real substance beyond them: images are written to local files, previews are downscaled while originals are returned as paths, and the operation may return a job that is still running. It does not disclose cost, rate limits, or where on disk files land, which keeps it off a 5.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Four short sentences, front-loaded with what the tool produces before the async fallback instruction. "Supports raster output and animated GIF" mildly overlaps the output_format enum but still frames the tool's scope early.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 13-parameter generative tool with an output schema, the description covers the essentials an agent needs: what is produced, where it is saved, what the return contains, and how to handle a still-running job. Nothing required to invoke it correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 92%, so the schema already explains prompt, size, model, quality, GIF frame settings, and compression. The description adds no parameter-level meaning of its own, which is the expected baseline when the schema does the work.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific verb and resource ("Generate images from a text prompt") plus the side effect ("save them to local files") and output modes (raster, GIF). It does not explicitly distinguish itself from edit_image, though the async handoff to get_image_result gives partial sibling routing.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
"If the result has status 'running', call get_image_result with its job_id" is explicit conditional guidance naming the alternative tool and parameter to pass. It lacks any statement about when to call generate_image versus edit_image, which is the remaining ambiguity among siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | Yes | The job_id returned by generate_image or edit_image. |
Output Schema
| Name | Required | Description |
|---|---|---|
| next | No | |
| error | No | |
| usage | No | |
| images | No | |
| job_id | No | |
| status | Yes | |
| elapsed_seconds | No | |
| revised_prompts | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already establish this as a read-only, closed-world operation, and the description adds genuinely new behavioral information: the call blocks for a limited time and is a polling primitive that must be repeated. It does not describe what is returned or how non-running terminal states are surfaced, which is a modest remaining gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short sentences, front-loaded with the action and followed by the retry rule. There is no boilerplate or redundant restatement of the title.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
An output schema exists, so return values need not be explained, and the polling contract is fully conveyed. The only omission is how error or failed-completion states differ from "running", which would help an agent decide whether to retry.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Only one parameter exists and schema coverage is 100%, with the schema already explaining that job_id is the value returned by generate_image or edit_image. The description repeats that provenance without adding format, validation, or lookup semantics, so the baseline 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ("Wait for and return the result of a job") and scopes it to jobs produced by generate_image or edit_image, which cleanly separates it from those two sibling tools. An agent can identify the tool's role without opening the schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Gives a clear triggering condition — use it only for jobs the generating tools reported as "running" — and prescribes the follow-up action (call again if still running). It stops short of an explicit exclusion such as behavior for already-completed or failed jobs, so it is strong but not fully exhaustive.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.2.0- First observed
edit_image - First observed
generate_image - First observed
get_image_result
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, edit and upscale images with references, batch jobs, cost previews and original downloads.
Generate images from Claude, ChatGPT, Cursor and Codex with 12 top AI image models. Up to 4 images per call, SVG vectorization, background removal, upscaling and image-to-video. Remote MCP with OAuth, no API keys.
Generate images with your own ChatGPT subscription (Plus, Pro or Team), without spending API credits
Related MCP Servers
- 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.12224 npm1MIT
- AlicenseBqualityDmaintenanceEnables generating images from text or transforming existing images using GPT-Image-compatible APIs, with support for OpenAI and Agnes AI backends.2MIT
- AlicenseAqualityBmaintenanceEnables 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.2216 npm2MIT
- AlicenseAqualityCmaintenanceEnables generating and editing images through OpenAI image models, with configurable output as saved files or returned URLs.2MIT