A Model Context Protocol (MCP) tool server for OpenAI's GPT-4o/gpt-image-1 image generation and editing APIs.
git clone https://github.com/SureScaleAI/openai-gpt-image-mcp.git
cd openai-gpt-image-mcp
yarn install
yarn build
Add to Claude Desktop or VSCode (including Cursor/Windsurf) config:
{
"mcpServers": {
"openai-gpt-image-mcp": {
"command": "node",
"args": ["/absolute/path/to/dist/index.js"],
"env": { "OPENAI_API_KEY": "sk-..." }
}
}
}
Also supports Azure deployments:
{
"mcpServers": {
"openai-gpt-image-mcp": {
"command": "node",
"args": ["/absolute/path/to/dist/index.js"],
"env": {
"AZURE_OPENAI_API_KEY": "sk-...",
"AZURE_OPENAI_ENDPOINT": "my.endpoint.com",
"OPENAI_API_VERSION": "2024-12-01-preview"
}
}
}
}
Also supports supplying an environment files:
{
"mcpServers": {
"openai-gpt-image-mcp": {
"command": "node",
"args": ["/absolute/path/to/dist/index.js", "--env-file", "./deployment/.env"]
}
}
}
create-image
, set n
to generate up to 10 images at once.edit-image
, provide a mask image (file path or base64) to control where edits are applied.--env-file path/to/file/.env
src/index.ts
for all options.src/index.ts
yarn build
node dist/index.js
MIT
OPENAI_API_KEY
is valid and has image API access./
(e.g., /path/to/image.png
):
(e.g., C:/path/to/image.png
or C:\path\to\image.png
)result exceeds maximum length of 1048576
.file_output
path, images will be saved to /tmp
(or the directory set by the MCP_HF_WORK_DIR
environment variable) with a unique filename.MCP_HF_WORK_DIR
: Set this to control where large images and file outputs are saved. Example: export MCP_HF_WORK_DIR=/your/desired/dir