Skip to main content
Glama
codex-openai-image-mcp

codex-openai-image-mcp

by meet30997

codex-openai-image-mcp

codex-openai-image-mcp: generate, edit and make matching image sets from any MCP client. Works with Codex CLI or an OpenAI API key.

npm version Codex / OpenAI Image MCP on mcprush

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"

The same race-car illustration before and after the edit: day on the left, night with glowing lights on the right

A matching set in one call: "cute flat stickers: coffee, cactus, moon"

Three pastel stickers in one consistent style: a coffee cup, a potted cactus and a sleepy moon

Both examples are real, unretouched output from the Codex backend.

What makes it different

  • Matching sets. generate_set makes 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 .json sidecar 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, or

  • an 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-mcp

Claude 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

prompt

required

size

1024x1024

Any WxH from 16 to 4096 px per side

count

1

1–4 variants, saved as -v1, -v2, …

transparent

false

Asks for a transparent background; the result says if the output has none

references

[]

Up to 4 images whose style to match

out_name

slug of the prompt

Path inside the output folder, without extension, e.g. icons/rocket

edit_image

Input

Default

Notes

image

required

The image to change. It is never modified

prompt

required

The change, e.g. "remove the person on the left", "make it watercolour"

size

the input's size

WxH

mask

none

PNG whose transparent areas mark where to edit (OpenAI API only)

count

1

1–4 variants

transparent

false

e.g. for cutouts

references

[]

Up to 3 supporting images: something to insert, or a style to apply

out_name

<input name>-edited

generate_set

Input

Default

Notes

style

required

What every image shares: medium, palette, rendering, background

items

required

1–8 { name, prompt }; each is saved as <folder>/<name>.png

size

1024x1024

Same for every image

transparent

false

references

[]

Up to 4 images whose style the whole set matches

folder

slug of style

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

codex-cli

openai-api

mock

Needs

Codex CLI, signed in

OPENAI_API_KEY

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

IMAGEGEN_PROVIDER

mock; set codex-cli or openai-api

OPENAI_API_KEY

required for openai-api

IMAGEGEN_OPENAI_MODEL

gpt-image-2.5-sunburst

IMAGEGEN_CODEX_BIN

codex

IMAGEGEN_OUT_DIR

generated-images, relative to the working folder

IMAGEGEN_READ_ROOT

the working folder; input images must be inside it

IMAGEGEN_TIMEOUT_SEC

300, per image asked for

IMAGEGEN_MAX_PER_CALL

8 images

IMAGEGEN_PREVIEW_SIZE

512 px

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>.json sidecar 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_CALL caps 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 Inspector

To 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.js

The 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

MIT

Available Tools

3 tools
edit_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.

NameRequiredDescriptionDefault
maskNoOptional PNG whose transparent areas mark where to edit (openai-api only). Resized to the image if needed.
sizeNoOutput size as width x height in px, e.g. "1024x1024". Defaults to the size of the input image.
countNoNumber of edited variants (1-4).
imageYesPath of the image to edit (inside the working folder).
promptYesThe change to make. Say what should change and, if it matters, what must stay the same.
out_nameNoFile name without extension, relative to the output folder. Defaults to "<input name>-edited".
referencesNoExtra images the edit uses: an object to insert, or a style to apply (inside the working folder).
transparentNoAsk for a transparent background, e.g. for a cutout.

TDQS

A4/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

NameRequiredDescriptionDefault
sizeNoWidth x height in px, e.g. "1024x1024" or "1536x1024".1024x1024
countNoNumber of variants to generate (1-4).
promptYesWhat to draw. Be specific about subject, style, composition and colours.
out_nameNoFile name without extension, relative to the output folder, e.g. "icons/rocket". Defaults to a slug of the prompt.
referencesNoPaths of existing images to match the style of (inside the working folder).
transparentNoAsk for a transparent background.

TDQS

A3.8/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines3/5

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.

NameRequiredDescriptionDefault
sizeNoWidth x height in px for every image, e.g. "1024x1024".1024x1024
itemsYesThe images to make, one per item.
styleYesThe look every image shares: medium, palette, rendering, lighting, framing, background.
folderNoFolder for the set, relative to the output folder. Defaults to a slug of the style.
referencesNoExisting images whose style the whole set should match (inside the working folder).
transparentNoAsk for transparent backgrounds.

TDQS

A3.8/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines3/5

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.

  1. 3 tool updatesv0.1.2
    • First observededit_image
    • First observedgenerate_image
    • First observedgenerate_set

TDQS

A4/5.0

Scored across 3 tools

Disambiguation4/5

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.

Naming Consistency5/5

All three tools follow a consistent verb_noun snake_case pattern: edit_image, generate_set, generate_image. The convention is predictable and readable.

Tool Count4/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers