MCP ExplorerExplorer

Incomestreamsurfer Chatgpt Native Image Gen Mcp

@MCP-Mirroron 17 days ago
1 Apache-2.0
FreeCommunity
AI Systems
Mirror of https://github.com/IncomeStreamSurfer/chatgpt-native-image-gen-mcp

Overview

What is Incomestreamsurfer Chatgpt Native Image Gen Mcp

IncomeStreamSurfer_chatgpt-native-image-gen-mcp is an MCP server that utilizes OpenAI’s gpt-image-1 model to generate and edit images based on text prompts. It provides a set of tools for image creation and modification through the official Python SDK.

Use cases

Use cases include generating unique artwork based on user descriptions, creating variations of existing images for design purposes, and producing images for social media content or advertising campaigns.

How to use

To use IncomeStreamSurfer_chatgpt-native-image-gen-mcp, send requests to the server with the required parameters, including a text prompt for image generation or editing. The server responds with the generated image’s path or an error message.

Key features

Key features include the ability to generate images with the ‘generate_image’ tool and edit images or create variations with the ‘edit_image’ tool. Users can specify parameters such as image size, quality, and save filename.

Where to use

IncomeStreamSurfer_chatgpt-native-image-gen-mcp can be used in various fields such as digital art creation, marketing materials, game development, and any application requiring custom image generation or editing.

Content

OpenAI Image Generation MCP Server

This project implements an MCP (Model Context Protocol) server that provides tools for generating and editing images using OpenAI’s gpt-image-1 model via the official Python SDK.

Features

This MCP server provides the following tools:

  • generate_image: Generates an image using OpenAI’s gpt-image-1 model based on a text prompt and saves it.

    • Input Schema:
      {
        "type": "object",
        "properties": {
          "prompt": {
            "type": "string",
            "description": "The text description of the desired image(s)."
          },
          "model": {
            "type": "string",
            "default": "gpt-image-1",
            "description": "The model to use (currently 'gpt-image-1')."
          },
          "n": {
            "type": [
              "integer",
              "null"
            ],
            "default": 1,
            "description": "The number of images to generate (Default: 1)."
          },
          "size": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "1024x1024",
              "1536x1024",
              "1024x1536",
              "auto"
            ],
            "default": "auto",
            "description": "Image dimensions ('1024x1024', '1536x1024', '1024x1536', 'auto'). Default: 'auto'."
          },
          "quality": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "low",
              "medium",
              "high",
              "auto"
            ],
            "default": "auto",
            "description": "Rendering quality ('low', 'medium', 'high', 'auto'). Default: 'auto'."
          },
          "user": {
            "type": [
              "string",
              "null"
            ],
            "default": null,
            "description": "An optional unique identifier representing your end-user."
          },
          "save_filename": {
            "type": [
              "string",
              "null"
            ],
            "default": null,
            "description": "Optional filename (without extension). If None, a default name based on the prompt and timestamp is used."
          }
        },
        "required": [
          "prompt"
        ]
      }
    • Output: {"status": "success", "saved_path": "path/to/image.png"} or error dictionary.
  • edit_image: Edits an image or creates variations using OpenAI’s gpt-image-1 model and saves it. Can use multiple input images as reference or perform inpainting with a mask.

    • Input Schema:
      {
        "type": "object",
        "properties": {
          "prompt": {
            "type": "string",
            "description": "The text description of the desired final image or edit."
          },
          "image_paths": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A list of file paths to the input image(s). Must be PNG. < 25MB."
          },
          "mask_path": {
            "type": [
              "string",
              "null"
            ],
            "default": null,
            "description": "Optional file path to the mask image (PNG with alpha channel) for inpainting. Must be same size as input image(s). < 25MB."
          },
          "model": {
            "type": "string",
            "default": "gpt-image-1",
            "description": "The model to use (currently 'gpt-image-1')."
          },
          "n": {
            "type": [
              "integer",
              "null"
            ],
            "default": 1,
            "description": "The number of images to generate (Default: 1)."
          },
          "size": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "1024x1024",
              "1536x1024",
              "1024x1536",
              "auto"
            ],
            "default": "auto",
            "description": "Image dimensions ('1024x1024', '1536x1024', '1024x1536', 'auto'). Default: 'auto'."
          },
          "quality": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "low",
              "medium",
              "high",
              "auto"
            ],
            "default": "auto",
            "description": "Rendering quality ('low', 'medium', 'high', 'auto'). Default: 'auto'."
          },
          "user": {
            "type": [
              "string",
              "null"
            ],
            "default": null,
            "description": "An optional unique identifier representing your end-user."
          },
          "save_filename": {
            "type": [
              "string",
              "null"
            ],
            "default": null,
            "description": "Optional filename (without extension). If None, a default name based on the prompt and timestamp is used."
          }
        },
        "required": [
          "prompt",
          "image_paths"
        ]
      }
    • Output: {"status": "success", "saved_path": "path/to/image.png"} or error dictionary.

Prerequisites

  • Python (3.8 or later recommended)
  • pip (Python package installer)
  • An OpenAI API Key (set directly in the script or via the OPENAI_API_KEY environment variable - using environment variables is strongly recommended for security).
  • An MCP client environment (like the one used by Cline) capable of managing and launching MCP servers.

Installation

  1. Clone the repository:
    git clone https://github.com/IncomeStreamSurfer/chatgpt-native-image-gen-mcp.git
    cd chatgpt-native-image-gen-mcp
    
  2. Set up a virtual environment (Recommended):
    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  3. Install dependencies:
    pip install -r requirements.txt
    
  4. (Optional but Recommended) Set Environment Variable:
    Set the OPENAI_API_KEY environment variable with your OpenAI key instead of hardcoding it in the script. How you set this depends on your operating system.

Configuration (for Cline MCP Client)

To make this server available to your AI assistant (like Cline), add its configuration to your MCP settings file (e.g., cline_mcp_settings.json).

Find the mcpServers object in your settings file and add the following entry:

Important: Replace C:/path/to/your/cloned/repo/ with the correct absolute path to where you cloned this repository on your machine. Ensure the path separator is correct for your operating system (e.g., use backslashes \ on Windows). If you set the API key via environment variable, you can remove it from the script and potentially add it to the env section here if your MCP client supports it.

Running the Server

You don’t typically need to run the server manually. The MCP client (like Cline) will automatically start the server using the command and args specified in the configuration file when one of its tools is called for the first time.

If you want to test it manually (ensure dependencies are installed and API key is available):

python openai_image_mcp.py

Usage

The AI assistant interacts with the server using the generate_image and edit_image tools. Images are saved within an ai-images subdirectory created where the openai_image_mcp.py script is located. The tools return the absolute path to the saved image upon success.

Tools

No tools

Comments