GPT Image Generator MCP server

Enables direct image generation and editing through OpenAI's gpt-image-1 model with support for text prompts, file paths, and base64 encoded inputs for creative workflows and visual content creation.
Back to servers
Setup instructions
Provider
CLOUDWERX
Release date
May 08, 2025
Language
Go
Stats
13 stars

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.

Getting Started

Prerequisites

  • Node.js v14 or higher
  • OpenAI API key with access to gpt-image-1

Environment Variables

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)

Quick Start with NPX

Run the server directly without installation:

npx -y @cloudwerxlab/gpt-image-1-mcp

Linux/macOS Example

# 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

Windows PowerShell Example

# 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

Installation with NPM

You can also install the package globally:

npm install -g @cloudwerxlab/gpt-image-1-mcp

Integrating with MCP Clients

Setting Up in Client Configuration

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"
      }
    }
  }
}

Windows Configuration Example

{
  "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"
      }
    }
  }
}

Linux/macOS Configuration Example

{
  "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"
      }
    }
  }
}

Using the Tools

Creating 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>

Parameters for create_image

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)

Editing Images

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>

Parameters for create_image_edit

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

Troubleshooting

Common Issues

  • MIME Type Errors: Ensure image files have the correct extension matching their format.
  • API Key Issues: Verify your OpenAI API key is correct and has access to gpt-image-1.
  • Output Directory Issues: Check if the process has write permissions to the output directory.

When errors occur, the server provides detailed information to help diagnose and resolve the issue.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            }
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later