Codex / OpenAI Image

io.github.meet30997由 GitHub 账号 meet30997 发布v0.1.2更新于 Oct 30, 2026

Generate, edit and make matching sets of images with the Codex CLI or the OpenAI Images API

已验证STDIO仅桌面媒体与设计AI 与机器学习

概览

AI 生成的概览

本地 MCP 服务器,让助手通过 Codex CLI 或 OpenAI Images API 生成、编辑图片,并制作风格统一的成套图片。

可以做什么
  • 按提示词生成图片,可指定尺寸、变体数量、透明背景和风格参考图
  • 按提示词编辑已有图片,支持蒙版和辅助参考图,原图不会被修改
  • 一次调用生成多张共享同一风格的命名图片,保存到指定文件夹
  • 返回保存路径和缩略预览,便于助手查看结果后继续调整
  • 为每张图片写入记录提示词和设置的 JSON 附属文件
适用场景
适合在对话中让助手创建或修改图片,例如博客头图、应用图标、贴纸套装,或把照片改成夜景之类的编辑,并在迭代前先看到结果。
运行要求
需要 Node.js 20.3 或更高版本,通过 npx 在本地运行。用 IMAGEGEN_PROVIDER 选择后端:codex-cli 需已登录的 Codex CLI 和含图像生成的 ChatGPT 套餐;openai-api 需 OPENAI_API_KEY;mock 无需任何条件。可选设置包括 IMAGEGEN_OUT_DIR、IMAGEGEN_READ_ROOT、IMAGEGEN_OPENAI_MODEL 和 IMAGEGEN_TIMEOUT_SEC。
安装前请注意
openai-api 后端按图计费并需要 OPENAI_API_KEY;codex-cli 后端会消耗 ChatGPT 套餐用量,脚本化使用前应核对 OpenAI 条款。服务器会在输出文件夹中写入新图片和附属文件(不覆盖已有文件),并从配置的根目录读取输入图片。生成内容为 AI 输出,需自行遵守平台规则,且不得模仿真实人物或品牌。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Codex / OpenAI Image,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

codex-openai-image-mcp

[codex-openai-image-mcp: generate, edit and make matching image sets from any MCP client. Works with Codex CLI or an OpenAI API key.]

[npm version] [Codex / OpenAI Image MCP on mcprush]

An MCP server that lets Claude (and any other MCP client) generate images, edit them, and make matching sets, then look at the result and keep going.

It works with two image backends:

  • Codex CLI: uses the ChatGPT plan you already have through the Codex CLI. No API key, no per-image bill.
  • OpenAI Images API: uses an OPENAI_API_KEY, for people without Codex.

Not affiliated with or endorsed by OpenAI. "OpenAI" and "Codex" are trademarks of OpenAI.

A matching set in one call: "cute flat stickers: coffee, cactus, moon"
[Three pastel stickers in one consistent style: a coffee cup, a potted cactus and a sleepy moon]

Both examples are real, unretouched output from the Codex backend.

What makes it different

  • Matching sets. generate_set makes several different images that share one style, each saved under its own name.
  • Two backends, one interface. Switch between Codex and the OpenAI API with one setting.
  • Made for an agent loop. Every call returns small previews that Claude can see, reports progress during long runs, can be cancelled, and writes a .json sidecar with the prompt and settings next to each image.
  • Careful with your files. It writes only inside its output folder, never overwrites an existing file, never changes the image you edit, and runs Codex read-only in an empty temporary folder.

Quick start

You need Node.js 20.3 or newer, plus one of:

  • the Codex CLI, signed in (codex login) with a ChatGPT plan that includes Codex image generation, or
  • an OpenAI API key with credits.

Claude Code

sh
# Codex backend (your ChatGPT plan)claude mcp add images -e IMAGEGEN_PROVIDER=codex-cli -- npx -y codex-openai-image-mcp
# or the OpenAI APIclaude mcp add images -e IMAGEGEN_PROVIDER=openai-api -e OPENAI_API_KEY=sk-... -- npx -y codex-openai-image-mcp

Claude Desktop, Cursor and other clients

Add this to the client's MCP config (for Claude Desktop, claude_desktop_config.json):

json
{  "mcpServers": {    "images": {      "command": "npx",      "args": ["-y", "codex-openai-image-mcp"],      "env": { "IMAGEGEN_PROVIDER": "codex-cli" }    }  }}

For the API backend use "IMAGEGEN_PROVIDER": "openai-api" and add "OPENAI_API_KEY".

Then just ask:

  • "Make a watercolour fox for my blog header, 1536x864."
  • "Edit photo.png so it looks like a sunset."
  • "Make 5 matching app icons: home, search, profile, settings, bell."

