gpt-image-mcp
Provides tools for generating and editing images using OpenAI's image API, including listing available models, generating images from prompts, editing images with masks, composing edited regions onto a base image, and creating elliptical masks.
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., "@gpt-image-mcp Generate a base image, then create mouth and eye variations for lip-sync and compose them."
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.
gpt-image-mcp
OpenAI の画像生成/編集を MCP ツールとして出すサーバ。 同じキャラクターの差分絵(口の形・目の開閉)を作る用途を主目的にしている。
なぜ単なるAPIラッパーではないか
/v1/images/edits は、マスクを渡しても画像全体を再生成する。
実測(2026-08-12・gpt-image-2・1024x1024):
マスク内で変化 | マスク外で変化 | マスク外の最大差分 | |
口を「あ」に編集 | 7,184px (35.8%) | 9,425px (0.92%) | 220 |
口を「い」に編集 | 1,498px (7.5%) | 7,431px (0.72%) | 216 |
最大差分220は「ほぼ別の色」。編集結果をそのまま動画のコマに使うと、口が変わるたびに髪や輪郭も動く—— 30fps で切り替えると顔が揺れる。
このサーバは対処を同梱している。編集結果は「口の形の参考」として扱い、土台は1枚に固定して、
マスク領域だけをローカルで貼り直す(compose_region)。土台はビット単位で保たれる。
マスク外の最大差分 | |
編集結果をそのまま使う | 220 |
単純にぼかして合成 | 55(ぼけがマスク外へ滲む) |
| 10(知覚不能) |
Related MCP server: Nano-Banana MCP Server
ツール
ツール | 課金 | 何をするか |
| なし | このキーで使える画像モデルを列挙。キーが生きているかの確認にも使う |
| あり | プロンプトから生成し、ファイルに保存してパスを返す |
| あり | マスク指定で編集。そのままコマに使わないこと(上記) |
| なし | 編集結果のマスク領域だけを土台へ貼る。土台の汚れを自動検証する |
| なし | 楕円マスクを作る(比率指定) |
画像は base64 で返さずファイルに書いてパスを返す。会話の文脈を食い潰さないため。
APIキーの扱い
このサーバはキーを保持しない。 呼ぶたびに、次の順で解決する。
環境変数
OPENAI_API_KEYmacOS Keychain(
OPENAI_KEYCHAIN_SERVICEにサービス名を設定した場合)
エラー本文にキーが混ざった場合は [REDACTED] に置換してから返す。
Keychain へ入れる場合(コマンド履歴にキーを残さない形):
printf 'key: '; stty -echo; read -r K; stty echo; echo
security add-generic-password -a "$USER" -s openai-image -U -w "$K"; unset K⚠
securityの対話入力(-wを引数なしで最後に置く形)は128文字で切り捨てる。sk-proj-形式のキーは164文字あるため、上の「値として渡す」形を使うこと。
設定
.mcp.json / Claude Code の MCP 設定に追加する。
{
"mcpServers": {
"gpt-image": {
"command": "node",
"args": ["/path/to/gpt-image-mcp/src/index.mjs"],
"env": { "OPENAI_KEYCHAIN_SERVICE": "openai-image" }
}
}
}必要なもの
Node.js 18+(
fetch/FormDataを使う)Python 3 + Pillow(
compose_region/make_mask)。numpyがあれば土台の汚れを自動検証する
npm install
pip install Pillow numpyアバターの作り方(この構成での標準手順)
generate_imageで土台を1枚作る。背景は単色、影とグラデーションを禁止、正面向き、口は閉じ目は開くmake_maskで口の領域(目安0.40 / 0.455 / 0.60 / 0.575)と目の領域(0.34 / 0.32 / 0.66 / 0.42)のマスクを作るedit_imageで口の形(あいうえお)と閉じた目を作るcompose_regionで全部を土台へ貼り直す ← ここを飛ばすと顔が揺れる口の形は母音ごとに1枚。日本語の口パクは
a i u e o+ 閉じ口の6枚で足りる
⚠ 「い」のように変化が小さい口の形は生成が弱い(実測でマスク内の変化が7.5%しか出ず、 マスク外のほうが動いた)。プロンプトを形で具体的に指示するか、その口だけ手で描くほうが早い。
生成物の権利
生成画像を販売物に使う場合、「動画に使ってよい」と「販売する教材に使ってよい」が 別条項のことがある。使う前に、使うキーのアカウントの利用規約を確認すること。 借りたキーで作った素材を自社商品に使わない。
ライセンス
MIT
Available Tools
5 toolscompose_region編集結果のマスク領域だけを土台へ貼るA
edit_image の結果からマスク領域だけを切り出し、土台画像へ合成する。土台はビット単位で保たれるので、口の形や目の開閉を差し替えても顔が動かない。アバターの差分絵を作るなら必ずこれを通す。境界のぼかしは内側にだけ入る(単純にぼかすとマスクの外へ滲んで土台を汚すため)。numpy があれば土台の汚れを自動検証する。
Inputs: out_path (required), src_path (required), base_path (required), mask_path (required), +1 more.
edit_image画像を編集する(マスク指定可)A
既存画像を編集する。mask_path を渡すと、透明の画素だけが編集対象になる。 ⚠ 実測(2026-08-12):マスクを渡しても画像全体が再生成される。マスク外の画素が0.7〜0.9%変化し、最大差分は220(ほぼ別の色)だった。同じキャラクターの差分絵(口の形・目の開閉)を作る用途では、この結果をそのままコマに使わないこと——30fpsで切り替えると顔が揺れる。compose_region で土台へ貼り直すこと。
Inputs: prompt (required), out_path (required), image_path (required), size, +2 more.
generate_image画像を生成するA
プロンプトから画像を生成し、ファイルに保存してパスを返す(base64は返さない)。アバターの土台を作る用途では、背景を単色に・影とグラデーションを禁止・正面向きと明示すると後段の合成が楽になる。
Inputs: prompt (required), out_path (required), size, model.
list_image_models画像モデルの一覧A
このAPIキーで使える画像生成モデルを列挙する。課金されない。キーが生きているかの確認にも使う(借りたキーはプロジェクト側で機能制限されていることがあるため、モデル名を推測せず必ずこれで確認する)。
Inputs: no named parameters.
make_mask楕円マスクを作るA
編集したい領域(口・目など)を楕円で指定したマスクPNGを作る。座標は画像サイズに対する比率(0〜1)で渡す。例: 口 = left 0.40 / top 0.455 / right 0.60 / bottom 0.575、目 = 0.34 / 0.32 / 0.66 / 0.42。
Inputs: top (required), left (required), right (required), bottom (required), +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a distinct role: generation, editing, region compositing, mask creation, and model listing. The only potential ambiguity is between edit_image and compose_region, but the descriptions clarify that compose_region is specifically for splicing edited regions onto a base image, while edit_image performs the actual editing.
The tools mostly follow a verb_noun pattern (generate_image, edit_image, compose_region, make_mask, list_image_models). compose_region and make_mask use slightly different verb forms (compose/make vs generate/edit/list) but the pattern is still clear and predictable overall.
With 5 tools, the server is well-scoped for image generation and editing workflows. Each tool addresses a necessary step in the primary use case of creating avatar variations, and there is no redundancy or excess.
The server covers the core pipeline: model listing, generation, editing, mask creation, and compositing. A minor gap is the lack of an explicit tool for reading image metadata or saving intermediate results, but agents can work around this using file paths returned by the tools.
Maintenance
Related MCP Connectors
MCP server for Qwen Image 3 AI image generation
MCP server for OpenAI Sora AI video generation
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
MCP server for Flux AI image generation
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP tool server that enables generating and editing images through OpenAI's image models, supporting text-to-image generation and advanced image editing (inpainting, outpainting) across various MCP-compatible clients.119MIT
- AlicenseAqualityDmaintenanceAn MCP server that provides AI image generation and editing capabilities using Google's Gemini 2.5 Flash Image API. It allows users to create new images from text, modify existing files, and perform iterative edits through natural language prompts.6MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that wraps OpenAI's image generation and editing APIs, enabling text-to-image and image-to-image operations via tools.292 npm37ISC
- AlicenseAqualityCmaintenanceAn MCP server that generates and edits images using OpenAI's GPT Image model, allowing users to create images from text descriptions and edit existing images through natural language.120 npmMIT