home / mcp / openai image generation mcp server

OpenAI Image Generation MCP Server

Provides tools to generate and edit images using OpenAI gpt-image-1 via an MCP server.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "incomestreamsurfer-chatgpt-native-image-gen-mcp": {
      "command": "python",
      "args": [
        "C:/path/to/your/cloned/repo/chatgpt-native-image-gen-mcp/openai_image_mcp.py"
      ],
      "env": {
        "OPENAI_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

This MCP server lets you generate and edit images using OpenAI’s gpt-image-1 model through a Python-based MCP integration. It exposes two tools—generate_image and edit_image—for creating new images from prompts and for editing or inpainting existing images. You can run this locally and connect it to your MCP client to automate image generation in your workflows.

How to use

You interact with the server through your MCP client by calling the two available tools. Use generate_image to create new images from a text prompt and save the result to disk. Use edit_image to modify an image or generate variations based on one or more reference images, with optional inpainting via a mask. The tools return the absolute path of the saved image when successful.

Before you start, ensure you have a valid OpenAI API key and that your MCP client is configured to launch the local Python server process. The server writes generated images to an ai-images subdirectory next to where the openai_image_mcp.py script resides.

How to install

Prerequisites you’ll need to meet before installing: Python 3.8 or later, pip, an OpenAI API key, and an MCP client environment capable of managing MCP servers.

Step-by-step setup:

# 1) Clone the project
git clone https://github.com/IncomeStreamSurfer/chatgpt-native-image-gen-mcp.git
cd chatgpt-native-image-gen-mcp

# 2) Set up a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows use `venv\Scripts\activate`

# 3) Install dependencies
pip install -r requirements.txt

# 4) Ensure your OpenAI API key is available (recommended via environment variable)
export OPENAI_API_KEY=your_api_key_here  # macOS/Linux
set OPENAI_API_KEY=your_api_key_here     # Windows
```} ,{

Configuration and usage with an MCP client

To enable your MCP client to launch this server, use the stdio configuration that runs the Python script directly. This setup assumes you have an absolute path to the script on your system.

{
  "type": "stdio",
  "name": "openai_image_mcp",
  "command": "python",
  "args": [
    "C:/path/to/your/cloned/repo/chatgpt-native-image-gen-mcp/openai_image_mcp.py"
  ],
  "env": {
    "OPENAI_API_KEY": "YOUR_API_KEY_HERE"
  }
}
````}]} ,{

Usage notes and output

Images are saved in an ai-images subdirectory alongside the openai_image_mcp.py script. Successful tool calls return the absolute path to the saved image. If a call fails, you’ll receive an error dictionary describing what went wrong.

Available tools

generate_image

Generates a new image from a text prompt using the gpt-image-1 model and saves it. Returns the path to the saved image on success.

edit_image

Edits an existing image or creates variations using one or more input images and optionally a mask for inpainting. Returns the path to the saved image on success.