gpt-image-mcp
An MCP server that enables Claude Code and Claude Desktop to generate and edit images using OpenAI's gpt-image-2 model, with results saved to disk.
README
gpt-image-mcp
A tiny, self-contained MCP server that gives Claude Code and Claude Desktop image generation and editing via OpenAI's gpt-image-2 (and other GPT Image models). Every result is saved to disk and returned inline, so Claude can both wire the file into your project and show you the image.
Two tools:
generate_image— text → image (UI mockups, icons, hero art, diagrams, social graphics). GPT Image renders in-image text well, so describe any text literally.edit_image— image(s) + instruction → image (restyle, composite, inpaint with a mask, outpaint).
This runs locally over stdio. It is for Claude Code and Claude Desktop, which support local servers. It is not a remote connector and will not appear in claude.ai in the browser (that requires a hosted, OAuth-protected server).
Prerequisites
- Python 3.10+
- uv (recommended) or
pip - An OpenAI API key with credits. ⚠️ gpt-image-2 may require Organization Verification on your OpenAI org — without it, calls return HTTP 403. Verify under OpenAI dashboard → Settings → Organization.
Install (do this on each PC after cloning)
git clone <your-repo-url> gpt-image-mcp
cd gpt-image-mcp
./install.sh
On Windows (PowerShell), use the equivalent script:
git clone <your-repo-url> gpt-image-mcp
cd gpt-image-mcp
.\install.ps1
# if blocked by execution policy:
# powershell -ExecutionPolicy Bypass -File .\install.ps1
The installer (install.sh / install.ps1) installs the dependencies and then
prints the exact config for both clients with the absolute paths already
filled in for that machine (paths JSON-escaped where needed). Copy what it
prints.
Tip: paths differ per machine, so re-run
./install.shon each PC rather than copying a config file between them.
Configure Claude Code
Export your key, then run the command install.sh printed (it looks like this):
export OPENAI_API_KEY=sk-...
claude mcp add gpt-image --scope user \
-e OPENAI_API_KEY=$OPENAI_API_KEY \
-- uv run --project /abs/path/to/gpt-image-mcp gpt-image-mcp
--scope user makes it available in every project on that machine. Verify with
claude mcp list, or /mcp inside a session.
--project (not --directory) is deliberate: it stops uv from changing
the working directory into the repo, so the server inherits the directory you
launched Claude Code from. With no IMAGE_OUTPUT_DIR set, images then save to
./generated-images inside whatever project you're working in. Want a fixed
location instead? Add -e IMAGE_OUTPUT_DIR="/abs/path" to the command. You can
also override per call with the tool's output_dir argument.
Configure Claude Desktop
Add the block install.sh printed under "mcpServers" in
claude_desktop_config.json, replace the key, and fully quit and relaunch
Desktop.
{
"mcpServers": {
"gpt-image": {
"command": "/absolute/path/to/uv",
"args": ["run", "--project", "/abs/path/to/gpt-image-mcp", "gpt-image-mcp"],
"env": {
"OPENAI_API_KEY": "sk-...",
"IMAGE_OUTPUT_DIR": "/Users/joe/gpt-image-output"
}
}
}
}
Config file location:
| OS | Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
Open it from Desktop via Settings → Developer → Edit Config.
Two gotchas that bite on Desktop specifically:
- Use the absolute path to
uv(or to.venv/bin/gpt-image-mcp). Desktop launches configs with a minimalPATH, so bareuv/npxoften fail even though they work in your terminal. Find it withwhich uv. - Set
IMAGE_OUTPUT_DIRto an absolute path. Desktop's working directory is unpredictable, so without this you may not find your images.
Manual setup (no uv, or Windows)
python3 -m venv .venv
# macOS/Linux:
.venv/bin/pip install -e .
# Windows (PowerShell):
.\.venv\Scripts\pip install -e .
Then point the command at the installed script:
- macOS/Linux:
/abs/path/to/gpt-image-mcp/.venv/bin/gpt-image-mcp - Windows:
C:\abs\path\to\gpt-image-mcp\.venv\Scripts\gpt-image-mcp.exe
(args can be [] since the script is the entry point), and set
OPENAI_API_KEY / IMAGE_OUTPUT_DIR in env.
Usage
Just ask in natural language:
- "Generate a 1536x1024 hero image: a calm modern fintech dashboard, soft gradients, the headline 'Self-Directed IRAs, Simplified' in clean sans-serif."
- "Make three square app icons for a swim-tracking tool — minimalist line art."
- "Edit
./logo.pngto put it on a transparent... " → usemodel="gpt-image-1.5"for transparency (see limitations). - In Claude Code: "Generate a background image and use it in
hero.tsx." — it saves the file into the project and references it for you.
Tool parameters (most useful)
generate_image: prompt, model (default gpt-image-2), size
(1024x1024 | 1536x1024 | 1024x1536 | auto), quality
(low|medium|high|auto), n (1–10), background
(auto|opaque|transparent), output_format (png|jpeg|webp),
output_dir, filename.
edit_image: prompt, images (list of paths), mask (PNG path), plus the
same model/size/quality/n/output_format/output_dir/filename.
Limitations & notes
- No transparent background on gpt-image-2. Passing
background="transparent"to it will error. For alpha (icons/UI assets), passmodel="gpt-image-1.5"or another alpha-capable model. - Cost. GPT Image is token-priced; most generations land roughly
$0.04–$0.35 each depending on size/quality. The tool prints a rough estimate
(rates are hardcoded in
server.pyand may drift — trust your OpenAI dashboard). - Cheap iteration. Use
model="gpt-image-1-mini"to rough things out, then re-render the final withgpt-image-2. - Org verification. A 403 almost always means your OpenAI org isn't verified for GPT Image yet.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。