claude-openai-image-mcp
The claude-openai-image-mcp server provides a generate_image tool that creates images from text prompts using OpenAI's image model or pluggable providers, returning them as MCP-compliant image content.
Generate images from a text prompt (1–2000 characters) using a mock provider, OpenAI's API (
gpt-image-2), or a custom pluggable provider.Customize output via optional
size(e.g.,1024x1024,1536x1024),quality(e.g.,low,medium), andoutput_format(e.g.,png,webp,jpeg) parameters, enforced against server-side allowlists.Receive structured results as base64-encoded image data with MIME type, plus metadata (provider, model, size, quality, output format, request ID).
Test for free using the default mock provider, which runs the full pipeline with no network calls or API costs.
Security-first: the OpenAI API key stays server-side and is never exposed to clients or logs; requests are validated with prompt length limits, allowlist enforcement, timeout handling, concurrency limits, and base64/MIME validation.
Configure via environment variables: set provider, API key, timeout, retries, concurrency, allowed sizes/qualities/formats, and defaults.
Integrate with Claude Code (CLI), Claude Desktop, or any stdio MCP client.
Generates images using OpenAI's image model (gpt-image-2) with configurable size, quality, and output format.
Click on "Install 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., "@claude-openai-image-mcpgenerate a surreal painting of a melting clock in the desert"
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.
claude-openai-image-mcp
A small, security-first MCP server that
generates images with OpenAI's image model (gpt-image-2) and returns them as
MCP image content — usable from Claude Code (CLI), Claude Desktop, and other
stdio MCP clients.
The OpenAI API key is held server-side only. The default provider is a mock that returns a real 1×1 PNG with no network call and no billing, so you can wire up and test the whole flow before spending a cent.
Status: Phase 2 wired — the live OpenAI call (
src/openaiImageClient.ts) is implemented with typed 429/timeout/5xx mapping, and every upstream branch is mock-reproduced in tests. The default provider is still mock; a real paid API call happens only when you explicitly setIMAGE_MCP_PROVIDER=openaiwith anOPENAI_API_KEY. Real-API E2E evidence is still pending. See Roadmap.
Tool
generate_image
Field | Type | Required | Notes |
| string | yes | 1.. |
| string | no | must be in |
| string | no | must be in |
| string | no | must be in |
The server chooses the model; clients never pass a model name. Requests outside the allowlist are rejected before any provider call.
Returns MCP image content { type: "image", data: <base64>, mimeType } plus
schema-validated structuredContent with
{ provider, model, size, quality, requested_output_format, output_format, request_id }.
requested_output_format records the request; output_format describes the
bytes actually returned and always agrees with mimeType.
Related MCP server: io.github.pvliesdonk/image-generation-mcp
Quick start
Requires Node ≥ 22.12 and pnpm.
pnpm install
cp .env.example .env # defaults to the mock provider (no key needed)
pnpm run build
pnpm testRun the server over stdio:
pnpm run dev # tsx src/index.ts
# or, after build:
node dist/index.jsRegister with Claude Code
claude mcp add openai-image -- node /absolute/path/to/dist/index.js(For the mock provider no OPENAI_API_KEY is needed. To use the real API later,
set IMAGE_MCP_PROVIDER=openai and OPENAI_API_KEY in the server's environment.)
Configuration
All configuration is via environment variables (see .env.example).
.env is git-ignored — never commit real secrets.
Variable | Default | Purpose |
|
|
|
| — | Required only when provider is |
|
| Server-owned effective model |
| — | Plugin module specifier (provider |
|
| Reject longer prompts |
|
| Per-request generation timeout (guard-enforced) |
|
| Bounded transient retries (Phase 2) |
|
| Max concurrent generations |
|
| Max decoded image size accepted from any provider |
|
| Allowlist |
|
| Allowlist |
|
| Allowlist |
| first allowed size | Used when the client omits |
| first allowed quality | Used when the client omits |
| first allowed format | Used when the client omits |
Provisional values
quality=low, concurrency=1, retries=0, n=1, and model=gpt-image-2 are
provisional — chosen to bound cost and latency and to be confirmed by
end-to-end evidence. Each carries a review condition in code comments; expect
them to change as we run real E2E tests.
Experimental: pluggable provider lane (detachable)
Besides mock and openai, the server can load an external provider plugin
(e.g. a Codex-CLI-backed lane that generates images inside a ChatGPT
subscription instead of API billing). The core stays API-key-first; the plugin
lane is strictly opt-in and detachable by design:
Activation needs both
IMAGE_MCP_PROVIDER=pluginandIMAGE_MCP_PROVIDER_MODULE=<npm package or path>. Remove both to detach — the core has no build-time dependency on any plugin.A plugin implements the contract exported at
claude-openai-image-mcp/provider(createImageProvider()+providerApiVersion). The server refuses to start on a version mismatch or any load failure (fail-closed).Every provider (plugin or not) runs behind a request-time guard: timeout with abort, strict base64 + magic-byte/MIME validation, decoded-size cap, and redacted error surfacing. A plugin cannot impersonate another lane in
structuredContent.There is no automatic fallback between lanes. If the plugin lane breaks (e.g. an upstream policy change), requests fail with a clear error; switching back to
openaiis a deliberate env change, never implicit billing.Trust model: the plugin runs in-process with the server's full privileges. Only install plugins you wrote or audited, and do not keep
OPENAI_API_KEYin the plugin lane's environment (the server warns if you do). A plugin backend may choose its own model; results report what the plugin actually used (orunknown) — the configured model is advisory there.
A reference implementation lives in
packages/codex-plugin-cc — the ChatGPT-subscription
lane (drives the Codex CLI, no API key). It is a separate, non-core package:
the core never imports it, and a dedicated CI job builds, audits, and tests it
separately so it stays detachable from the core dependency graph.
Security
The OpenAI key is server-side only and never logged, serialized, or returned. Logs are stderr-only, metadata-only, and redacted. See SECURITY.md.
Development
pnpm run lint:ox # fast Rust correctness pass
pnpm run format:check # prettier
pnpm run lint # eslint
pnpm run typecheck # tsc --noEmit
pnpm run build
pnpm test # vitest (no network, no billing)CI runs the same sequence (.github/workflows/node.js.yml) plus CodeQL.
Roadmap
Phase 1 (this repo): scaffold,
generate_image, mock provider, CI. ✅Phase 2: wire
OpenAIImageProviderto the official SDK (allowlist, timeout, bounded retry, 429/Retry-After/timeout/5xx mapping, byte/MIME checks); mock-reproduce every branch. ✅ — implemented; real API E2E still requires explicit approval (billing) and is the remaining checkbox of this phase.Phase 3: Streamable HTTP transport + client→server OAuth (the OpenAI key is never forwarded to clients). Note: there is no official OpenAI OAuth path to call the Images API on a ChatGPT user's behalf — the core stays server-side API key only. Unofficial subscription-backed lanes live as external plugins (see the pluggable provider lane above), at the user's own risk.
License
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- AlicenseAqualityCmaintenanceA minimal MCP server that wraps Google Gemini image generation, enabling users to generate images via a single tool prompt in Claude Code or other MCP hosts, with automatic filename collision handling.1MIT
- AlicenseAqualityAmaintenanceMulti-provider image generation MCP server that enables image generation from Claude Desktop, Claude Code, or any MCP client using OpenAI, Google Gemini, Stable Diffusion, or a placeholder provider.101MIT
- Alicense-qualityCmaintenanceMCP server that enables Claude Code to generate images using Google's Gemini image generation models.MIT
- AlicenseBqualityCmaintenanceA Model Context Protocol server that enables generating, editing, and multi-turn editing of images using OpenAI's gpt-image models directly from Claude or any MCP client.41MIT
Related MCP Connectors
MCP server for Grok Imagine AI video generation
MCP server for Flux AI image generation
MCP server for OpenAI Sora AI video generation
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/theosera/claude_openai_image_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server