openai-image-mcp
Provides tools for generating and editing images via OpenAI's Images API, including text-to-image generation, editing with reference images and masks, transparent backgrounds, and listing previously generated files.
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-image-mcp Generate a hero image for our landing page: a lighthouse at dawn, flat vector, no text."
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-image-mcp
A local, stdio-transport MCP server that lets Claude Code and
Claude Desktop generate and edit images with OpenAI's Images API (gpt-image-2 by default).
Finished images are written into the current project (default ./assets/generated) so they can be
used directly as site assets, and every tool call returns a small JPEG preview so the calling model
can inspect the result and iterate. Images only; no video.
Tools
Tool | Purpose |
| New image(s) from a text prompt. |
| New image guided by 1–8 reference images (consistent style, modifications, optional mask). |
| Files in the output directory with dimensions, size and the prompt from each |
Each generated image gets a <name>.json sidecar next to it holding the prompt, model, requested and
final size, quality, background, output format, reference paths (for edits) and an ISO timestamp.
Files are never overwritten: a taken name gets -2, -3, … appended.
Related MCP server: RunPod Image MCP Server
Prerequisites
Python ≥ 3.11 and, ideally, uv.
An OpenAI API key with access to the GPT Image models.
Organization verification. OpenAI gates GPT Image models behind API Organization Verification. If your organization has not completed it, calls fail with a 403 and this server reports "Your OpenAI organization is not verified for gpt-image-2 …". Verification can take a few minutes to propagate after it is approved.
Install
With uv (recommended):
git clone https://github.com/mostmark/openai-image-mcp.git
cd openai-image-mcp
uv sync
uv run openai-image-mcp # starts the server on stdio; Ctrl-C to stopWith plain pip:
python -m venv .venv && source .venv/bin/activate
pip install -e .
python -m openai_image_mcpEnvironment variables
Variable | Required | Default | Purpose |
| yes | — | API key. The server exits at startup with a clear message if it is missing. |
| no | OpenAI default | Route calls through an OpenAI-compatible gateway. |
| no |
| Model for both generation and edits. |
| no |
| Where images are written, relative to the server's working directory. Created on first write. |
| no |
| Per-request timeout. High-quality generations can take over a minute. |
See .env.example. All logging goes to stderr; stdout is reserved for the MCP protocol.
Register with Claude Code
The server writes images relative to its working directory, and Claude Code starts MCP servers in the
project directory, so a user-scoped registration puts assets into whichever project you are working in.
Use uv run --project (not --directory) so the working directory stays your project:
claude mcp add openai-image --scope user \
-e OPENAI_API_KEY=sk-... \
-- uv run --project /absolute/path/to/openai-image-mcp openai-image-mcpEquivalent project-scoped setup in the project's .mcp.json (commit it, keep the key out of it by
using an environment reference):
{
"mcpServers": {
"openai-image": {
"command": "uv",
"args": ["run", "--project", "/absolute/path/to/openai-image-mcp", "openai-image-mcp"],
"env": {
"OPENAI_API_KEY": "${OPENAI_API_KEY}",
"IMAGE_OUTPUT_DIR": "./public/images/generated"
}
}
}
}Verify with claude mcp list, then ask Claude Code to "generate a hero image for the landing page".
Register with Claude Desktop
Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json,
Windows: %APPDATA%\Claude\claude_desktop_config.json). Claude Desktop does not start servers inside a
project directory, so set IMAGE_OUTPUT_DIR to an absolute path:
{
"mcpServers": {
"openai-image": {
"command": "uv",
"args": ["run", "--project", "/absolute/path/to/openai-image-mcp", "openai-image-mcp"],
"env": {
"OPENAI_API_KEY": "sk-...",
"IMAGE_OUTPUT_DIR": "/absolute/path/to/your/project/assets/generated"
}
}
}
}If Desktop cannot find uv, use its absolute path (which uv) as command.
Getting started: example prompts
Once the server is registered, you talk to Claude in plain language and it picks the tool and
parameters. Everything below is something you can type into Claude Code (inside your project) or
Claude Desktop. Generated files land in IMAGE_OUTPUT_DIR, and Claude sees a preview of each result,
so you can follow up with "make it warmer" or "try a version without text".
First image
Generate a hero image for the landing page: a lighthouse on a rocky coast at dawn, soft pastel sky, flat vector illustration, no text. Save it as
hero-lighthouse.
Claude calls generate_image with size: "hero", filename: "hero-lighthouse", and reports the path,
for example assets/generated/hero-lighthouse.png, plus a preview.
Quick drafts, then a final render
Give me three low-quality draft ideas for a blog card about database migrations, landscape format.
generate_image with n: 3, quality: "low", size: "landscape". Pick one, then:
I like the second one. Regenerate it at high quality with the same prompt and call it
blog-migrations.
Icons and logos with transparent backgrounds
Create a transparent PNG app icon of a paper airplane, single flat blue shape, centered, 512x512.
generate_image with background: "transparent", output_format: "png", size: "512x512".
Transparent output needs png or webp; Claude gets a clear error if it asks for jpeg.
Make a webp banner for the newsletter header, 1400x500, our mascot waving, warm colours.
generate_image with output_format: "webp" and size: "1400x500". Dimensions are rounded to
multiples of 16, and the result reports the size actually produced (here 1408x496). Anything wider
than 3:1 (or taller than 1:3) is rejected with a message explaining the limit.
A consistent set of assets
First create a brand board: a style sheet with a navy, amber and off-white palette, flat vector illustration style, soft shadows, rounded geometry, no text. Landscape, high quality, filename
brand-board.
Then, for every further asset:
Using
assets/generated/brand-board.pngas the reference, create a feature illustration of a developer at a desk with two monitors, landscape, filenamefeature-workspace.
Same reference: a transparent PNG icon of a cloud with an upload arrow, square, filename
icon-upload.
Each of these is an edit_image call with reference_paths: ["assets/generated/brand-board.png"].
The section below shows how to make this the default via CLAUDE.md.
Editing an existing image
Take
public/images/team-photo.jpgand turn it into a flat illustration in the same composition, keep the number of people and their poses.
Using
assets/generated/hero-lighthouse.pngas reference, produce a night-time version with a lit lamp and a starry sky, same framing.
Combine
assets/logo.pngandassets/generated/hero-lighthouse.png: place the logo bottom-right on the hero as a small watermark.
All three are edit_image calls; the last one passes both files in reference_paths. With a mask:
Using
assets/generated/hero-lighthouse.pngand the maskassets/masks/sky.png, replace the sky with a dramatic thunderstorm and leave the rest untouched.
Masking is prompt-guided rather than pixel-exact, so keep the description of the change in the prompt.
Picking up where you left off
What images have already been generated in this project?
list_generated_images returns each file's path, dimensions, size in KB, and the prompt from its
sidecar, so a new session can reuse a brand board or earlier asset without regenerating it.
Wiring the result into a site
Generate an Open Graph image for the pricing page, 1200x630, and add it to the page's
<meta>tags.
Claude generates the file, then edits your HTML or framework config to reference the returned path. Because the file is already in your project tree, no copying step is needed.
Size presets
Preset | Pixels | Typical use |
| 1024x1024 | Icons, avatars, social tiles (default) |
| 1536x1024 | Blog and card images |
| 1024x1536 | Posters, mobile screens |
| 1920x1088 | Full-width hero sections |
| 1536x512 | Headers, email banners |
| model decides | When the prompt implies a shape |
Explicit WIDTHxHEIGHT is also accepted. Each dimension is rounded to the nearest multiple of 16
(minimum 256); the aspect ratio must be within 1:3 to 3:1 and neither side may exceed 3840. The tool
result reports the size actually produced. background="transparent" requires png or webp output.
Consistent assets
To keep one look across a whole set of assets, generate a brand board first and then pass it as a
reference for every subsequent image. A suggested snippet for a project's CLAUDE.md:
## Image assets
- Images are generated with the `openai-image` MCP server into `assets/generated/`.
- Run `list_generated_images` first; if `assets/generated/brand-board.png` exists, reuse it.
- If it does not exist, create it once with `generate_image`
(filename `brand-board`, size `landscape`, quality `high`): a style sheet showing our palette
(#0B3D91 navy, #F2A900 amber, off-white), flat vector illustration style, soft shadows,
rounded geometry, no text.
- Create every other asset with `edit_image`, passing
`reference_paths: ["assets/generated/brand-board.png"]` and describing the new subject
in the prompt ("In the style of the reference: …"). Use `background: transparent`
with `png` for icons and logos.
- Inspect the returned preview; if it is off-brand, adjust the prompt and regenerate rather
than editing the file by hand.Errors
Common OpenAI failures are translated into short, actionable messages: missing organization verification, safety-system (content policy) rejections, rate limits and quota, and timeouts. The OpenAI request ID is included when available. Transient errors are retried by the OpenAI SDK's default policy; the server adds no retry loop of its own.
Development
uv sync # installs dev dependencies (pytest)
uv run pytest # unit tests + a stdio round-trip; no network access
uv run python scripts/smoke.py # one real low-quality generation; needs OPENAI_API_KEYLayout: src/openai_image_mcp/server.py (tool definitions), client.py (OpenAI calls and error
translation), images.py (size handling, file naming, sidecars, previews).
Available Tools
3 toolsedit_imageA
Create a new image that is guided by one or more existing images (1-8 reference files) plus a text prompt, save it to the project's generated-assets directory, and return a preview. The model sees every reference image and the prompt together, so use this tool whenever the result must stay consistent with images you already have: to keep one visual style across a whole set of assets, pass the same brand-board or style-reference image in reference_paths for every asset and describe the new subject in the prompt (for example 'In the style of the reference: a hero illustration of a lighthouse at dawn'). Also use it to modify an image (change colours, add or remove elements, restyle it) or to combine several images into one. For a brand-new image with no reference, use generate_image. MASKING: mask_path is an optional PNG the same size as the first reference whose transparent pixels mark the region to change. Masking is prompt-guided rather than pixel-exact: the model treats the mask as strong guidance and may adjust areas near the edge, so always describe the desired change in the prompt too. Paths may be absolute or relative to the server's working directory. SIZE: pass a preset name or explicit WIDTHxHEIGHT. Presets: 'square' (1024x1024), 'landscape' (1536x1024), 'portrait' (1024x1536), 'hero' (1920x1088), 'banner' (1536x512), 'auto' (model picks). Explicit sizes are rounded to the nearest multiple of 16 (minimum 256); the aspect ratio must be between 1:3 and 3:1 and neither side may exceed 3840. The result text reports the size actually produced, so check it if the exact pixel size matters. BACKGROUND: 'transparent' produces an alpha channel and requires output_format 'png' or 'webp' (never 'jpeg'); use it for logos, icons and cut-out illustrations. QUALITY: 'low' is fast and cheap (good for drafts and iteration), 'high' is slow (can take over a minute) and detailed; 'auto' lets the model choose. RETURNS: for each image, a text block with the absolute file path, final width x height, model, quality and the path of a .json sidecar holding the prompt and settings, followed by a small JPEG preview (longest side 512px) so you can inspect the result. The full-resolution file is already on disk; reference it by the returned path (for example as a site asset).
Inputs: prompt (required), reference_paths (required), size, quality, +4 more.
generate_imageA
Generate one or more brand-new images from a text prompt using OpenAI's image model, save them as files in the project's generated-assets directory, and return a small preview of each. Use this when no existing image needs to guide the result. If you need the new image to match the look of images you already have (a brand board, an earlier asset, a photo to modify), use edit_image instead and pass those files as references. Write prompts as a full description: subject, style, composition, lighting, colour palette, and any text that must appear. SIZE: pass a preset name or explicit WIDTHxHEIGHT. Presets: 'square' (1024x1024), 'landscape' (1536x1024), 'portrait' (1024x1536), 'hero' (1920x1088), 'banner' (1536x512), 'auto' (model picks). Explicit sizes are rounded to the nearest multiple of 16 (minimum 256); the aspect ratio must be between 1:3 and 3:1 and neither side may exceed 3840. The result text reports the size actually produced, so check it if the exact pixel size matters. BACKGROUND: 'transparent' produces an alpha channel and requires output_format 'png' or 'webp' (never 'jpeg'); use it for logos, icons and cut-out illustrations. QUALITY: 'low' is fast and cheap (good for drafts and iteration), 'high' is slow (can take over a minute) and detailed; 'auto' lets the model choose. RETURNS: for each image, a text block with the absolute file path, final width x height, model, quality and the path of a .json sidecar holding the prompt and settings, followed by a small JPEG preview (longest side 512px) so you can inspect the result. The full-resolution file is already on disk; reference it by the returned path (for example as a site asset).
Inputs: prompt (required), n, size, quality, +3 more.
list_generated_imagesA
List the images this server has written to the project's generated-assets directory (IMAGE_OUTPUT_DIR, default ./assets/generated): absolute path, pixel dimensions, file size in KB, and the prompt that produced each one when its .json sidecar exists. Use it at the start of a session to discover assets (such as a brand board) created earlier, so you can reuse them or pass them to edit_image as references.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools have clearly distinct purposes: generate_image creates new images from text only, edit_image modifies or creates images guided by reference images, and list_generated_images discovers previously created assets. No overlap or ambiguity exists between them.
All tool names follow a consistent verb_noun snake_case pattern: generate_image, edit_image, list_generated_images. The verbs clearly indicate the action and the nouns consistently refer to images.
Three tools is well-scoped for an image generation server: create, edit, and list. Each tool earns its place and there is no bloat or missing core functionality.
The tool set covers the full lifecycle for this domain: generating new images, editing existing ones (including masking and style references), and listing previously generated assets for reuse. No critical dead end or missing operation is apparent.
Maintenance
Related MCP Connectors
MCP server for Qwen Image 3 AI image generation
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables Claude Code to generate context-aware images using local GPU-powered diffusion models, either automatically during coding or on-demand via slash commands.25 npm1MIT
- AlicenseAqualityDmaintenanceAn MCP server that gives Claude Code and Cursor the ability to generate and edit images using RunPod's Seedream V4 and Nano Banana Pro APIs.4MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that enables Claude Code to generate images using Google's Gemini image generation models.MIT
- FlicenseAqualityDmaintenanceA local MCP server that enables Claude to generate images using the OpenAI API.2-