imagegen
MCP server for OpenAI Image Generation & Editing — text-to-image, image-to-image (with mask), no extra plugins.
claude mcp add --transport stdio spartanz51-imagegen-mcp npx imagegen-mcp \ --env OPENAI_API_KEY="your_openai_api_key_here"
How to use
The MCP server imagegen-mcp exposes OpenAI image generation and editing capabilities via the MCP protocol. It acts as a wrapper around OpenAI's image APIs and integrates two core MCP tools: text-to-image and image-to-image. The text-to-image tool generates images from natural language prompts, with support for multiple models (e.g., gpt-image-1, dall-e-2, dall-e-3) and adjustable parameters such as size, style, format, and quality. The image-to-image tool edits existing images by providing paths to source images, a prompt describing the desired edits, and optional masks. Generated results are saved to temporary files and returned alongside base64 data. You can configure which models are allowed at runtime using the --models option when starting the server (default includes the supported OpenAI image models).
To use from MCP-enabled clients (e.g., Cursor), start the server via npx and then issue MCP requests specifying the tool name (text-to-image or image-to-image) and the required parameters. The server will handle image generation/editing and respond with the path to the saved image and its data.
How to install
Prerequisites:
- Node.js v18+ and npm or yarn
- An OpenAI API key with access to image generation/edit endpoints
Installation steps:
- Install dependencies and set up the project
git clone <your-repository-url>
cd <repository-directory>
npm install
# or
yarn install
- Configure environment variables
cp .env.example .env
Edit .env to include your OpenAI API key (the README indicates OPENAI_API_KEY as the key):
OPENAI_API_KEY=your_openai_api_key_here
- Build (if needed) or run directly with npx
# Quick run with npx (no local build required):
npx imagegen-mcp --help
- Run locally (alternative to npx)
npm run build
node dist/index.js --help
Additional notes
Environment variables and configuration:
- OPENAI_API_KEY is required to authenticate with OpenAI.
- The server supports environment-driven configuration and CLI options (e.g., --models to restrict available OpenAI image models).
Common issues:
- If you encounter authentication errors, verify OPENAI_API_KEY is correct and has access to the requested models.
- Ensure the runtime has permission to write to the system temporary directory for saved images.
Model and parameter notes:
- The text-to-image tool supports models like gpt-image-1, dall-e-2, dall-e-3 with options for size, style, and output format.
- The image-to-image tool supports editing through gpt-image-1 and dall-e-2 with masks; available sizes and formats follow OpenAI capabilities.
For Cursor integration, you can adjust the command provided in Cursor settings to point to your server and expose desired models via --models.
Related MCP Servers
mcp
Browser MCP is a Model Context Provider (MCP) server that allows AI applications to control your browser
kanban
MCP Kanban is a specialized middleware designed to facilitate interaction between Large Language Models (LLMs) and Planka, a Kanban board application. It serves as an intermediary layer that provides LLMs with a simplified and enhanced API to interact with Planka's task management system.
MCP -Starter
A Model Context Protocol server starter template
mcp-cron
MCP server for scheduling and running shell commands and AI prompts
mcp -templates
A flexible platform that provides Docker & Kubernetes backends, a lightweight CLI (mcpt), and client utilities for seamless MCP integration. Spin up servers from templates, route requests through a single endpoint with load balancing, and support both deployed (HTTP) and local (stdio) transports — all with sensible defaults and YAML-based configs.
movie-context-provider
An OpenAI App demo built with the OpenAI Apps SDK, that's ready to deploy on Render.