gpt-image-mcp
Provides tools for generating and editing images through an OpenAI-compatible /v1/images API, including text-to-image generation with configurable size, quality, background, format, and model, plus image editing/restyling with masks and multiple outputs. Results are saved to disk and can be returned inline.
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., "@gpt-image-mcpgenerate a watercolor image of a red fox in the snow and save it as fox.png"
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.
gpt-image-mcp
An MCP server that lets coding agents draw. It wraps an
OpenAI-compatible /v1/images API and exposes it as two tools, so pi, Claude Code, Cursor, Codex,
and anything else that speaks MCP can generate and edit images as part of a normal task.
Text-only chat models cannot produce images, and most agent harnesses have no image tool. This fills
that gap: the model calls generate_image, gets the picture back inline (so it can actually look
at what it made) and a file on disk (so the next turn can reference, move, or ship it).
Zero dependencies — one
server.mjs, Node built-ins onlyStdio transport,
2025-06-18protocol (negotiates down to2024-11-05)Returns both image content blocks and saved files
Never touches your key beyond the
Authorizationheader
Tools
Tool | Purpose |
| Text → image. |
| Edit / restyle / extend existing images. |
Both save every result to disk (./generated-images by default), print the paths, and attach the
images inline. Multiple results get -1, -2 suffixes; name collisions are avoided automatically.
b64_json and url responses are both handled, so gpt-image and dall-e style providers both work.
Related MCP server: DreamLayer image tools
Quick start
# try it without installing (from this repo)
npx -y github:TypeDreamMoon/gpt-image-mcp --check
# or install globally
npm i -g github:TypeDreamMoon/gpt-image-mcp--check prints the resolved configuration and probes the endpoint. It costs nothing.
export IMAGE_API_KEY=sk-...
node server.mjs --draw "a red fox in the snow, watercolor" # costs one imageConfigure
Everything is an environment variable; there are no config files.
Variable | Default | Notes |
| — | Required. Falls back to |
| — | Path to a file containing the key; wins over the two above |
|
| OpenAI-compatible base; trailing |
|
| Default model for both tools |
|
| Where images are written |
|
| Image models are slow; do not set this low |
|
| Set to |
| — | Extra JSON merged into the request body, for provider-specific fields |
|
| Multipart field name for edits, if a relay expects something else |
Client setup
pi
~/.pi/agent/mcp.json:
{
"mcpServers": {
"gpt-image": {
"command": "node",
"args": ["/absolute/path/to/gpt-image-mcp/server.mjs"],
"timeout": 300,
"exposure": "direct",
"env": { "IMAGE_API_KEY": "sk-...", "IMAGE_MODEL": "gpt-image-1" }
}
}
}timeout: 300— pi defaults to 60 seconds per request, which image generation will exceed.exposure: "direct"— declares the tools to the model up front. Use"deferred"to keep the tool list small behindtool_search, or omit it (defaultcodemode) to reach the tools from scripts.
Check it: pi mcp list should report gpt-image: connected, 2 tools.
Claude Code
claude mcp add gpt-image --scope user \
--env IMAGE_API_KEY=sk-... --env IMAGE_MODEL=gpt-image-1 \
-- node /absolute/path/to/gpt-image-mcp/server.mjs
claude mcp listCursor, Claude Desktop, Codex, anything else
Use the standard mcpServers entry — command, args, env — wherever that client keeps its MCP
configuration. Codex takes the TOML equivalent under [mcp_servers.gpt-image].
Verify without spending money
node test.mjsRuns a local mock of the OpenAI image API and drives the server over real stdio JSON-RPC: handshake,
tools/list, schema shape, generation, multipart editing, file saving, output_dir override, usage
passthrough, missing-key errors, provider 401s, and unknown tools. 18 checks, no network, no key.
Provider requirements
The server needs an endpoint that implements the OpenAI images API:
POST {IMAGE_BASE_URL}/images/generations ← generate_image
POST {IMAGE_BASE_URL}/images/edits ← edit_image (multipart)Official OpenAI (gpt-image-1, gpt-image-1-mini, dall-e) works out of the box. Many OpenAI-compatible
relays also expose /v1/images/generations; point IMAGE_BASE_URL at theirs and set IMAGE_MODEL to
the name they list.
⚠️ Plenty of chat-only relays advertise image models in /v1/models but return 404 on the images
endpoints, and some reject image_generation inside /v1/responses. Run --check and then --draw
before wiring it into an agent. A relay that only serves chat completions cannot be used here.
Notes and limitations
Images are returned inline by default. A 1024×1024 PNG is roughly 1–3 MB of base64, which costs context on every turn it stays in history; set
IMAGE_INLINE=0to keep files only.No retries. Failures here are usually quota or moderation, which retrying will not fix — the provider's message is passed through verbatim.
Generated images bypass any image downscaling the harness applies to files it reads.
edit_imagesendsmultipart/form-data; a few relays expect a JSON body withimages[].image_urlinstead. That shape is not supported yet.
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
Create images & video from any MCP agent — 17 models, spend limits, one URL.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to generate and edit images through OpenAI's DALL-E models via MCP tools. Supports text-to-image generation and image-to-image editing with configurable parameters for size, quality, and style.-
- AlicenseAqualityBmaintenanceImage tools for coding agents: generate from text, edit one reference image, remove backgrounds, upscale 2x, and create reference-based sprite animations. The MCP server, CLI and REST API share one key, credit balance and request history. Needs a DreamLayer API key and paid credits; sprite sheets are beta.7277 npmMIT
- 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.121 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.MIT