image-gen
Enables on-demand image generation using the signed-in ChatGPT/Codex quota through the Codex CLI $imagegen backend, with automatic fallback to Pollinations FLUX if Codex fails.
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., "@image-gen Generate an image of a cozy bookstore on a rainy evening"
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.
image-gen MCP
An MCP server that lets Claude generate images on demand using a ChatGPT plan through Codex CLI, with a free FLUX fallback. It works locally over stdio and can also be hosted over HTTPS as a Claude custom connector.
Primary backend: Codex CLI
$imagegen(uses the signed-in ChatGPT/Codex quota, no API key)Fallback: Pollinations FLUX (free, keyless)
Tools:
generate_image,get_image_job,image_backend_statusZero npm dependencies
Not affiliated with OpenAI, Anthropic, or Tailscale. Use your own account and follow each service's terms.
Requirements
Windows 10/11 (the helper scripts are PowerShell; the server itself is Node.js)
Node.js 18 or newer
A ChatGPT plan that includes Codex image generation
Optional for remote hosting: Tailscale (preferred) or Cloudflare Tunnel
Related MCP server: codex-image
Quick start (local stdio)
npm install -g @openai/codex
codex loginVerify:
codex login statusClone the repo and register the server with Claude Code:
git clone https://github.com/barnikbhai2007/image-gen-mcp.git
cd image-gen-mcp
node install.mjsinstall.mjs writes an image-gen entry to %USERPROFILE%\.claude.json at user scope. Re-run it any time; it backs up the file first and only replaces the image-gen entry.
Start a new Claude Code session and ask:
Generate an image of a cozy bookstore on a rainy evening
Images are saved to %USERPROFILE%\Pictures\Claude Images by default.
Host it as a custom connector
Claude Desktop's Add custom connector dialog needs a public HTTPS MCP URL. This repo can serve Streamable HTTP and publish it through a tunnel.
Option A: Tailscale Funnel (stable URL, recommended)
Install Tailscale and sign in.
Enable Funnel for your tailnet when Tailscale asks (or in the admin console).
Run:
.\start-host.ps1The script starts the HTTP server, enables Funnel on port 8788, and prints a URL like:
https://your-machine.your-tailnet.ts.net/mcp/<secret>The hostname stays the same across restarts. The /mcp/<secret> path is generated once and stored in http-secret.txt, so the full connector URL does not change.
Check the Funnel directly:
tailscale funnel statusOption B: Cloudflare quick tunnel (temporary URL)
If Tailscale is unavailable, start-host.ps1 falls back to a Cloudflare quick tunnel. Download the binary once:
.\get-cloudflared.ps1
.\start-host.ps1Quick tunnels get a new random *.trycloudflare.com hostname whenever they restart. That is fine for testing, but you must re-paste the URL into the connector after a restart.
Add the connector in Claude
+ → Connectors → Add custom connector
Name it
image-gen(or anything you like)Paste the URL from
connector-url.txtAuthentication: No sign-in
Leave request headers empty
Transport: Streamable HTTP
Click Add
The full URL is printed by start-host.ps1 and saved in connector-url.txt.
Tools
generate_image
Argument | Type | Description |
| string, required | Subject, setting, composition, lighting, style, constraints |
| string |
|
| string | Optional base filename; the extension is chosen from the image data |
| string |
|
auto tries Codex first and falls back to FLUX if Codex fails. A call that takes longer than ~50 seconds returns a job_id instead of the image, because Claude Desktop cuts MCP calls at about 60 seconds.
get_image_job
Poll a job returned by generate_image.
Argument | Type | Description |
| string, required | The id returned by |
| number | How long to wait, 1–45 seconds; default 30 |
Jobs expire after 10 minutes.
image_backend_status
Reports the output folder, Codex CLI version, login state, default backend, and fallback status.
Configuration
Environment variables read by server.mjs:
Variable | Default | Purpose |
|
| Path to the Codex executable |
|
| Output folder |
|
| Default backend |
|
| Codex process timeout |
|
| FLUX request timeout |
|
| Time before returning a |
|
| Set to |
|
| HTTP bind address |
|
| HTTP port |
| generated | Override the secret path segment |
You can also start HTTP mode directly:
node server.mjs --httpEndpoints:
POST /mcp/<secret>— MCP JSON-RPCGET /health— health checkDELETE /mcp/<secret>— end an MCP session
The secret is written to http-secret.txt on first run. Treat it like a password.
Autostart on Windows
.\install-autostart.ps1This adds a hidden launcher to the current user's Startup folder, so the server starts at login. Tailscale also starts with Windows. The stable Funnel URL becomes available a few seconds after login.
To stop everything:
.\stop-host.ps1Security notes
The public endpoint is protected by an unguessable
/mcp/<secret>path, not by OAuth.Anyone with the full URL can spend the signed-in user's image quota. Do not share it.
The HTTP server rate-limits requests to 120 per minute per IP.
http-secret.txt,connector-url.txt,host-pids.json, logs, and tunnel binaries are git-ignored. Never commit them.The Cloudflare fallback forwards prompts to Cloudflare and then to the local server. The FLUX fallback sends prompts to Pollinations.
This is a personal tool, not a multi-tenant production service.
Troubleshooting
codex login status says not signed in
codex loginClaude Code doesn't list the server
node install.mjsThen start a new session. In Claude Code, /mcp must be the first thing typed in an empty prompt.
The connector URL stopped working
.\start-host.ps1Then open https://your-machine.your-tailnet.ts.net/health in a browser. If it returns {"ok":true,...}, the server is fine; restart Claude Desktop. If it fails, check that Tailscale is running and signed in, and that Funnel is enabled:
tailscale status
tailscale funnel statusLong generations time out
The job handoff should handle it. If not, increase CODEX_SOFT_WAIT_MS or use get_image_job.
Files
server.mjs— MCP server (stdio + Streamable HTTP)install.mjs— registers the stdio server in~/.claude.jsonstart-host.ps1— starts HTTP mode and publishes it (Tailscale Funnel, then Cloudflare fallback)stop-host.ps1— stops the server and tunnelinstall-autostart.ps1— adds the Windows login autostart entryget-cloudflared.ps1— downloads the Cloudflare Tunnel binarycommands/image.md— optional/imageslash command for Claude Code
License
MIT. See LICENSE.
Available Tools
3 toolsgenerate_imageA
Generate an image from a text prompt and save it to disk. Uses the ChatGPT/Codex plan when signed in, otherwise a free FLUX backend. Returns the image and saved path, or a job_id when generation takes longer than ~50 seconds; in that case call get_image_job with the job_id.
Inputs: prompt (required), size, backend, filename.
get_image_jobA
Retrieve the image from a generate_image call that returned a job_id. Waits up to wait_seconds for the generation to finish.
Inputs: job_id (required), wait_seconds.
image_backend_statusA
Report whether the ChatGPT/Codex image backend is signed in, the free fallback, and the output folder.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct role: generate_image creates, get_image_job polls an async result, and image_backend_status reports configuration. The descriptions explicitly cross-link generate_image's job_id output to get_image_job, so an agent cannot easily misselect.
All names use consistent snake_case, and two follow a verb_noun pattern (generate_image, get_image_job). image_backend_status is a noun-only diagnostic name, a minor deviation from the verb-first convention.
Three tools is well-scoped for a focused image-generation server; the async job model genuinely justifies a separate retrieval tool, and the status tool is small but useful for diagnosing backend auth. No filler tools.
Core flow (generate, poll, check backend) is covered, but the async job lifecycle has dead ends: no way to list pending jobs, cancel a job, or recover a result if the job_id is lost. Configuration of output/size is also not exposed beyond what generate_image infers.
Maintenance
Related MCP Connectors
Generate images and video from Claude with one API key.
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Generate images from Claude, ChatGPT, Cursor and Codex with 12 top AI image models and 10 tools: up to 4 images per call, SVG vectorization, editing and more. Remote MCP with OAuth, no API keys. Pay per image, no subscription.
Generate images from Claude, ChatGPT, Cursor and Codex with 12 top AI image models. Up to 4 images per call, SVG vectorization, background removal, upscaling and image-to-video. Remote MCP with OAuth, no API keys.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceGenerates and edits images through the Codex CLI using an existing ChatGPT subscription, with queued jobs, progress reporting, and artifact URLs for MCP clients.MIT
- AlicenseNot gradedqualityCmaintenanceEnables generating images directly from Claude Code using the ChatGPT subscription's built-in Codex CLI and gpt-image-2, with no API key or separate credits.MIT
- AlicenseNot gradedqualityBmaintenanceEnables Claude Code to generate and edit images with GPT Image by relaying prompts through a local Codex CLI signed in with a ChatGPT plan, saving results to disk and returning them inline with no OpenAI API key required.48 npm1MIT
- AlicenseAqualityCmaintenanceLets Claude Code or any MCP client generate images through the official Codex CLI using an existing ChatGPT plan login, with no API key or separate billing. Supports prompt-driven generation with base and reference images, writing results to a chosen path.1MIT