openai-gpt-image-mcp is a Model Context Protocol (MCP) tool server for interfacing with OpenAI's GPT-4o/gpt-image-1 image generation and editing APIs. Its goal is to make OpenAI's image generation and editing capabilities available to MCP-compatible clients.
Purpose
This tool is intended for scenarios that require image generation or image editing within an MCP client. It declares support for clients including Claude Desktop, Cursor, VSCode, Windsurf, and any MCP-compatible client.
Main Capabilities
It provides two tool capabilities:
- create-image: generates images from prompts, with advanced options such as size, quality, and background. n can be set to generate up to 10 images at once.
- edit-image: edits or extends images using a prompt and an optional mask, supporting both file path and base64 input methods. Providing a mask image (file path or base64) allows control over where the edit is applied.
In addition, it supports file output: generated images can be saved directly to disk or returned as base64.
Usage
This tool is added via configuration to Claude Desktop or VSCode (including Cursor/Windsurf). The documentation also states that it supports Azure deployment and also supports providing configuration via an environment file; you can use --env-file path/to/file/.env to pass in the environment file.
Development-related: the TypeScript source code is located at src/index.ts; the build command is yarn build; the run command is node dist/index.js. For all options, see src/index.ts.
Applicable Scenarios
Suitable for scenarios involving generating images from prompts in MCP-compatible clients, as well as editing, extending, or compositing images through prompts and masks.
Limitations and Notes
- Ensure that OPENAI_API_KEY is valid and has image API access permissions.
- You must have a verified OpenAI organization; after verification, image API access may take 15–20 minutes to activate.
- File paths must be absolute paths. On Unix/macOS/Linux, they start with / (e.g., /path/to/image.png); on Windows, it is a drive letter followed by a colon (e.g., C:/path/to/image.png or C:\path\to\image.png).
- When outputting files, ensure the directory is writable.
- If you encounter file type-related errors, check the extension and format of the image file.
- 1MB payload limit: MCP clients (including Claude Desktop) have a hard 1MB limit on tool responses. Large images (especially high-resolution or multiple images) can easily exceed this limit if returned as base64.
- Automatic switch to file output: when the total image size exceeds 1MB, the tool automatically saves the image to disk and returns the file path instead of base64, to avoid errors such as result exceeds maximum length of 1048576.
- Default file location: if no file_output path is specified, images are saved to /tmp (or the directory set by the MCP_HF_WORK_DIR environment variable) and use a unique filename.
- The MCP_HF_WORK_DIR environment variable can be used to control where large images and file outputs are saved, for example: export MCP_HF_WORK_DIR=/your/desired/dir.
- Best practice: for large or production-use images, always use file output and ensure the client is configured to handle file paths.
This tool is built on @modelcontextprotocol/sdk, uses OpenAI's Node.js SDK, and is built by SureScale.ai.