A Model Context Protocol (MCP) server for OpenAI image generation API. This MCP enables AI assistants like Claude to generate and edit images using OpenAI's GPT-image-1 model.
- Generate images using OpenAI's image generation models
- Edit existing images with text prompts and optional masks
- Automatically save generated images to local storage
- Optionally upload generated images to Cloudflare ImgBed
- Health check endpoint to verify server status
- Multiple ways to provide API key (env var, command line, direct)
- Clone the repository and install dependencies:
git clone https://github.com/yourusername/openai-image-gen-mcp.git
cd openai-image-gen-mcp
npm install- Build the TypeScript project:
npm run buildThe easiest way to start the full-featured MCP server:
./run-with-key.shThis script has the API key embedded and starts the MCP server with all features.
node hardcoded-key.jsThis is a simplified version with the API key directly embedded in the code.
export OPENAI_API_KEY=your-api-key
./start.shTo connect Claude to this MCP, use this configuration file:
{
"mcpServers": {
"openai-image-gen": {
"command": "node",
"args": ["/Users/jerry/openai-image-gen-mcp/build/index.js"]
}
}
}build/index.js) for production. The simplified versions are for testing and education only.
The MCP provides these tools to Claude:
- oai_generate_image - Generate images from text prompts
- oai_edit_image - Edit existing images with text prompts
- health_check - Verify the server's health status
Example usage in Claude:
Generate an image of a sunset over mountains with a lake in the foreground.
Claude will use the appropriate MCP tool to create the image.
For more detailed information, please see:
- Architecture - System design and components
- Pipeline - Development and request processing pipeline
- Guidelines - Best practices and usage guidelines
- Explanation - Detailed explanation of the code and APIs
openai-image-gen-mcp/
├── build/ # Compiled JavaScript code
├── docs/ # Documentation files
├── output/ # Generated images
├── src/ # TypeScript source code
│ ├── config.js # Configuration management
│ └── index.ts # Main MCP server implementation
├── *.sh # Helper scripts
├── *.js # Simplified versions and utilities
└── *.json # Configuration files
If you encounter problems:
- Check that your API key is valid and properly formatted
- Ensure the output directory exists and is writable
- Run the health check to verify server status
- Check logs for detailed error information
- Try the simplified version to isolate issues
For more help, see the Troubleshooting section in the guidelines.