Skip to main content

OpenAI Image Generation MCP Server for AI assistant access to OpenAI's image generation capabilities

Project description

OpenAI Image Generation MCP

Model Context Protocol (MCP) server for AI assistants to generate and edit images using OpenAI's GPT-image-1 model.

Features

  • Generate images from text prompts
  • Edit images with reference images and optional masks
  • Save generated/edited images to local storage
  • Handle errors gracefully

Installation

Install from PyPI:

pip install openai-gpt-image-1-mcp

Prerequisites

  • Python 3.10 or higher
  • OpenAI API key (set as environment variable OPENAI_API_KEY)

Usage

Starting the MCP Server

After installation, you can start the MCP server using the following command:

openai-gpt-image-1-mcp

Or run it directly as a module:

python -m openai_gpt_image_1_server

Configuring with Claude Desktop

To use this MCP with Claude Desktop or similar tools, add the following configuration to your mcp_config.json file:

For PyPI installation (recommended)

"openai-gpt-image-1-mcp": {
  "autoApprove": [
    "generate_image",
    "edit_image"
  ],
  "disabled": false,
  "timeout": 180,
  "command": "openai-gpt-image-1-mcp",
  "env": {
    "OPENAI_API_KEY": "your_openai_api_key_here"
  },
  "transportType": "stdio"
}

For UV package manager

"openai-gpt-image-1-mcp": {
  "autoApprove": [
    "generate_image",
    "edit_image"
  ],
  "disabled": false,
  "timeout": 180,
  "command": "uv",
  "args": [
    "run",
    "openai-gpt-image-1-mcp"
  ],
  "env": {
    "OPENAI_API_KEY": "your_openai_api_key_here"
  },
  "transportType": "stdio"
}

For direct execution (without PyPI)

If you cloned the repository and want to run it directly:

"openai-gpt-image-1-mcp": {
  "autoApprove": [
    "generate_image",
    "edit_image"
  ],
  "disabled": false,
  "timeout": 180,
  "command": "python",
  "args": [
    "/absolute/path/to/your/cloned/repo/openai_gpt_image_1_mcp/openai_gpt_image_1_server/__init__.py"
  ],
  "env": {
    "OPENAI_API_KEY": "your_openai_api_key_here"
  },
  "transportType": "stdio"
}

Configuration parameters explained:

  • autoApprove: List of tool methods that can be called without user confirmation
  • disabled: Set to true to disable this MCP
  • timeout: Maximum time (in seconds) allowed for image generation operations
  • command & args: The command to start the MCP server
  • env: Environment variables needed by the MCP (requires your OpenAI API key)
  • transportType: Communication protocol used (keep as "stdio")

API Tools

generate_image

Generate an image from a text prompt.

Parameters:

  • prompt (string, required): Text description of the desired image
  • model (string, optional): Model to use, default is "gpt-image-1"
  • n (integer, optional): Number of images to generate, default is 1
  • size (string, optional): Image dimensions, options: "1024x1024", "1536x1024", "1024x1536", "auto"
  • quality (string, optional): Rendering quality, options: "low", "medium", "high", "auto"
  • user (string, optional): Unique identifier for the end-user
  • save_filename (string, optional): Custom filename without extension

Returns:

  • Success: {"status": "success", "saved_path": "/path/to/image.png"}
  • Error: {"status": "error", "message": "Error details"}

edit_image

Edit an image or create variations based on reference images and an optional mask.

Parameters:

  • prompt (string, required): Text description of the desired final image
  • image_paths (array of strings, required): List of paths to input images
  • mask_path (string, optional): Path to mask image for inpainting
  • model (string, optional): Model to use, default is "gpt-image-1"
  • n (integer, optional): Number of images to generate, default is 1
  • size (string, optional): Image dimensions, options: "1024x1024", "1536x1024", "1024x1536", "auto"
  • quality (string, optional): Rendering quality, options: "low", "medium", "high", "auto"
  • user (string, optional): Unique identifier for the end-user
  • save_filename (string, optional): Custom filename without extension

Returns:

  • Success: {"status": "success", "saved_path": "/path/to/image.png"}
  • Error: {"status": "error", "message": "Error details"}

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key (required)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openai_gpt_image_1_mcp-0.1.3.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openai_gpt_image_1_mcp-0.1.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file openai_gpt_image_1_mcp-0.1.3.tar.gz.

File metadata

  • Download URL: openai_gpt_image_1_mcp-0.1.3.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for openai_gpt_image_1_mcp-0.1.3.tar.gz
Algorithm Hash digest
SHA256 51eeb022dfea696157c8288d31918bbe891eb57bb128d5a8785c9b79dde4e0a3
MD5 567a7b21e4ffe4000218230d7c02c738
BLAKE2b-256 e26814d0440fc19279369d634e242440f082ef58d47c6f29d76598feb02e9da7

See more details on using hashes here.

File details

Details for the file openai_gpt_image_1_mcp-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for openai_gpt_image_1_mcp-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 47eecd8dc9377a2e12625da7e30b813932e240f1ffe1a35803c1654ade5855b4
MD5 d66c28e06a2b178960713131ab49a858
BLAKE2b-256 9c1c8ff5915898962071b2e634e31c7276b63c3c974fc55c4ab26fdacefc91cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page