Labsco
IncomeStreamSurfer logo

OpenAI Image Generation

โ˜… 15

from IncomeStreamSurfer

Generate and edit images using OpenAI's DALL-E models via the official Python SDK.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

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.