Integrations
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:Copy
- 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:Copy
- 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:Copy
- Set up a virtual environment (Recommended):Copy
- Install dependencies:Copy
- (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
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
- AsecurityAlicenseAqualityEnables the generation of images using Together AI's models through an MCP server, supporting customizable parameters such as model selection, image dimensions, and output directory.Last updated -14JavaScriptMIT License
- AsecurityAlicenseAqualityA MCP server that enables Claude and other MCP-compatible assistants to generate images from text prompts using Together AI's image generation models.Last updated -12TypeScriptMIT License
- -securityAlicense-qualityA MCP server that integrates with Cursor IDE to generate images based on text descriptions using JiMeng AI, allowing users to create and save custom images directly within their development environment.Last updated -82PythonMIT License
- -securityFlicense-qualityAn MCP server that allows users to generate, edit, and create variations of images through OpenAI's DALL-E API, supporting both DALL-E 2 and DALL-E 3 models.Last updated -2TypeScript