OpenAI Image Generation MCP Server
Enables image generation using OpenAI's DALL-E and GPT-Image models directly through the Model Context Protocol. It allows users to create and save images with fine-grained control over parameters like size, quality, and background transparency.
README
OpenAI Image Generation MCP Server
A TypeScript-based Model Context Protocol (MCP) server for generating images using OpenAI's image generation models (gpt-image-1, gpt-image-1-mini, DALL-E 3, and DALL-E 2).
Quick Start with npx
The easiest way to use this MCP server is with npx (no installation required):
npx @lpenguin/openai-image-mcp
This will start the MCP server with stdio transport. You'll need to set the OPENAI_API_KEY environment variable:
OPENAI_API_KEY=your_api_key_here npx @lpenguin/openai-image-mcp
Installation
You can also install the package globally:
npm install -g @lpenguin/openai-image-mcp
Then run it with:
openai-image-mcp
Development Setup
For local development:
- Clone this repository
- Install dependencies:
npm install - Create a
.envfile based on.env.exampleand add your OpenAI API key:OPENAI_API_KEY=your_openai_api_key_here - Build the TypeScript code:
npm run build
Running the MCP Server
Start the MCP server:
npm start
Development
For development with automatic compilation:
npm run dev
MCP Server Configuration
To use this as an MCP server with Claude or other MCP clients, you need to add it to your MCP settings configuration file.
Using npx (Recommended)
The easiest way is to use npx directly in your MCP configuration:
{
"mcpServers": {
"image-generation": {
"command": "npx",
"args": ["-y", "@lpenguin/openai-image-mcp"],
"env": {
"OPENAI_API_KEY": "your_openai_api_key_here"
},
"disabled": false,
"autoApprove": []
}
}
}
Using local installation
If you have the package installed globally or locally, you can use the direct command:
{
"mcpServers": {
"image-generation": {
"command": "openai-image-mcp",
"env": {
"OPENAI_API_KEY": "your_openai_api_key_here"
},
"disabled": false,
"autoApprove": []
}
}
}
Using from source (Development)
For local development with the cloned repository:
{
"mcpServers": {
"image-generation": {
"command": "node",
"args": ["dist/mcp-server.js"],
"env": {
"OPENAI_API_KEY": "your_openai_api_key_here"
},
"disabled": false,
"autoApprove": []
}
}
}
Important: Replace "your_openai_api_key_here" with your actual OpenAI API key. The MCP server will use this key to authenticate with the OpenAI API.
Copy this configuration to your MCP settings file, typically located at:
VS Code
VS Code has native MCP support. Add the configuration to your workspace or user settings:
Location: .vscode/mcp.json (in your workspace root)
Using npx:
{
"mcpServers": {
"image-generation": {
"command": "npx",
"args": ["-y", "@lpenguin/openai-image-mcp"],
"env": {
"OPENAI_API_KEY": "your_openai_api_key_here"
},
"disabled": false,
"autoApprove": []
}
}
}
Using local installation:
{
"mcpServers": {
"image-generation": {
"command": "node",
"args": ["/absolute/path/to/openai-image-mcp/dist/mcp-server.js"],
"env": {
"OPENAI_API_KEY": "your_openai_api_key_here"
},
"disabled": false,
"autoApprove": []
}
}
}
Important:
- Replace
/absolute/path/to/openai-image-mcpwith the actual absolute path to your cloned repository - Replace
"your_openai_api_key_here"with your actual OpenAI API key
Claude Desktop
Location: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
Use the npx configuration format shown above.
API Key Configuration
The MCP server requires an OpenAI API key to function. There are two ways to provide this key:
-
Environment Variable: If you're running the server directly with
npm start, it will use the OPENAI_API_KEY from your.envfile. -
MCP Settings: When configuring the server in your MCP settings file, you need to provide the API key in the
envsection as shown above. This key will be passed to the server as an environment variable.
Usage
Once the MCP server is configured in Claude, you can use one of the four image generation tools to create images based on text prompts. Each tool is optimized for a specific OpenAI model.
Available Tools
1. generate_image_gpt - GPT-Image-1 Model
Generate images using OpenAI's gpt-image-1 model with advanced features like transparency and custom output formats.
Parameters:
prompt(required): A text description of the desired image (max 32,000 characters)output(required): File path where the generated image should be saved (e.g.,/path/to/image.png)size(optional): Image size. Options: "1024x1024", "1536x1024", "1024x1536", "auto". Default: "auto"quality(optional): Image quality. Options: "low", "medium", "high", "auto". Default: "auto"background(optional): Background transparency. Options: "transparent", "opaque", "auto". Default: "auto"output_format(optional): Output image format. Options: "png", "jpeg", "webp". Default: "png"output_compression(optional): Compression level (0-100) for webp/jpeg formats. Default: 100moderation(optional): Content moderation level. Options: "low", "auto". Default: "auto"n(optional): Number of images to generate (1-10). Default: 1
2. generate_image_gpt_mini - GPT-Image-1-Mini Model
Generate images using OpenAI's gpt-image-1-mini model. Cost-efficient alternative to gpt-image-1 with the same advanced features like transparency and custom output formats.
Parameters:
prompt(required): A text description of the desired image (max 32,000 characters)output(required): File path where the generated image should be saved (e.g.,/path/to/image.png)size(optional): Image size. Options: "1024x1024", "1536x1024", "1024x1536", "auto". Default: "auto"quality(optional): Image quality. Options: "low", "medium", "high", "auto". Default: "auto"background(optional): Background transparency. Options: "transparent", "opaque", "auto". Default: "auto"output_format(optional): Output image format. Options: "png", "jpeg", "webp". Default: "png"output_compression(optional): Compression level (0-100) for webp/jpeg formats. Default: 100moderation(optional): Content moderation level. Options: "low", "auto". Default: "auto"n(optional): Number of images to generate (1-10). Default: 1
3. generate_image_dalle3 - DALL-E 3 Model
Generate high-quality images using OpenAI's DALL-E 3 model with style control.
Parameters:
prompt(required): A text description of the desired image (max 4,000 characters)output(required): File path where the generated image should be savedsize(optional): Image size. Options: "1024x1024", "1792x1024", "1024x1792". Default: "1024x1024"quality(optional): Image quality. Options: "standard", "hd". Default: "standard"style(optional): Image style. Options: "vivid" (hyper-real and dramatic), "natural" (more natural, less hyper-real). Default: "vivid"
Note: DALL-E 3 can only generate 1 image at a time (n is always 1).
4. generate_image_dalle2 - DALL-E 2 Model
Generate images using OpenAI's DALL-E 2 model. Fast and cost-effective option.
Parameters:
prompt(required): A text description of the desired image (max 1,000 characters)output(required): File path where the generated image should be savedsize(optional): Image size. Options: "256x256", "512x512", "1024x1024". Default: "1024x1024"n(optional): Number of images to generate (1-10). Default: 1
Examples
Generate a logo with transparency (GPT-Image-1)
generate_image_gpt(
prompt="A minimalist geometric logo with circles and triangles",
output="/path/to/logo.png",
background="transparent",
output_format="png",
quality="high"
)
Generate a cost-efficient image (GPT-Image-1-Mini)
generate_image_gpt_mini(
prompt="A serene landscape with mountains and a lake at sunset",
output="/path/to/landscape.png",
quality="medium",
size="1024x1024"
)
Generate a high-quality artistic image (DALL-E 3)
generate_image_dalle3(
prompt="A peaceful zen garden with raked sand and carefully placed stones",
output="/path/to/zen_garden.png",
quality="hd",
style="natural"
)
Generate multiple variations (DALL-E 2)
generate_image_dalle2(
prompt="A vintage robot reading a newspaper",
output="/path/to/robot.png",
n=3,
size="512x512"
)
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.