OpenAI Image MCP Server
This server enables AI-powered image generation and editing using OpenAI's gpt-image models directly from Claude or any MCP client.
Generate images (
generate_image): Create one or more images from a text prompt, with control over model, size, quality, background, output format (PNG/JPEG/WebP), compression, and moderation settings.Edit images (
edit_image): Edit, extend, or compose existing images using a prompt and an optional mask, supporting multiple input images and fine-tuned parameters like input fidelity, quality, and output format.Multi-turn iterative image editing (
edit_image_conversation): Perform stateful, conversational image editing across multiple turns using the Responses API, chaining edits viaprevious_response_idand supporting partial image streaming.Discover model capabilities (
image_capabilities): Query available models, their supported parameters, size/quality limits, pricing information, and default settings.Flexible output options: Save generated images to a local directory (
IMAGE_OUTPUT_DIR) as file paths, receive them as base64-encoded data, or both.Cost controls: Set maximum cost per call (
MAX_COST_PER_CALL_USD), require confirmation for bulk generation (CONFIRM_ABOVE_N), and optionally log per-call cost records as JSONL for tracking usage.Configurable via environment variables for API keys, default models, output modes, and security settings for URL inputs.
Provides tools for generating, editing, and multi-turn editing images using OpenAI's gpt-image models.
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 Server generate an image of a sunset over the ocean"
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
MCP server for OpenAI gpt-image models — generate, edit, and multi-turn edit images straight from Claude (or any MCP client).
Tools
generate_image— text → image(s)edit_image— edit / extend / compose with an optional maskedit_image_conversation— multi-turn iterative edit (Responses API)image_capabilities— discover models, params, pricing as-of date
Related MCP server: GPT Image 1 MCP
Quick start
1. Get the code & build
git clone <repo-url> openai-image-mcp
cd openai-image-mcp
npm install
npm run buildnpm run build produces dist/index.js — the entrypoint you point Claude at.
2. Register with Claude Code (one command)
claude mcp add openai-image --scope user \
--env OPENAI_API_KEY=sk-your-openai-api-key \
--env IMAGE_OUTPUT_DIR=/absolute/path/to/images \
-- node /absolute/path/to/openai-image-mcp/dist/index.jsUse an absolute path to
dist/index.js(output of step 1).IMAGE_OUTPUT_DIRis where generated images are written. Optional — defaults to~/Pictures/openai-image-mcp.--scope usermakes it available in every project. Use--scope projectto limit it to the current repo.
Verify it registered:
claude mcp list3. Use it
In Claude, just ask — e.g. "generate an image of a red bicycle on the beach".
The server writes the file under IMAGE_OUTPUT_DIR and returns the path.
Configuration (env vars)
Var | Required | Default | Purpose |
| yes¹ | — | OpenAI API key |
| yes¹ | — | path to a file containing the API key (trailing whitespace trimmed); used when |
| no |
| where images are saved |
| no |
| gpt-image-1 / gpt-image-1-mini / gpt-image-2 |
| no |
|
|
| no | — | reject a call whose estimate exceeds this |
| no | — | require |
| no |
| allow image inputs given as URLs (see Security) |
¹ Exactly one of OPENAI_API_KEY or OPENAI_API_KEY_FILE is required. Prefer OPENAI_API_KEY_FILE pointing to a chmod 600 file so the key does not live in client config files.
| SPEND_LOG_PATH | no | — | append per-call cost records as JSONL |
| PROMPT_ENHANCE | no | false | locally augment short prompts (no extra LLM call) |
| OPENAI_BASE_URL | no | — | override API base URL |
| LOG_LEVEL | no | info | debug | info | warn | error |
Add any of these as extra --env KEY=value flags on the claude mcp add command.
Manual MCP config (other clients)
If your client uses a JSON config (Claude Desktop, Cursor, VSCode), add:
{
"mcpServers": {
"openai-image": {
"command": "node",
"args": ["/absolute/path/to/openai-image-mcp/dist/index.js"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"IMAGE_OUTPUT_DIR": "/absolute/path/to/images"
}
}
}
}Security notes
URL image input is off by default. Set
ALLOW_URL_INPUT=trueto enable. When on, fetches resolve all DNS addresses and reject any private / loopback / link-local / CGNAT / IPv4-mapped target, re-validating on every redirect hop (SSRF guard).Output paths are confined to
IMAGE_OUTPUT_DIR; existing files are never overwritten (a numeric suffix is added on collision).Logs go to stderr only; stdout is reserved for the MCP protocol.
Development
npm test # run the vitest suite
npm run typecheck # tsc --noEmit
npm run build # compile to dist/Notes
Models: gpt-image-1 (deprecating 2026-10-23), gpt-image-1-mini, gpt-image-2 (default).
DALL-E was removed from the OpenAI API (2026-05-12) — not supported.
Pricing data is as of 2026-06; query the
image_capabilitiestool for details.
Available Tools
4 toolsedit_imageC
Edit, extend, or compose images with a prompt and optional mask (gpt-image).
Inputs: images (required), prompt (required), n, mask, +10 more.
edit_image_conversationB
Multi-turn iterative image editing via the Responses API (stateful by previous_response_id).
Inputs: prompt (required), model, action, output, +3 more.
generate_imageC
Generate image(s) from a text prompt using OpenAI gpt-image models.
Inputs: prompt (required), n, size, model, +7 more.
image_capabilitiesA
Discover available models, allowed params, size/quality limits, pricing as-of date, and defaults.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct image operation: single edit, multi-turn edit, generation from text, and capability discovery. There is no overlap in purpose.
Tool names mix verb_noun (edit_image, generate_image) with noun_noun (image_capabilities) and a longer compound (edit_image_conversation). While all use snake_case, the pattern is inconsistent.
Four tools cover essential image operations without excess. The scope is well-defined for a focused MCP server.
Core image generation and editing workflows are covered, including multi-turn. Missing a dedicated variation tool is a minor gap, but the set is largely complete.
Maintenance
Related MCP Connectors
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
MCP server for Qwen Image 3 AI image generation
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.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP tool server that enables generating and editing images through OpenAI's image models, supporting text-to-image generation and advanced image editing (inpainting, outpainting) across various MCP-compatible clients.119MIT
- AlicenseDqualityDmaintenanceA Model Context Protocol server that enables generating and editing images using OpenAI's gpt-image-1 model, allowing AI assistants to create and modify images from text prompts.279 npm18MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that wraps OpenAI's image generation and editing APIs, enabling text-to-image and image-to-image operations via tools.230 npm37ISC
- AlicenseAqualityCmaintenanceExposes OpenAI's gpt-image-2 (image generation and editing) as an MCP server for tools like generate_image, edit_image, and iterative edit sessions.6104 npm13MIT