GPT Image 2 MCP Server
Enables image generation and editing using OpenAI's GPT Image 2 model within a Claude Desktop Code project workspace, with security boundaries and no-overwrite file handling.
README
GPT Image 2 plugin for Claude Desktop Code
Generate and edit project images with OpenAI GPT Image 2 through a bundled local MCP server. The plugin writes one validated image per paid call, keeps files inside an approved project workspace, and never overwrites an existing destination.
Supported Claude surface
This plugin is for Claude Desktop Code, the project-oriented Code experience in the Claude Desktop application. Claude Desktop Chat is not supported. It is not an MCPB package and is not a remote MCP service.
Install through the Claude Desktop Code GUI
GUI plugin installation is the primary path:
- Open the target project in Claude Desktop Code.
- Open the GUI Settings → Plugins area. Labels may vary slightly by Claude release.
- Add this repository root as a local marketplace or select its repository source, then install
gpt-image-2@kpk-plugins. - Enable the installed plugin for the current project. Enablement is project-specific; installing it does not grant access to every project automatically.
- Open the plugin settings for configuration. Do not copy
.mcp.jsoninto ordinary settings.
The plugin root is the marketplace root, and the marketplace entry points to ./.
Runtime requirement
The only runtime dependency is Node.js 20+, available on the PATH seen by Claude Desktop Code. The installed plugin starts the prebuilt dist/server.mjs directly. At runtime, the plugin does not run npm, npx, lifecycle scripts, source compilation, or load node_modules.
The committed marketplace copy includes the standalone bundle. An installed-copy test launches only Git-tracked files and verifies that get_status works with no node_modules directory present and without an API key.
npm and development dependencies are needed only by contributors building or testing the source checkout.
Configure in the GUI
In plugin settings, enter the API key in the sensitive OpenAI API key field. Do not put it in a command line, .env, .mcp.json, ordinary settings, a README, a prompt, or a log, and do not ask Claude to display or inspect it.
The default official Base URL is:
https://api.openai.com/v1
A custom Base URL receives the API key, prompts, and edit images sent by this plugin. Configure one only when you trust that endpoint and its operator. A custom endpoint should usually include /v1; the plugin does not append it automatically. The only user-facing documentation example is:
https://api.example.invalid/v1
The URL must be an absolute HTTP(S) URL without credentials, a query, a fragment, control characters, or surrounding whitespace. A compatible endpoint must implement the image API used by the OpenAI client; compatibility is not implied merely by accepting a URL.
HTTP is permitted for trusted local or private-network compatible endpoints, but it sends the API key, prompts, and edit images without transport encryption. Use an http:// Base URL only on a network and endpoint you trust; prefer HTTPS otherwise.
Run /gpt-image-2:setup after installation. The command calls only get_status and makes no provider request.
Tools
get_status
Reports only safe status data: API-key configured boolean, whether a custom Base URL is configured, base_url_valid: true for the active URL of a running server, approved workspace roots, model, server version, and the default relative output directory. An invalid configured Base URL prevents server startup; correct it in plugin settings and reload or restart the plugin. get_status makes zero provider or image API requests and never returns the key or Base URL value.
generate_image
Generates one image with model gpt-image-2, fixed n: 1, and saves one new file. Main inputs are:
promptquality:auto,low,medium, orhighsizeoutput_format:png,jpeg, orwebp- optional JPEG/WebP
output_compressionfrom 0 to 100 moderation:autoorlow- optional relative
output_pathand approvedworkspace_root
edit_image
Edits one to eight edit inputs in the supplied order and saves one new image. Inputs may be PNG, JPEG, or WebP. The limit is 50 MiB per input and 200 MiB aggregate across all edit images plus the optional mask.
An optional mask must be a PNG with an alpha channel, match the first input image's dimensions, and be less than 4 MiB. Transparent output backgrounds are not supported; mask alpha only identifies the edit region.
Formats, sizes, and output
- Output formats: PNG, JPEG, and WebP.
- The tool default size is
1024x1024.autois also accepted. - A custom
WIDTHxHEIGHTmust use multiples of 16, each edge must be at most 3840 pixels, aspect ratio must be between 1:3 and 3:1, and total pixels must be between 655,360 and 8,294,400. - PNG does not use output compression. JPEG and WebP accept compression values from 0 to 100.
- If
output_pathis omitted, output goes under.claude/generated-images/gpt-image-2with a unique prompt-free filename. - Explicit output paths are preserved, must be relative to an approved workspace root, and must use an extension matching the requested format.
- Existing destinations are rejected. No-overwrite publication also prevents concurrent calls from replacing the same target.
Actual dimensions are preserved and reported after the saved image is decoded and validated. If an explicit requested size differs, the file remains saved with its actual dimensions and the result includes SIZE_MISMATCH.
Images at or below 2 MiB include an inline preview. For larger images, the inline preview is omitted; the saved file path remains authoritative. TEMP_CLEANUP_PENDING means the output was saved successfully but cleanup of a temporary publication file is still pending.
Cost, concurrency, and retries
Generation and editing are paid provider operations. The plugin fixes one output per request and permits one paid call at a time in each server process. There are no SDK retries and no application retries, so a failed paid call is not automatically repeated. Confirm prompts, edit inputs, size, format, and output path before invoking an image tool.
Workspace and security boundary
- Outputs stay inside a workspace root approved by Claude Desktop Code. Output paths cannot be absolute or traverse outside the root.
- Contained absolute input paths are accepted only when they already resolve inside an approved root; an input path never grants a new root.
- Input files are copied through stable handles into private temporary snapshots before upload. Originals are not modified.
- Provider output is strictly decoded, image-validated, flushed, and published with no-overwrite semantics.
- Logs accept only bounded status codes and numeric context; prompts, API keys, Base URLs, image data, Base64, and full input paths are excluded.
Windows Node 20 Junction boundary
On Windows under Node 20, existing reparse-point/Junction escapes are rejected, and output parent paths are rechecked immediately before exclusive publication. An active directory replacement by another same-authority process between checks remains outside the threat boundary. A native Win32 handle-relative helper would be required to remove that same-authority replacement race completely.
Troubleshooting
- API key not configured: open Claude Desktop Code plugin settings and populate the sensitive API-key field. Do not paste the key into chat or a shell.
- Invalid or unused custom Base URL: an invalid configured Base URL prevents the server from starting. Correct it in plugin settings, confirm the setting was saved, then reload or restart the plugin. Custom endpoints should usually end in
/v1; no/v1segment is added automatically. - No approved workspace root: open the project in Claude Desktop Code and enable the plugin for that project.
OUTPUT_EXISTS: choose a new relative output path. The plugin will not overwrite.SIZE_MISMATCH: use the returned actual width and height; the saved image is valid.- Preview omitted: open the returned relative or absolute path; inline previews are limited to 2 MiB.
Build and test from source
Development commands may install and use development dependencies; they are not part of installed-plugin runtime behavior. The validation command disables implicit npm lifecycle hooks before checking that the approved script set is exact.
npm ci --ignore-scripts
npm run typecheck
npm test
npm run build
npm run test:dist
npm --ignore-scripts run validate
These checks use local fixtures, fakes, and protocol tests. No paid image request is required. No live provider verification has been performed or claimed.
License
MIT © 2026 KPK. See LICENSE and THIRD_PARTY_NOTICES.md.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。