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
This server cannot be deployed
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.117 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

