Skip to main content
Glama

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@latest

Quick 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

OPENAI_API_KEY

required for tool calls

Sent by the OpenAI SDK. Never commit it.

OPENAI_IMAGE_MODEL

gpt-image-2.6-flare

Model used when a call omits model.

OPENAI_BASE_URL

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@latest

Codex

~/.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

openai_image_generate

images.generate

prompt, output_dir

Shared image fields, plus svg

openai_image_edit

images.edit

prompt, image_paths, output_dir

Shared image fields, plus mask_path, markup_path, input_fidelity

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

output_dir

yes

Absolute directory. A relative path is rejected. The directory is created if needed.

model

no

Default is OPENAI_IMAGE_MODEL or gpt-image-2.6-flare. Examples: gpt-image-2.6-flare (fast), gpt-image-2.6-sunburst (detail and precise edits), gpt-image-2.5-flare, gpt-image-2.5-sunburst.

size

no

auto, 1024x1024, 1536x1024, 1024x1536, or WIDTHxHEIGHT. Both sides must be multiples of 16, the aspect ratio must be from 1:3 to 3:1, and the maximum is 3840x2160. For GIF this is the size of each frame. Keep frames small, for example 512x512, so the animation fits the pixel budget.

quality

no

auto (default), low, medium, high, xhigh, max.

complexity

no

Planning effort, separate from quality: low, medium, high. gpt-image-2.6 defaults to high.

n

no

Integer from 1 to 10.

background

no

auto (default), opaque, transparent. Transparent requires png, webp, or svg.

output_format

no

png (default), jpeg, webp. Generate also supports gif (animated) and svg.

output_compression

no

Integer from 0 to 100. jpeg and webp only.

frame_count

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.

frame_duration_ms

no

GIF only. Integer from 20 to 2000, rounded to 10. Default 200.

moderation

no

auto (default), low.

safety_identifier

no

Optional stable hashed end-user id for OpenAI abuse monitoring.

extra

no

Object shallow-merged into the request last, for example {"complexity":"high"}.

openai_image_generate

Parameter

Required

Range and notes

prompt

yes

Text prompt. Maximum 32000 characters.

svg

no

SVG only, with output_format=svg and n=1. Object {"model":"...","reasoning":{"effort":"high"}}. Needs SVG model-selection access. Omit it otherwise.

openai_image_edit

Parameter

Required

Range and notes

prompt

yes

Edit instructions.

image_paths

yes

Local paths. Minimum 1. The API accepts up to 16 reference images.

mask_path

no

PNG mask, same size as the first image. Transparent pixels are the area to edit. Cannot be combined with markup_path.

markup_path

no

Transparent PNG overlay with marks, arrows, or notes, same size as the first image. Cannot be combined with mask_path.

input_fidelity

no

high or low. Applies to gpt-image-1.5 and 1-mini only. Omit it for gpt-image-2 and later.

Edit accepts the shared fields, including output_format. GIF output from edit was verified on 2026-11-05.

Notes

  • GIF. Set output_format to gif on generate or edit. Use frame_count and frame_duration_ms to 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, and revised_prompt when the API provides one.

  • Pass-through. extra is 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 start

npm 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 tools
openai_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.

NameRequiredDescriptionDefault
nNoNumber of images, 1-10
sizeNoauto, 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
extraNoExtra API params shallow-merged into the request last, e.g. {"complexity":"high"}
modelNoImage 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
promptYesEdit instructions
qualityNoauto (default), low, medium, high, xhigh, max
mask_pathNoOptional PNG mask, same size as the first image (transparent = area to edit). Cannot combine with markup_path
backgroundNoauto (default), opaque, transparent (transparent needs png, webp or svg)
complexityNoPlanning effort, separate from quality: low, medium, high (2.6 default high)
moderationNoauto (default), low
output_dirYesAbsolute directory to save images in. Follow your workspace conventions: the current project folder if any, else your own tmp dir.
frame_countNoGIF 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_pathsYesLocal paths of one or more input/reference images
markup_pathNoOptional 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_formatNopng (default), jpeg, webp; generate also supports gif (animated) and svg
input_fidelityNohigh or low; gpt-image-1.5 / 1-mini only, omit for gpt-image-2 and later
frame_duration_msNoGIF only: ms per frame, 20-2000, rounded to 10 (default 200)
safety_identifierNoOptional stable hashed end-user id for OpenAI abuse monitoring
output_compressionNo0-100, jpeg/webp only

TDQS

B3.4/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness3/5

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.

Parameters4/5

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.

Purpose4/5

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.

Usage Guidelines3/5

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.

NameRequiredDescriptionDefault
nNoNumber of images, 1-10
svgNoSVG only (output_format=svg, n=1): author model and reasoning, e.g. {"model":"...","reasoning":{"effort":"high"}}. Needs SVG model-selection access; omit otherwise
sizeNoauto, 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
extraNoExtra API params shallow-merged into the request last, e.g. {"complexity":"high"}
modelNoImage 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
promptYesText prompt (max 32000 chars)
qualityNoauto (default), low, medium, high, xhigh, max
backgroundNoauto (default), opaque, transparent (transparent needs png, webp or svg)
complexityNoPlanning effort, separate from quality: low, medium, high (2.6 default high)
moderationNoauto (default), low
output_dirYesAbsolute directory to save images in. Follow your workspace conventions: the current project folder if any, else your own tmp dir.
frame_countNoGIF 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_formatNopng (default), jpeg, webp; generate also supports gif (animated) and svg
frame_duration_msNoGIF only: ms per frame, 20-2000, rounded to 10 (default 200)
safety_identifierNoOptional stable hashed end-user id for OpenAI abuse monitoring
output_compressionNo0-100, jpeg/webp only

TDQS

B3.4/5.0
Behavior3/5

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.

Conciseness4/5

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.

Completeness3/5

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.

Parameters3/5

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.

Purpose4/5

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.

Usage Guidelines3/5

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.

  1. 2 tool updatesv0.2.0
    • First observedopenai_image_edit
    • First observedopenai_image_generate

TDQS

A3.7/5.0

Scored across 2 tools

Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count4/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessSyncing

Related MCP Connectors

Related MCP Servers