This MCP server provides a Model Context Protocol (MCP) interface to OpenAI's gpt-image-1 model, enabling you to generate and edit images through compatible MCP clients. It seamlessly integrates with platforms like VS Code, Roo, Cursor, Augment, and Windsurf.
Variable | Required | Description |
---|---|---|
OPENAI_API_KEY |
Yes | Your OpenAI API key with access to gpt-image-1 |
GPT_IMAGE_OUTPUT_DIR |
No | Custom directory for saving images (defaults to user's Pictures folder under gpt-image-1 subfolder) |
Run the server directly without installation:
npx -y @cloudwerxlab/gpt-image-1-mcp
# Set your OpenAI API key
export OPENAI_API_KEY=sk-your-openai-api-key
# Optional: Set custom output directory
export GPT_IMAGE_OUTPUT_DIR=/home/username/Pictures/ai-generated-images
# Run the server with NPX
npx -y @cloudwerxlab/gpt-image-1-mcp
# Set your OpenAI API key
$env:OPENAI_API_KEY = "sk-your-openai-api-key"
# Optional: Set custom output directory
$env:GPT_IMAGE_OUTPUT_DIR = "C:\Users\username\Pictures\ai-generated-images"
# Run the server with NPX
npx -y @cloudwerxlab/gpt-image-1-mcp
You can also install the package globally:
npm install -g @cloudwerxlab/gpt-image-1-mcp
Locate your MCP client's settings file and add the following configuration:
{
"mcpServers": {
"gpt-image-1": {
"command": "npx",
"args": [
"-y",
"@cloudwerxlab/gpt-image-1-mcp"
],
"env": {
"OPENAI_API_KEY": "PASTE YOUR OPEN-AI KEY HERE",
"GPT_IMAGE_OUTPUT_DIR": "OPTIONAL: PATH TO SAVE GENERATED IMAGES"
}
}
}
}
{
"mcpServers": {
"gpt-image-1": {
"command": "npx",
"args": ["-y", "@cloudwerxlab/gpt-image-1-mcp"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"GPT_IMAGE_OUTPUT_DIR": "C:\\Users\\username\\Pictures\\ai-generated-images"
}
}
}
}
{
"mcpServers": {
"gpt-image-1": {
"command": "npx",
"args": ["-y", "@cloudwerxlab/gpt-image-1-mcp"],
"env": {
"OPENAI_API_KEY": "sk-your-openai-api-key",
"GPT_IMAGE_OUTPUT_DIR": "/home/username/Pictures/ai-generated-images"
}
}
}
}
Use the create_image
tool to generate images from text prompts:
<use_mcp_tool>
<server_name>gpt-image-1</server_name>
<tool_name>create_image</tool_name>
<arguments>
{
"prompt": "A futuristic city skyline at sunset, digital art",
"size": "1024x1024",
"quality": "high",
"n": 1,
"background": "auto"
}
</arguments>
</use_mcp_tool>
Parameter | Type | Required | Description |
---|---|---|---|
prompt |
string | Yes | Text description of the image (max 32,000 chars) |
size |
string | No | "1024x1024" (default), "1536x1024", or "1024x1536" |
quality |
string | No | "high" (default), "medium", or "low" |
n |
integer | No | Number of images (1-10, default: 1) |
background |
string | No | "transparent", "opaque", or "auto" (default) |
output_format |
string | No | "png" (default), "jpeg", or "webp" |
output_compression |
integer | No | Compression level (0-100, default: 0) |
user |
string | No | User identifier for OpenAI usage tracking |
moderation |
string | No | "low" or "auto" (default) |
Use the create_image_edit
tool to edit existing images:
<use_mcp_tool>
<server_name>gpt-image-1</server_name>
<tool_name>create_image_edit</tool_name>
<arguments>
{
"image": {
"filePath": "C:/path/to/your/image.png"
},
"prompt": "Add a small robot in the corner",
"mask": {
"filePath": "C:/path/to/your/mask.png"
},
"quality": "high"
}
</arguments>
</use_mcp_tool>
Parameter | Type | Required | Description |
---|---|---|---|
image |
string/object/array | Yes | Image to edit (base64 or file path) |
prompt |
string | Yes | Description of the edit (max 32,000 chars) |
mask |
string/object | No | Mask defining areas to edit (base64 or file path) |
size |
string | No | "1024x1024" (default), "1536x1024", or "1024x1536" |
quality |
string | No | "high" (default), "medium", or "low" |
n |
integer | No | Number of images (1-10, default: 1) |
background |
string | No | "transparent", "opaque", or "auto" (default) |
user |
string | No | User identifier for OpenAI usage tracking |
When errors occur, the server provides detailed information to help diagnose and resolve the issue.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "gpt-image-1" '{"command":"npx","args":["-y","@cloudwerxlab/gpt-image-1-mcp"],"env":{"OPENAI_API_KEY":"PASTE YOUR OPEN-AI KEY HERE","GPT_IMAGE_OUTPUT_DIR":"OPTIONAL: PATH TO SAVE GENERATED IMAGES"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"gpt-image-1": {
"command": "npx",
"args": [
"-y",
"@cloudwerxlab/gpt-image-1-mcp"
],
"env": {
"OPENAI_API_KEY": "PASTE YOUR OPEN-AI KEY HERE",
"GPT_IMAGE_OUTPUT_DIR": "OPTIONAL: PATH TO SAVE GENERATED IMAGES"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"gpt-image-1": {
"command": "npx",
"args": [
"-y",
"@cloudwerxlab/gpt-image-1-mcp"
],
"env": {
"OPENAI_API_KEY": "PASTE YOUR OPEN-AI KEY HERE",
"GPT_IMAGE_OUTPUT_DIR": "OPTIONAL: PATH TO SAVE GENERATED IMAGES"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect