openai-image
Provides tools to generate and edit images through the OpenAI Images API, including still images, animated GIFs, SVG generation, and image editing or composition with optional masks or markup overlays.
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-imageGenerate a watercolor sunset over mountains and save it to /Users/me/Pictures"
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 is a stdio Model Context Protocol server. It calls the official OpenAI Images API, writes the files to an absolute output_dir, and returns paths plus metadata. Tool results never include base64.
npx -y @felixpy/openai-image@latestQuick start
1. API key
The server reads OPENAI_API_KEY from the environment. It is required for a tool call and is never logged. A missing key does not stop the process from starting.
export OPENAI_API_KEY=sk-...Variable | Default | Role |
| required for tool calls | Sent by the OpenAI SDK. Never commit it. |
|
| Model used when a call omits |
| OpenAI default | Optional. Read by the OpenAI SDK. |
2. Register the server
Every snippet starts the published package over stdio. Replace sk-... locally. Do not commit a real key.
Bare npx -y <pkg> can keep reusing a cached older version, while @latest makes npx check npm on each start; pin a version like @0.2.0 instead if you want reproducible behavior.
Cursor
~/.cursor/mcp.json or .cursor/mcp.json:
{
"mcpServers": {
"openai-image": {
"command": "npx",
"args": ["-y", "@felixpy/openai-image@latest"],
"env": {
"OPENAI_API_KEY": "sk-..."
}
}
}
}Claude Desktop
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"openai-image": {
"command": "npx",
"args": ["-y", "@felixpy/openai-image@latest"],
"env": {
"OPENAI_API_KEY": "sk-..."
}
}
}
}Claude Code
claude mcp add openai-image \
-e OPENAI_API_KEY=sk-... \
-- npx -y @felixpy/openai-image@latestCodex
~/.codex/config.toml:
[mcp_servers.openai-image]
command = "npx"
args = ["-y", "@felixpy/openai-image@latest"]
env = { OPENAI_API_KEY = "sk-..." }Related MCP server: image-generation-mcp
Tools
Tool | API | Required | Also accepts |
|
|
| Shared image fields, plus |
|
|
| Shared image fields, plus |
openai_image_generate creates still images, animated GIFs (output_format=gif), or SVG. openai_image_edit edits or composes up to 16 reference images, optionally guided by a mask or a markup overlay. Both save files under output_dir and return their paths.
A successful result is text JSON. URLs and revised_prompt are included only when the API sends them.
{
"model": "gpt-image-2.6-flare",
"files": ["/absolute/path/image-2026-11-05T00-00-00-000Z-0.png"],
"usage": null,
"size": "1024x1024",
"quality": "auto",
"output_format": "png"
}API failures, including moderation_blocked, come back as tool errors with status, code, type, param, message, request_id, and the raw error body. The client uses maxRetries: 2 and a 180 second timeout.
Parameters
Schemas are loose strings on purpose. The API validates values, so a new option usually needs no code change. Unknown fields can go through extra, which is shallow-merged last.
Shared
Parameter | Required | Range and notes |
| yes | Absolute directory. A relative path is rejected. The directory is created if needed. |
| no | Default is |
| no |
|
| no |
|
| no | Planning effort, separate from quality: |
| no | Integer from 1 to 10. |
| no |
|
| no |
|
| no | Integer from 0 to 100. |
| no | GIF only. Integer, minimum 2, default 9. The SDK documents 2–16 and the image guide documents 2–64. Describe the motion and a return to the starting pose so the loop is smooth. |
| no | GIF only. Integer from 20 to 2000, rounded to 10. Default 200. |
| no |
|
| no | Optional stable hashed end-user id for OpenAI abuse monitoring. |
| no | Object shallow-merged into the request last, for example |
openai_image_generate
Parameter | Required | Range and notes |
| yes | Text prompt. Maximum 32000 characters. |
| no | SVG only, with |
openai_image_edit
Parameter | Required | Range and notes |
| yes | Edit instructions. |
| yes | Local paths. Minimum 1. The API accepts up to 16 reference images. |
| no | PNG mask, same size as the first image. Transparent pixels are the area to edit. Cannot be combined with |
| no | Transparent PNG overlay with marks, arrows, or notes, same size as the first image. Cannot be combined with |
| no |
|
Edit accepts the shared fields, including output_format. GIF output from edit was verified on 2026-11-05.
Notes
GIF. Set
output_formattogifon generate or edit. Useframe_countandframe_duration_msto shape the loop. Edit GIF output was verified on 2026-11-05.Absolute
output_dir. The path must be absolute. Relative paths are rejected before the API is called.No base64 in tool results. Bytes are written to disk. The tool returns file paths, the model,
usage, andrevised_promptwhen the API provides one.Pass-through.
extrais shallow-merged last, so new API fields work without a release.
Development
Node.js 20 or newer.
npm ci
npm test
npm run build
npm startnpm test builds dist/ and completes an MCP initialize plus tools/list handshake. It does not call the OpenAI API and does not need OPENAI_API_KEY.
See CONTRIBUTING.md for commit style and pull requests, and docs/publishing.md for the one-time npm setup.
Project
Available Tools
2 toolsopenai_image_editB
Edit images or compose from up to 16 reference images (OpenAI images.edit), optionally guided by a mask or markup overlay. Saves files to output_dir and returns their paths.
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images, 1-10 | |
| size | No | auto, 1024x1024, 1536x1024, 1024x1536, or WIDTHxHEIGHT (both multiples of 16, aspect 1:3 to 3:1, max 3840x2160). For GIF this is the size of each frame; keep it small (e.g. 512x512) to fit the pixel budget | |
| extra | No | Extra API params shallow-merged into the request last, e.g. {"complexity":"high"} | |
| model | No | Image model (default gpt-image-2.6-flare). e.g. gpt-image-2.6-flare (fast), gpt-image-2.6-sunburst (detail/precise edits), gpt-image-2.5-flare, gpt-image-2.5-sunburst | |
| prompt | Yes | Edit instructions | |
| quality | No | auto (default), low, medium, high, xhigh, max | |
| mask_path | No | Optional PNG mask, same size as the first image (transparent = area to edit). Cannot combine with markup_path | |
| background | No | auto (default), opaque, transparent (transparent needs png, webp or svg) | |
| complexity | No | Planning effort, separate from quality: low, medium, high (2.6 default high) | |
| moderation | No | auto (default), low | |
| output_dir | Yes | Absolute directory to save images in. Follow your workspace conventions: the current project folder if any, else your own tmp dir. | |
| frame_count | No | GIF only: number of frames (default 9; SDK says 2-16, guide says 2-64). Describe the motion and a return to the starting pose in the prompt for a smooth loop | |
| image_paths | Yes | Local paths of one or more input/reference images | |
| markup_path | No | Optional transparent PNG overlay with marks/arrows/notes drawn on it, same size as the first image, to guide the edit. Cannot combine with mask_path | |
| output_format | No | png (default), jpeg, webp; generate also supports gif (animated) and svg | |
| input_fidelity | No | high or low; gpt-image-1.5 / 1-mini only, omit for gpt-image-2 and later | |
| frame_duration_ms | No | GIF only: ms per frame, 20-2000, rounded to 10 (default 200) | |
| safety_identifier | No | Optional stable hashed end-user id for OpenAI abuse monitoring | |
| output_compression | No | 0-100, jpeg/webp only |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations at all, the description carries the full behavioral burden and does disclose the key trait that it writes files to disk and returns their paths. However, for a 19-parameter mutation tool it says nothing about overwrite behavior for existing filenames, required credentials, latency/cost, or failure modes — meaningful gaps when no annotations cover the mutation profile.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, both front-loaded with the operation and then the output behavior. There is no filler, no restatement of parameters, and no redundancy with the schema.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
It correctly covers the return semantics ('returns their paths') in the absence of an output schema, which is important given 19 parameters and file output. But the description is thin for a tool this complex: it omits file-overwrite behavior, credential prerequisites, and the relationship to the generate sibling, leaving real gaps for an agent preparing a call.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents nearly all 19 parameters and a baseline of 3 would be defensible. The description still adds value beyond the schema by stating the 'up to 16 reference images' cap (the schema only specifies minItems: 1 with no maximum) and by framing mask/markup as optional guidance mechanisms.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific verb and resource ('Edit images or compose from up to 16 reference images'), identifies the underlying API (images.edit), and adds scoping detail (mask or markup overlay, files saved to output_dir). It is clear what the tool does, though it never explicitly contrasts itself with the sibling openai_image_generate beyond the implicit edit-vs-generate distinction.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is only implied: the agent can infer this is for transforming existing images rather than creating new ones. There is no explicit statement of when to choose this over openai_image_generate, nor any guidance on preconditions (e.g. images must exist locally) beyond what the schema states.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
openai_image_generateB
Generate images (OpenAI images.generate): still images, animated GIF (output_format=gif) or SVG. Saves files to output_dir and returns their paths.
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images, 1-10 | |
| svg | No | SVG only (output_format=svg, n=1): author model and reasoning, e.g. {"model":"...","reasoning":{"effort":"high"}}. Needs SVG model-selection access; omit otherwise | |
| size | No | auto, 1024x1024, 1536x1024, 1024x1536, or WIDTHxHEIGHT (both multiples of 16, aspect 1:3 to 3:1, max 3840x2160). For GIF this is the size of each frame; keep it small (e.g. 512x512) to fit the pixel budget | |
| extra | No | Extra API params shallow-merged into the request last, e.g. {"complexity":"high"} | |
| model | No | Image model (default gpt-image-2.6-flare). e.g. gpt-image-2.6-flare (fast), gpt-image-2.6-sunburst (detail/precise edits), gpt-image-2.5-flare, gpt-image-2.5-sunburst | |
| prompt | Yes | Text prompt (max 32000 chars) | |
| quality | No | auto (default), low, medium, high, xhigh, max | |
| background | No | auto (default), opaque, transparent (transparent needs png, webp or svg) | |
| complexity | No | Planning effort, separate from quality: low, medium, high (2.6 default high) | |
| moderation | No | auto (default), low | |
| output_dir | Yes | Absolute directory to save images in. Follow your workspace conventions: the current project folder if any, else your own tmp dir. | |
| frame_count | No | GIF only: number of frames (default 9; SDK says 2-16, guide says 2-64). Describe the motion and a return to the starting pose in the prompt for a smooth loop | |
| output_format | No | png (default), jpeg, webp; generate also supports gif (animated) and svg | |
| frame_duration_ms | No | GIF only: ms per frame, 20-2000, rounded to 10 (default 200) | |
| safety_identifier | No | Optional stable hashed end-user id for OpenAI abuse monitoring | |
| output_compression | No | 0-100, jpeg/webp only |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description does disclose the key behavioral fact that this writes files to output_dir and returns their paths, which tells the agent this is a mutating, persistent operation. It omits other relevant traits: cost/latency of image generation, whether existing files are overwritten, and what happens on partial failure.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with the action and followed by the persistence/return behavior; nothing is padded. The parenthetical API name is slightly redundant but harmless.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 16-parameter tool with nested objects, no annotations, and no output schema, the description covers the essentials (what it produces, where files go, what comes back) but leaves the agent without guidance on format/size tradeoffs, cost, or the edit-vs-generate decision. The schema carries most of the remaining detail, so it is adequate rather than complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, and the schema already explains formats, sizes, frame counts, model names, and the SVG sub-object in detail. The description adds only the cross-parameter link between GIF output and output_format=gif, so the baseline of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource ("Generate images (OpenAI images.generate)") and enumerates the three output kinds (still, animated GIF, SVG), plus the side effect of saving files. It distinguishes itself naturally from the sibling openai_image_edit by being the generation path, though it never names that sibling explicitly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is only implied: an agent can infer this is for creating new images rather than editing existing ones, but the description never says "use openai_image_edit to modify an existing image" or states any exclusion or precondition beyond the SVG-access note carried in the schema. No guidance on when to prefer one model or format.
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.
2 tool updates
v0.2.0- First observed
openai_image_edit - First observed
openai_image_generate
TDQS
Scored across 2 tools
The two tools are cleanly separated by OpenAI endpoint semantics: generate creates new images, edit modifies or composes from existing references. Descriptions make the boundary explicit (new content vs. reference-based modification), so an agent cannot reasonably confuse them.
Both names follow the same predictable pattern: openai_image_<verb> in snake_case, with the shared prefix mirroring the provider and resource. No mixing of conventions or stylistic outliers.
Two tools is minimal but well matched to a single-provider image server where generate and edit are the two real operations. Each earns its place; the surface is small by design rather than arbitrarily truncated.
Generation and reference-based editing cover the core image lifecycle, including GIF/SVG output and multi-reference composition. Minor gaps remain (e.g. no image variations endpoint, no listing or retrieval of previously saved outputs), but agents can work around these via the returned file paths.
Maintenance
Related MCP Connectors
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
Generate AI images and videos from any compatible MCP client.
Generate on-brand images from your AI agent: design, edit, and render templates over MCP.
Generate images with any major model — one API key, one prepaid balance, one MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceGenerates and edits images using OpenAI image models via MCP tools.MIT
- 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
- AlicenseNot gradedqualityCmaintenanceEnables MCP clients to generate and edit images through any OpenAI-compatible image API, saving results as local files and returning absolute paths for immediate use.14 npmMIT
- AlicenseAqualityBmaintenanceEnables MCP clients to generate images and iteratively edit them using OpenAI's gpt-image-2 models, with session management, background job polling, and local file saving.8556 npmMIT