Enables image generation and editing using OpenAI's gpt-image-1 model, providing tools to create images from text prompts, edit existing images, and perform inpainting with masks.
Uses the OpenAI Python SDK to implement the image generation capabilities, allowing for programmatic access to OpenAI's image models through Python.
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'sgpt-image-1
model based on a text prompt and saves it.- Input Schema:
- Output:
{"status": "success", "saved_path": "path/to/image.png"}
or error dictionary.
- Input Schema:
edit_image
: Edits an image or creates variations using OpenAI'sgpt-image-1
model and saves it. Can use multiple input images as reference or perform inpainting with a mask.- Input Schema:
- Output:
{"status": "success", "saved_path": "path/to/image.png"}
or error dictionary.
- Input Schema:
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
- Clone the repository:
- Set up a virtual environment (Recommended):
- Install dependencies:
- (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):
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.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Provides tools for generating and editing images using OpenAI's gpt-image-1 model via an MCP interface, enabling AI assistants to create and modify images based on text prompts.
Related MCP Servers
- AsecurityAlicenseAqualityAllows AI assistants to generate and transform high-quality images from text prompts using Google's Gemini model via the MCP protocol.Last updated -314PythonMIT License
- -securityAlicense-qualityAn MCP tool server that enables generating and editing images through OpenAI's image models, supporting text-to-image generation and advanced image editing (inpainting, outpainting) across various MCP-compatible clients.Last updated -52TypeScriptMIT License
- AsecurityFlicenseAqualityAn MCP (Model Context Protocol) server that allows generating, editing, and creating variations of images using OpenAI's DALL-E APIs.Last updated -1TypeScript
- AsecurityAlicenseAqualityAn MCP server that allows Claude to use OpenAI's image generation capabilities (gpt-image-1) to create image assets for users, which is particularly useful for game and web development projects.Last updated -122JavaScriptMIT License