codex-image-gen++
Use this local MCP server to connect Codex to an OpenAI-compatible image API for model discovery, image generation/editing, and job polling while saving outputs locally.
list_models: list provider-visible model IDs, optionally filtered by substring; does not generate images or prove generation permission.generate_image: submit one paid image-generation request using requiredmodel,prompt, and absoluteoutput_path; optionalsize,quality,background, andn(1–4).edit_image: edit 1–16 local reference images with optional mask via multipart Images Edits API; preserves originals.Save results locally as PNG, JPG/JPEG, or WebP; existing files are never overwritten, and
n>1appends-1,-2, etc.get_job: poll an existing job by ID, optionally waiting up to 20 seconds; never submits or retries another request.Return paths and metadata such as dimensions, bytes, SHA-256, and whether requested size matched, instead of Base64 blobs.
Long jobs run in a detached local worker and can survive MCP disconnects while the worker stays alive.
Provides tools for interacting with an OpenAI-compatible Images API, enabling model listing, image generation from prompts, image editing with reference images and optional masks, and job status retrieval via OpenAI-style endpoints.
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., "@codex-image-gen++ list the image models, then make a square watercolor fox and save it to output/imagegen/fox.png"
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.
codex-image-gen++
中文 · English
A small, local MCP server that connects Codex to your own OpenAI-compatible Image API. Configure the provider once; let Codex choose the model, prompt, parameters and workspace output filename for each task.
Windows · macOS · Linux | 中文 / English setup | MIT
Install
Requires Node.js 22.13 or newer (Node.js 24 LTS recommended), npm, and the Codex CLI. The desktop app can use the registered stdio MCP too. Install the CLI if you want automatic registration.
Install the built package from GitHub Releases:
npm install -g https://github.com/Anti2077/codex-image-gen-plus-plus/releases/latest/download/codex-image-gen-plus-plus.tgz
codex-image-gen-plus-plus initThe npm package registry is not required. The display name is codex-image-gen++; the repository, executable and MCP entry use codex-image-gen-plus-plus for naming compatibility.
Or build from source (Git required):
git clone https://github.com/Anti2077/codex-image-gen-plus-plus.git
cd codex-image-gen-plus-plus
npm ci
npm run build
npm link
codex-image-gen-plus-plus initKeep the source directory if installing with npm link. Registration uses absolute Node and CLI paths; rerun init if you move the installation or replace Node.
Related MCP server: image-gen-mcp
Setup
Choose 中文 / English.
Choose Import from CC Switch or enter an API base URL and hidden key manually. A root URL such as
https://api.example.combecomeshttps://api.example.com/v1; a custom path such as/gateway/v1is preserved.Fetch
/modelsto check connection and authentication. This step does not generate an image or incur image-generation charges. The provider may charge for API requests under its own policy.Choose whether to register with Codex. Setup invokes the official
codex mcp addcommand and updates the entry with this name. If Codex cannot be found, it prints a manual TOML entry.Copy the supplied paragraph into your Codex personalization instructions to prefer this MCP for images. Setup does not edit those instructions automatically.
Restart Codex or open a new chat after registration. No model or output directory is fixed in configuration.
Import the current CC Switch provider
Choose this option in init and accept the default ~/.cc-switch data directory, or enter your custom CC Switch directory. CODEX_IMAGE_GEN_CCS_DIR can override that default. The importer reads settings.json and opens cc-switch.db read-only. The local currentProviderCodex selection takes priority; if missing/stale, a single database is_current Codex provider is used. It parses only the selected provider's settings_config, using the active TOML model-provider table for the base URL and its API key configuration. It does not guess another table or select the first saved provider.
The key is imported without displaying it, then the normal /models connection check runs. This is a one-time copy into this tool's own private config: later CC Switch changes do not automatically switch your image provider. Rerun init to import again. No CC Switch files are changed. API-key providers are supported; ChatGPT OAuth tokens and proxy placeholder keys are not imported. If import fails, setup offers manual entry. Older JSON-only CC Switch databases are not supported. Node.js 22 may print its built-in SQLite experimental notice during import.
Example request to Codex:
Use codex-image-gen++ to list the available image models, choose one, and create a square watercolor fox illustration. Save it in this workspace's output/imagegen/ directory and show the result.
Codex should call list_models and pass the exact model ID. Provider-visible model IDs and name hints do not establish generation permission, pricing, quality or speed. Names such as flare and sunburst are passed through without assumed rankings or aliases.
MCP tools
Tool | Purpose |
| Fetch visible model IDs, with an optional substring filter and image-name hints. |
| Submit a generation request and save the result to an absolute local filename. |
| Submit local reference images and an optional mask as multipart data. |
| Retrieve an existing job; optionally wait up to 20 seconds. Never submits another request. |
Generation/edit arguments: model, prompt, output_path; optional size, quality, background, n (1–4). Edits also take input_paths (1–16) and optional mask_path. Provider limits may be lower.
Output extension .png, .jpg / .jpeg, or .webp sets output_format. Existing files are never overwritten. With n: 2 and output_path: /absolute/workspace/output/imagegen/fox.png, files are fox-1.png and fox-2.png. Output reports measured dimensions, bytes, SHA-256, and whether a requested explicit size matches. Dimensions come from image headers, not a complete image-decoding check; Codex should inspect the saved image.
Use absolute paths inside the current workspace. The MCP process's working directory may differ from the chat's workspace. Codex chooses the destination and the server writes the bytes directly, returning paths and metadata instead of large Base64 blobs. This local MCP has the filesystem permissions of the account running it. Optional workspace protection enforces an output root; it does not restrict reference-image reads or isolate the entire process. It rejects existing symlink/junction escapes, but does not replace an OS sandbox against another process concurrently replacing directories.
Long requests and failures
Images run in a detached local Node worker. The initial tool call waits up to 15 seconds, then returns a job ID if still pending, keeping ordinary MCP calls below the default timeout. Use get_job rather than submitting again. Jobs continue through an MCP disconnect while the worker and computer remain running.
No automatic request retries, model fallback, or protocol guessing. A network timeout may occur after the provider accepted a paid request; inspect the job, output files and provider logs before deciding to submit again. Failed jobs include a code, outcome_unknown, provider request ID when available, and any successfully saved partial files. A worker interrupted by shutdown/crash is reported as interrupted; it is not resumed automatically. A hard worker crash can leave empty reserved files that need manual inspection/removal.
Provider compatibility
The initial implementation supports the OpenAI-compatible Images API:
GET {baseUrl}/modelsPOST {baseUrl}/images/generationswith JSONPOST {baseUrl}/images/editswith multipart (imagefor one input,image[]for multiple inputs)data[].b64_json,data[].url, ordata[].image_urlstring responses
It is not a universal adapter for every image provider. APIs requiring Responses-only tools, custom job/polling endpoints, OAuth, or proprietary request bodies need a future adapter. Providers must support output_format or return an image format that matches the requested extension. Optional size/quality fields are sent only when supplied; quality values are not limited to an old fixed model list.
API URLs require HTTPS, with HTTP allowed for loopback development. API authentication never follows redirects. Returned image URLs may contain signed queries and follow up to five redirects, without forwarding your provider API key. Response limits are 50 MiB per image and 192 MiB per generation JSON response.
Configuration and privacy
System | Default config file |
Windows |
|
macOS |
|
Linux |
|
During init, choose the private config file (the compatibility default) or the system credential store (macOS Keychain, Windows Credential Manager, or Linux Secret Service). In system-store mode, the config file keeps only the credential mode and provider settings. The MCP process caches the key, and a detached worker receives it through a one-time private pipe, so each image does not require a new credential-store lookup. The OS may still ask for access on a new MCP process, locked store, or changed application identity; this tool does not bypass OS authentication. Linux requires an unlocked Secret Service session; no volatile kernel-keyring fallback is used. If the credential store is unavailable, init can use the private config-file compatibility mode. POSIX directories/files use modes 700/600; Windows uses inherited user-directory ACLs. Keep the config file private when using compatibility mode.
Optional environment overrides: CODEX_IMAGE_GEN_CONFIG (absolute config path recommended), CODEX_IMAGE_GEN_BASE_URL, CODEX_IMAGE_GEN_API_KEY. Do not put keys in terminal command arguments, source control, or chat. The default provider timeout is 600 seconds; timeoutSeconds in config accepts 1–3600.
init can also enable workspace protection and store an existing absolute workspace root. With protection enabled, output files must stay inside that root and symlink/junction escapes in output directories are rejected. Without it, Codex is still instructed to use absolute paths in the current workspace, but the server permits other absolute paths.
Jobs are stored beside config under jobs/, containing prompts, input/output paths, status and metadata, without copying the API key. On MCP startup, completed/failed records older than 7 days are removed automatically. Set jobRetentionDays to 0 in config to disable automatic cleanup, or set 1–3650 days. Running/queued, malformed, and unrecognized records are retained; images are never removed. Images and prompts are sent to your configured provider; signed result URLs are fetched locally. This project has no analytics endpoint.
Commands
codex-image-gen-plus-plus init
codex-image-gen-plus-plus models image
codex-image-gen-plus-plus doctor
codex-image-gen-plus-plus instructions zh-CN
codex-image-gen-plus-plus instructions en
codex-image-gen-plus-plus job <job-id>doctor checks /models, not a paid generation. Rerun init to change the provider or key. On PowerShell, if script execution policy prevents npm command shims, use codex-image-gen-plus-plus.cmd init instead.
To disconnect, run codex mcp remove codex-image-gen-plus-plus. For file storage, remove the config/jobs directory separately to delete the key and history. For system storage, remove the codex-image-gen-plus-plus credential in your OS credential manager too. Moving the config file changes its credential reference; rerun init after moving it. Uninstall a global package with npm uninstall -g codex-image-gen-plus-plus.
Clean old job records without deleting generated images:
codex-image-gen-plus-plus jobs clean # completed/failed records older than 7 days
codex-image-gen-plus-plus jobs clean --days 30 --dry-run # preview eligible records
codex-image-gen-plus-plus jobs clean --days 30 # delete recordsDevelopment
npm ci
npm run check
npm run build
npm packCI builds and checks the CLI/package on Windows, macOS and Linux with Node.js 22 and 24. This does not establish compatibility with every third-party provider. Real generation consumes your provider credits and is not part of setup or CI.
Acknowledgements
See THIRD_PARTY_NOTICES.md for related open-source projects and the official MCP SDK. Original implementation; MIT licensed.
Available Tools
4 toolsedit_imageA
Edit local images using the provider multipart Images Edits API. Saves to a new absolute path; preserves originals. Optional mask follows provider semantics. Poll returned job ID with get_job.
Inputs: model (required), prompt (required), input_paths (required), output_path (required), +5 more.
generate_imageA
Submit one paid image-generation request and save bytes locally. Returns paths/metadata or a job ID to poll with get_job. Never automatically resubmit after timeout/failure. Existing files are protected.
Inputs: model (required), prompt (required), output_path (required), n, +3 more.
get_jobARead-only
Query an existing image job without submitting or retrying. Jobs survive MCP disconnects while the local worker is alive. On interrupted/unknown outcome, inspect output paths/provider logs before considering another paid request.
Inputs: job_id (required), wait_seconds.
list_modelsARead-only
List models visible to the configured provider API key. Does not generate images or prove generation permission. image_candidate is only a name heuristic.
Inputs: filter.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct purpose: list_models (discovery), generate_image (create), edit_image (modify), and get_job (poll). The descriptions explicitly disambiguate similar-sounding operations, e.g. generate_image vs. get_job and the warning that list_models doesn't prove generation permission.
All four tools follow a consistent verb_noun snake_case pattern (list_models, generate_image, edit_image, get_job). No mixing of conventions or vague verbs.
Four tools is a tight, well-scoped set for an image generation/editing server, with each tool earning its place. It's slightly lean, as there's no cancel or list-jobs operation.
The core lifecycle is covered: discover models, generate, poll job status, and edit images. Minor gaps remain around job management (no cancel_job or list_jobs), but agents can work around them.
Maintenance
Related MCP Connectors
Image infrastructure for agents. Upload, transform, and deliver images through MCP, CLI, or API.
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. Up to 4 images per call, SVG vectorization, background removal, upscaling and image-to-video. Remote MCP with OAuth, no API keys.
Create AI images and videos, manage projects and credits, and use workspace campaign context.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables generating images through SmartAPI's image generation endpoint directly from Codex, saving files locally.1MIT
- AlicenseAqualityCmaintenanceEnables generating and editing images through OpenAI image models, with configurable output as saved files or returned URLs.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables image generation through any OpenAI-compatible images/generations endpoint, saving results to disk and returning them inline for the model.MIT
- AlicenseNot gradedqualityBmaintenanceEnables Codex to generate finite image batches using its built-in image tool, managing jobs, saving outputs, and supporting pause/resume.MIT