openai-gpt-image
A Model Context Protocol (MCP) tool server for OpenAI's GPT-4o/gpt-image-1 image generation and editing APIs.
claude mcp add --transport stdio surescaleai-openai-gpt-image-mcp node /absolute/path/to/dist/index.js \ --env OPENAI_API_KEY="sk-..."
How to use
This MCP server exposes OpenAI image generation and editing capabilities via MCP clients. It uses the OpenAI image APIs to generate images from prompts and supports editing operations such as inpainting, outpainting, and compositing with prompt-driven controls. The server outputs either image data directly (base64) or writes files to disk and returns file paths, depending on the payload size and MCP client configuration. You can configure the server within your MCP-enabled tooling (e.g., Claude Desktop, VSCode, Cursor, Windsurf) by providing the server name, the path to the built runtime (dist/index.js), and any required environment variables such as your OpenAI API key.
Once running, you can invoke two primary capabilities: create-image and edit-image. create-image accepts a text prompt along with optional parameters like image size, quality, and other OpenAI image options. edit-image lets you apply a prompt-based modification to an existing image, optionally using a mask to constrain edits. The server can output results as base64 or save them to disk for large responses, with sensible defaults and guidance to ensure compatibility with MCP clients.
How to install
Prerequisites:
- Node.js installed (npx or node available in PATH)
- Yarn or npm for dependencies
- Git to clone the repository
Install and run:
- Clone the repository: git clone https://github.com/SureScaleAI/openai-gpt-image-mcp.git
- Navigate to the project: cd openai-gpt-image-mcp
- Install dependencies (Yarn): yarn install
- Build the project: yarn build
- Run the server (example): node dist/index.js
Configuration:
- In your MCP client, point to the built server entry (dist/index.js) and pass necessary environment variables such as OPENAI_API_KEY. You can also supply an env file via your client if supported (e.g., --env-file path/to/.env).
Optional: prepare a .env file with OPENAI_API_KEY and any other needed variables, then run with the environment file support provided by your MCP client.
Additional notes
Notes and tips:
- Ensure OPENAI_API_KEY has access to image generation endpoints.
- Absolute file paths are recommended for input/output files when using file-based edit/output modes.
- If output size is large, the MCP server may return a file path instead of base64 data to avoid 1MB payload limits.
- You can configure Azure OpenAI or classic OpenAI keys by adjusting env variables as shown in the README examples.
- For production usage, consider setting MCP_HF_WORK_DIR to control where large images are saved and to improve performance and reliability.
- If you encounter file type or path errors, verify that input paths exist and have appropriate read permissions, and that output directories are writable.
Related MCP Servers
iterm
A Model Context Protocol server that executes commands in the current iTerm session - useful for REPL and CLI assistance
mcp
Octopus Deploy Official MCP Server
furi
CLI & API for MCP management
editor
MCP Server for Phaser Editor
DoorDash
MCP server from JordanDalton/DoorDash-MCP-Server
mcp
MCP сервер для автоматического создания и развертывания приложений в Timeweb Cloud