Skip to main content
Glama
aleslanger

OpenAI Image MCP Server

by aleslanger

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 mask

  • edit_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 build

npm 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.js
  • Use an absolute path to dist/index.js (output of step 1).

  • IMAGE_OUTPUT_DIR is where generated images are written. Optional — defaults to ~/Pictures/openai-image-mcp.

  • --scope user makes it available in every project. Use --scope project to limit it to the current repo.

Verify it registered:

claude mcp list

3. 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

OPENAI_API_KEY

yes¹

OpenAI API key

OPENAI_API_KEY_FILE

yes¹

path to a file containing the API key (trailing whitespace trimmed); used when OPENAI_API_KEY is unset

IMAGE_OUTPUT_DIR

no

~/Pictures/openai-image-mcp

where images are saved

DEFAULT_MODEL

no

gpt-image-2

gpt-image-1 / gpt-image-1-mini / gpt-image-2

DEFAULT_OUTPUT_MODE

no

path

path | base64 | both

MAX_COST_PER_CALL_USD

no

reject a call whose estimate exceeds this

CONFIRM_ABOVE_N

no

require confirm:true when generating more than N images

ALLOW_URL_INPUT

no

false

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=true to 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_capabilities tool for details.

Available Tools

4 tools
edit_imageC

Edit, extend, or compose images with a prompt and optional mask (gpt-image).

ParametersJSON Schema
NameRequiredDescriptionDefault
nNo
maskNo
sizeNo
modelNo
imagesYes
outputNo
promptYes
confirmNo
qualityNo
backgroundNo
moderationNo
output_formatNo
input_fidelityNo
output_compressionNo

TDQS

C2.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It only states the basic action ('edit, extend, or compose') without detailing side effects, permission requirements, or impact on original images. Key behavioral aspects (e.g., moderation, output modes) are omitted.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise but lacks structure. While brevity is positive, it omits critical information that would justify its length. It could be more informative without sacrificing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (14 parameters, no output schema), the description is insufficiently complete. It covers only prompt and mask, leaving many configuration options (quality, background, output format, etc.) unexplained.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% and the description adds no parameter explanation beyond 'prompt' and 'optional mask'. With 14 parameters including enums and nested objects, the agent receives no help understanding their meaning or usage.

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 uses specific verbs 'edit, extend, or compose images' and mentions the key inputs (prompt, optional mask). It clearly indicates the tool's main function, though it does not explicitly distinguish from sibling tool 'edit_image_conversation'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives (e.g., generate_image). Does not mention prerequisites, exclusions, or appropriate contexts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

edit_image_conversationB

Multi-turn iterative image editing via the Responses API (stateful by previous_response_id).

ParametersJSON Schema
NameRequiredDescriptionDefault
modelNo
actionNo
outputNo
promptYes
partial_imagesNo
input_image_maskNo
previous_response_idNo

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description reveals statefulness via previous_response_id, a key behavioral trait, and implies iterative dependency. However, it does not discuss other behaviors like error states, side effects, or the meaning of the action enum, which are left uncovered.

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?

The description is a single concise sentence with no wasted words, effectively front-loading the key differentiator. It could be slightly expanded to include parameter hints without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (7 parameters, nested objects, no output schema), the description is too brief. It omits information about return values, parameter interactions, and usage patterns beyond statefulness, leaving the agent underinformed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage and 7 parameters, the description adds meaning only for previous_response_id by explaining its role in statefulness. Other parameters like partial_images, input_image_mask, and output remain undefined, failing to compensate for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'Multi-turn iterative image editing', clearly distinguishing from sibling tools like edit_image (likely single-turn) and generate_image. The mention of 'stateful by previous_response_id' further clarifies the specific use case.

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?

The description implies usage for multi-turn editing through statefulness but does not explicitly contrast with alternatives like edit_image or provide conditions for when not to use this tool. No exclusions or guidance on prerequisites are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

generate_imageC

Generate image(s) from a text prompt using OpenAI gpt-image models.

ParametersJSON Schema
NameRequiredDescriptionDefault
nNo
sizeNo
modelNo
outputNo
promptYes
confirmNo
qualityNo
backgroundNo
moderationNo
output_formatNo
output_compressionNo

TDQS

C2.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description indicates a generative, non-destructive behavior, but lacks details on output format, potential costs, rate limits, or safety mechanisms. Without annotations, more behavioral context would be helpful.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise but lacks structure. It could benefit from brief parameter explanations or usage examples without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (11 parameters, nested objects, no output schema, no annotations), the description is severely incomplete. It does not address return values, configuration options, or any operational context needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description provides no explanation of any parameter (e.g., size, n, output_format). The agent receives no semantic help beyond the schema names and types, which is insufficient for an 11-parameter tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Generate image(s)') and the resource ('from a text prompt'), and identifies the specific model family ('OpenAI gpt-image models'). It differentiates from siblings like 'edit_image' by focusing on generation from scratch.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus its siblings (e.g., edit_image, image_capabilities). The description does not specify prerequisites or context where this tool is preferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

image_capabilitiesA

Discover available models, allowed params, size/quality limits, pricing as-of date, and defaults.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It clearly states what information the tool returns (models, params, limits, pricing, defaults), and 'Discover' implies a non-mutating operation.

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?

A single sentence that fully conveys the tool's purpose without any redundant or missing words. Every piece of information earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no parameters, the description sufficiently lists all the information the agent can expect: models, parameters, limits, pricing, and defaults. It is complete for an introspection tool.

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?

There are no parameters, so the schema coverage is trivially 100%. The description adds no param info, which is appropriate given zero parameters (baseline 4).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'Discover' and lists the exact resources (models, allowed params, size/quality limits, pricing, defaults). It clearly distinguishes from sibling tools which are image editing/generation actions.

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?

The description implies using this tool to understand capabilities before using siblings, but does not explicitly state when to use it versus alternatives or provide any exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.3/5.0
Disambiguation5/5

Each tool targets a distinct image operation: single edit, multi-turn edit, generation from text, and capability discovery. There is no overlap in purpose.

Naming Consistency3/5

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.

Tool Count5/5

Four tools cover essential image operations without excess. The scope is well-defined for a focused MCP server.

Completeness4/5

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

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aleslanger/OpenAI-image-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server