Images are saved in ./generated-images in the folder the client was started from.

Tools

generate_image

InputDefaultNotes
promptrequired
size1024x1024Any WxH from 16 to 4096 px per side
count11–4 variants, saved as -v1, -v2, …
transparentfalseAsks for a transparent background; the result says if the output has none
references[]Up to 4 images whose style to match
out_nameslug of the promptPath inside the output folder, without extension, e.g. icons/rocket

edit_image

InputDefaultNotes
imagerequiredThe image to change. It is never modified
promptrequiredThe change, e.g. "remove the person on the left", "make it watercolour"
sizethe input's sizeWxH
masknonePNG whose transparent areas mark where to edit (OpenAI API only)
count11–4 variants
transparentfalsee.g. for cutouts
references[]Up to 3 supporting images: something to insert, or a style to apply
out_name<input name>-edited

generate_set

InputDefaultNotes
stylerequiredWhat every image shares: medium, palette, rendering, background
itemsrequired1–8 { name, prompt }; each is saved as <folder>/<name>.png
size1024x1024Same for every image
transparentfalse
references[]Up to 4 images whose style the whole set matches
folderslug of styleFolder inside the output folder

All tools crop and resize the result to exactly the size you ask for, and return the saved paths with a 512 px preview of each image.

Backends

codex-cliopenai-apimock
NeedsCodex CLI, signed inOPENAI_API_KEYnothing
Costyour ChatGPT plan's usageper imagefree
Speed~30–60 s per imagedepends on model and sizeinstant
References, edits, transparencyyesyesedits only
Edit masksnoyesno
Setsone Codex session for the whole setone image at a time, first image used as a style referenceone at a time

mock draws placeholder images, for trying the server out and for tests.

Codex backend. Each call runs codex exec --json --skip-git-repo-check --sandbox read-only --cd <empty temp folder> [--image=<file>…] -- - with a prompt that asks Codex to call its built-in image_gen tool and nothing else. The server reads the session id from Codex's JSON events and collects the images from $CODEX_HOME/generated_images/<session id>/. Codex never gets write access or sees your project beyond the images you pass it. Cancelling the request, or hitting the timeout, stops Codex. Check OpenAI's terms for scripted use of the Codex CLI with your plan.

OpenAI backend. Uses the official openai SDK. The default model is gpt-image-2.5-sunburst; set IMAGEGEN_OPENAI_MODEL=gpt-image-2.5-flare for faster results. Sizes are rounded to ones the API accepts, then resized to yours. This backend is covered by automated tests against a mocked client; it has not yet had a full live test.

Settings

VariableDefault
IMAGEGEN_PROVIDERmock; set codex-cli or openai-api
OPENAI_API_KEYrequired for openai-api
IMAGEGEN_OPENAI_MODELgpt-image-2.5-sunburst
IMAGEGEN_CODEX_BINcodex
IMAGEGEN_OUT_DIRgenerated-images, relative to the working folder
IMAGEGEN_READ_ROOTthe working folder; input images must be inside it
IMAGEGEN_TIMEOUT_SEC300, per image asked for
IMAGEGEN_MAX_PER_CALL8 images
IMAGEGEN_PREVIEW_SIZE512 px

Files and safety

  • Output is written only inside IMAGEGEN_OUT_DIR. Absolute paths, .. and symlinks that lead outside are rejected.
  • Input images (to edit, or as references) must be inside IMAGEGEN_READ_ROOT.
  • Existing files are never overwritten: a new file gets -2, -3, … instead.
  • Each image gets a <name>.json sidecar with the prompt, backend, model, size, inputs and time.
  • API keys are read from the environment only and never logged or written to sidecars.
  • IMAGEGEN_MAX_PER_CALL caps how many images one call can make.

Images are AI-generated. You are responsible for how you use them, including platform rules on AI-generated content, and for not imitating real people or brands.

Development

sh
git clone https://github.com/meet30997/codex-openai-image-mcp.gitcd codex-openai-image-mcpnpm installnpm run buildnpm test          # unit and end-to-end tests; no network or API key needednpm run inspect   # try the tools in the MCP Inspector

To run a local build from Claude Code:

sh
claude mcp add images -e IMAGEGEN_PROVIDER=codex-cli -- node /path/to/codex-openai-image-mcp/dist/index.js

The tests run the Codex backend against a stand-in script (test/fixtures/fake-codex.mjs) and the OpenAI backend against a fake client, so they are free and quick. PLAN.md has the design notes and roadmap. Issues and pull requests are welcome.

License

MIT

来源:README.md,提交 ec83524

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.2最新Oct 29, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分