codex-openai-image-mcp
Generates, edits, and creates matching image sets using OpenAI image generation backends, including the OpenAI Images API and the Codex CLI, with support for sizes, variants, transparency, references, and saved previews.
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., "@codex-openai-image-mcpmake 5 matching app icons: home, search, profile, settings, bell"
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.
codex-openai-image-mcp

An MCP server that lets Claude (and any other MCP client) generate images, edit them, and make matching sets, then look at the result and keep going.
It works with two image backends:
Codex CLI: uses the ChatGPT plan you already have through the Codex CLI. No API key, no per-image bill.
OpenAI Images API: uses an
OPENAI_API_KEY, for people without Codex.
Not affiliated with or endorsed by OpenAI. "OpenAI" and "Codex" are trademarks of OpenAI.
Edit an image: "make it a night scene, keep the car and composition" |
|
A matching set in one call: "cute flat stickers: coffee, cactus, moon" |
|
Both examples are real, unretouched output from the Codex backend.
What makes it different
Matching sets.
generate_setmakes several different images that share one style, each saved under its own name.Two backends, one interface. Switch between Codex and the OpenAI API with one setting.
Made for an agent loop. Every call returns small previews that Claude can see, reports progress during long runs, can be cancelled, and writes a
.jsonsidecar with the prompt and settings next to each image.Careful with your files. It writes only inside its output folder, never overwrites an existing file, never changes the image you edit, and runs Codex read-only in an empty temporary folder.
Related MCP server: imaginate-mcp
Quick start
You need Node.js 20.3 or newer, plus one of:
the Codex CLI, signed in (
codex login) with a ChatGPT plan that includes Codex image generation, oran OpenAI API key with credits.
Claude Code
# Codex backend (your ChatGPT plan)
claude mcp add images -e IMAGEGEN_PROVIDER=codex-cli -- npx -y codex-openai-image-mcp
# or the OpenAI API
claude mcp add images -e IMAGEGEN_PROVIDER=openai-api -e OPENAI_API_KEY=sk-... -- npx -y codex-openai-image-mcpClaude Desktop, Cursor and other clients
Add this to the client's MCP config (for Claude Desktop, claude_desktop_config.json):
{
"mcpServers": {
"images": {
"command": "npx",
"args": ["-y", "codex-openai-image-mcp"],
"env": { "IMAGEGEN_PROVIDER": "codex-cli" }
}
}
}For the API backend use "IMAGEGEN_PROVIDER": "openai-api" and add "OPENAI_API_KEY".
Then just ask:
"Make a watercolour fox for my blog header, 1536x864."
"Edit photo.png so it looks like a sunset."
"Make 5 matching app icons: home, search, profile, settings, bell."
Images are saved in ./generated-images in the folder the client was started from.
Tools
generate_image
Input | Default | Notes |
| required | |
|
| Any |
|
| 1–4 variants, saved as |
|
| Asks for a transparent background; the result says if the output has none |
|
| Up to 4 images whose style to match |
| slug of the prompt | Path inside the output folder, without extension, e.g. |
edit_image
Input | Default | Notes |
| required | The image to change. It is never modified |
| required | The change, e.g. "remove the person on the left", "make it watercolour" |
| the input's size |
|
| none | PNG whose transparent areas mark where to edit (OpenAI API only) |
|
| 1–4 variants |
|
| e.g. for cutouts |
|
| Up to 3 supporting images: something to insert, or a style to apply |
|
|
generate_set
Input | Default | Notes |
| required | What every image shares: medium, palette, rendering, background |
| required | 1–8 |
|
| Same for every image |
|
| |
|
| Up to 4 images whose style the whole set matches |
| slug of | Folder inside the output folder |
All tools crop and resize the result to exactly the size you ask for, and return the saved paths with a 512 px preview of each image.
Backends
|
|
| |
Needs | Codex CLI, signed in |
| nothing |
Cost | your ChatGPT plan's usage | per image | free |
Speed | ~30–60 s per image | depends on model and size | instant |
References, edits, transparency | yes | yes | edits only |
Edit masks | no | yes | no |
Sets | one Codex session for the whole set | one image at a time, first image used as a style reference | one at a time |
mock draws placeholder images, for trying the server out and for tests.
Codex backend. Each call runs
codex exec --json --skip-git-repo-check --sandbox read-only --cd <empty temp folder> [--image=<file>…] -- -
with a prompt that asks Codex to call its built-in image_gen tool and nothing else. The server
reads the session id from Codex's JSON events and collects the images from
$CODEX_HOME/generated_images/<session id>/. Codex never gets write access or sees your project
beyond the images you pass it. Cancelling the request, or hitting the timeout, stops Codex.
Check OpenAI's terms for scripted use of the Codex CLI with your plan.
OpenAI backend. Uses the official openai SDK. The default model is
gpt-image-2.5-sunburst; set IMAGEGEN_OPENAI_MODEL=gpt-image-2.5-flare for faster results. Sizes
are rounded to ones the API accepts, then resized to yours. This backend is covered by automated
tests against a mocked client; it has not yet had a full live test.
Settings
Variable | Default |
|
|
| required for |
|
|
|
|
|
|
| the working folder; input images must be inside it |
|
|
|
|
|
|
Files and safety
Output is written only inside
IMAGEGEN_OUT_DIR. Absolute paths,..and symlinks that lead outside are rejected.Input images (to edit, or as references) must be inside
IMAGEGEN_READ_ROOT.Existing files are never overwritten: a new file gets
-2,-3, … instead.Each image gets a
<name>.jsonsidecar with the prompt, backend, model, size, inputs and time.API keys are read from the environment only and never logged or written to sidecars.
IMAGEGEN_MAX_PER_CALLcaps how many images one call can make.
Images are AI-generated. You are responsible for how you use them, including platform rules on AI-generated content, and for not imitating real people or brands.
Development
git clone https://github.com/meet30997/codex-openai-image-mcp.git
cd codex-openai-image-mcp
npm install
npm run build
npm test # unit and end-to-end tests; no network or API key needed
npm run inspect # try the tools in the MCP InspectorTo run a local build from Claude Code:
claude mcp add images -e IMAGEGEN_PROVIDER=codex-cli -- node /path/to/codex-openai-image-mcp/dist/index.jsThe tests run the Codex backend against a stand-in script (test/fixtures/fake-codex.mjs) and the
OpenAI backend against a fake client, so they are free and quick. PLAN.md has the
design notes and roadmap. Issues and pull requests are welcome.
License
Available Tools
3 toolsedit_imageEdit imageA
Change an existing image with a text instruction (e.g. 'make the sky a sunset', 'remove the person on the left', 'turn it into a watercolour', 'remove the background'). The original is never modified; edited copies are saved in the output folder with a .json sidecar, and their paths are returned with small previews.
| Name | Required | Description | Default |
|---|---|---|---|
| mask | No | Optional PNG whose transparent areas mark where to edit (openai-api only). Resized to the image if needed. | |
| size | No | Output size as width x height in px, e.g. "1024x1024". Defaults to the size of the input image. | |
| count | No | Number of edited variants (1-4). | |
| image | Yes | Path of the image to edit (inside the working folder). | |
| prompt | Yes | The change to make. Say what should change and, if it matters, what must stay the same. | |
| out_name | No | File name without extension, relative to the output folder. Defaults to "<input name>-edited". | |
| references | No | Extra images the edit uses: an object to insert, or a style to apply (inside the working folder). | |
| transparent | No | Ask for a transparent background, e.g. for a cutout. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Goes meaningfully beyond the annotations by disclosing that the source is never overwritten, that outputs land in the output folder with a .json sidecar, and that paths plus small previews come back. It does not cover provider/credential constraints or cost/rate behaviour, but for a mutation tool flagged openWorld this is solid added context consistent with destructiveHint=false.
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 sentences, zero filler: the action and examples come first, then the side-effect and return-format guarantees. Every clause carries information an agent would otherwise lack.
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?
With no output schema, the description usefully compensates by stating what is returned (paths and previews) and where files land. Minor gaps remain around the mask/provider restriction and any length or content limits on the prompt, but the specification is sufficient to invoke the tool correctly.
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 100%, so every one of the 8 parameters (including mask, references, transparent, out_name) already carries its own description; the description adds nothing about individual parameters. Baseline 3 applies since the schema does all the semantic 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?
States a specific verb+resource ('Change an existing image') and immediately grounds it with four concrete instruction examples, which makes the distinction from the generate_image/generate_set siblings apparent without naming them. An agent can tell this transforms an existing file rather than creating one from scratch.
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?
The framing 'an existing image' implicitly signals when to reach for this over generate_image, and the examples clarify the kind of prompt that works. But there is no explicit when-to-use/when-not statement and no reference to the siblings by name, so the routing decision is left to inference.
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 one or more images from a text prompt. Saves full-size PNGs (plus a .json sidecar with the prompt and settings) in the output folder and returns their paths with small previews.
| Name | Required | Description | Default |
|---|---|---|---|
| size | No | Width x height in px, e.g. "1024x1024" or "1536x1024". | 1024x1024 |
| count | No | Number of variants to generate (1-4). | |
| prompt | Yes | What to draw. Be specific about subject, style, composition and colours. | |
| out_name | No | File name without extension, relative to the output folder, e.g. "icons/rocket". Defaults to a slug of the prompt. | |
| references | No | Paths of existing images to match the style of (inside the working folder). | |
| transparent | No | Ask for a transparent background. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already flag a non-read-only, open-world, non-destructive operation. The description adds real value beyond them: it discloses that full-size PNGs plus a .json sidecar are written to the output folder and that paths with small previews are returned. It stops short of covering overwrite behavior when out_name collides, cost/latency of the external call, or failure modes.
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 sentences, zero filler, and the core action is front-loaded before the side effects. Every clause adds information an agent needs.
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 six-parameter mutation tool with no output schema, the description adequately covers what is produced and where, so the agent knows the return shape. Remaining gaps are overwrite semantics for out_name and any cost/rate-limit caveats for the external generation call.
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 100%, so all six parameters are already documented with defaults and ranges. The description adds only output-side context ('one or more', paths, sidecar) and no syntax or semantics beyond the schema, which matches the baseline of 3 when the schema carries the burden.
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 gives a specific verb (generate) and resource (images) with the source constraint 'from a text prompt', which implicitly separates it from edit_image. It never names or contrasts the siblings edit_image or generate_set, so the boundary with generate_set ('one or more images') is left ambiguous.
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?
Usage is implied by 'from a text prompt' and the file-output behavior, but there is no explicit when-to-use, when-not-to-use, or routing to edit_image/generate_set. An agent must infer that this is the text-to-image entry point rather than a set generator or editor.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
generate_setGenerate matching setA
Generate several different images that share one style, e.g. a set of icons, stickers, badges, character portraits or story illustrations. Each item gets its own file, named after the item, in one folder. Returns paths and previews.
| Name | Required | Description | Default |
|---|---|---|---|
| size | No | Width x height in px for every image, e.g. "1024x1024". | 1024x1024 |
| items | Yes | The images to make, one per item. | |
| style | Yes | The look every image shares: medium, palette, rendering, lighting, framing, background. | |
| folder | No | Folder for the set, relative to the output folder. Defaults to a slug of the style. | |
| references | No | Existing images whose style the whole set should match (inside the working folder). | |
| transparent | No | Ask for transparent backgrounds. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations only declare the safety profile (not read-only, open-world, non-destructive), so the description usefully adds that each item produces its own file named after the item, all in one folder, and that paths and previews are returned. It stops short of stating overwrite/conflict behavior for an existing folder or any rate/cost limits, which matters given openWorldHint.
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?
Three short sentences, front-loaded with the core purpose, followed by output layout and return values. No filler or repetition of schema details.
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?
It covers what the tool produces and what it returns (paths and previews), which compensates for the absent output schema on a 6-parameter tool. Gaps remain around folder collision behavior and whether style/items have any content restrictions, but nothing essential to invoking it 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 coverage is 100%, so the schema already documents style, items, size, folder, references, and transparent. The description contributes only the linkage that item names become file names and that everything lands in one folder — helpful but marginal, so 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?
Specific verb (generate) plus resource (several images sharing one style), reinforced by concrete examples (icons, stickers, badges, portraits, story illustrations). It implicitly separates itself from generate_image by emphasizing 'several' and 'share one style,' but never names the sibling tools, so the differentiation is inferred rather than stated.
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?
The example list gives a reasonable sense of when a matched set is appropriate, but there is no explicit guidance on when to prefer generate_image for a single image or edit_image for modifying existing art. No prerequisites, exclusions, or cost/batching trade-offs are stated.
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.1.2- First observed
edit_image - First observed
generate_image - First observed
generate_set
TDQS
Scored across 3 tools
Each tool targets a distinct operation: editing an existing image, generating a coordinated set, and generating standalone images. The only mild overlap is that generate_image says 'one or more images' while generate_set also produces multiple images, but the shared-style/folder semantics distinguish them reasonably well.
All three tools follow a consistent verb_noun snake_case pattern: edit_image, generate_set, generate_image. The convention is predictable and readable.
Three tools is a focused, well-scoped surface for an image generation/editing server. It is slightly thin but each tool clearly earns its place without redundancy.
The core lifecycle is covered: generate single images, generate coordinated sets, and edit existing images. Minor gaps exist around image variations, upscaling, or format conversion, but agents can work around them for the stated purpose.
Maintenance
Related MCP Connectors
Generate on-brand images from your AI agent: design, edit, and render templates over MCP.
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 from Claude, ChatGPT, Cursor and Codex with 12 top AI image models and 10 tools: up to 4 images per call, SVG vectorization, editing and more. Remote MCP with OAuth, no API keys. Pay per image, no subscription.
Edit images over MCP with object removal, background removal, and guided generative edits.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceGenerates and edits images using OpenAI image models via MCP tools.MIT
- AlicenseAqualityBmaintenanceGenerates and edits images using OpenAI GPT Image or Google Gemini models, saving every result to disk and returning local file paths so AI assistants can continue working with the images. It enables prompt-based image creation, editing, inpainting, multi-image composition, and model listing through MCP tools.114 npm1Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables MCP-capable agents to generate and edit images through Gemini or OpenAI, returning an absolute file path instead of image bytes to keep context windows clean.1MIT
- AlicenseAqualityCmaintenanceEnables MCP clients to generate and edit images through Codex's built-in image generation using a ChatGPT login, returning final files with metadata and optional inline previews.4MIT

