Provides access to OpenAI's GPT-Image-1 model for high-quality image generation, featuring support for multiple resolutions, batch processing, and style control.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GPT-Image-1 MCP ServerGenerate a high-quality HD image of a cyberpunk city at sunset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GPT-Image-1 MCP Server
A Model Context Protocol (MCP) server that provides access to OpenAI's GPT-Image-1 model. This server enables high-quality image generation using OpenAI's latest image generation model with enhanced detail, richer lighting, and fewer artifacts.
š Repository: https://github.com/PierrunoYT/gpt-image-1-mcp-server
š Ready to use! Pre-built executable included - no compilation required.
ā Enhanced Reliability: Server handles missing API keys gracefully without crashes and includes robust error handling.
Features
High-Quality Image Generation: Uses OpenAI's GPT-Image-1 model
Automatic Image Download: Generated images are automatically saved to local
imagesdirectory as PNG filesMultiple Sizes: Support for 1024x1024, 1024x1536, and 1536x1024 resolutions
Batch Generation: Generate up to 4 images at once
Style Variations: Enhanced tool with style guidance support
Quality Control: Standard and HD quality options
Base64 Processing: Handles OpenAI's base64 image format automatically
Detailed Responses: Returns local file paths with generation metadata
Robust Error Handling: Graceful handling of missing API keys without server crashes
Universal Portability: Works anywhere with npx - no local installation required
Enhanced Reliability: Graceful shutdown handlers and comprehensive error reporting
Prerequisites
Node.js 18 or higher
OpenAI API key with access to GPT-Image-1 model
Installation
1. Get your OpenAI API Key
Visit OpenAI Platform
Sign up for an account or log in
Navigate to API Keys section
Generate an API key
Ensure you have access to the GPT-Image-1 model
2. Clone or Download
3. Install Dependencies (Optional)
The server is pre-built, but if you want to modify it:
Configuration
š Recommended: Universal npx Configuration (Works Everywhere)
Best option for portability - works on any machine with Node.js:
Benefits:
ā Universal Access: Works on any machine with Node.js
ā No Local Installation: npx downloads and runs automatically
ā Always Latest Version: Pulls from GitHub repository
ā Cross-Platform: Windows, macOS, Linux compatible
ā Settings Sync: Works everywhere you use your MCP client
Alternative: Local Installation
If you prefer to install locally, use the path helper:
This will output the complete MCP configuration with the correct absolute path.
For Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
For Kilo Code MCP Settings
Add to your MCP settings file at:
C:\Users\[username]\AppData\Roaming\Kilo-Code\MCP\settings\mcp_settings.json
Available Tools
gpt_image_1_generate
Generate images using OpenAI's GPT-Image-1 model with standard processing.
Parameters:
prompt(required): Text description of the image to generatesize(optional): "1024x1024", "1024x1536", or "1536x1024" (default: "1024x1024")n(optional): Number of images to generate, 1-4 (default: 1)
Response includes:
Local file paths for saved PNG images
Generation metadata (revised prompts if applicable)
File information and save status
gpt_image_1_generate_with_variations
Generate images using GPT-Image-1 with enhanced style control and quality options.
Parameters:
prompt(required): Text description of the image to generatesize(optional): "1024x1024", "1024x1536", or "1536x1024" (default: "1024x1024")n(optional): Number of images to generate, 1-4 (default: 1)style(optional): Style guidance for the image generationquality(optional): "standard" or "hd" (default: "standard")
Use this tool when:
You want to specify a particular artistic style
You need higher quality (HD) images
You want enhanced control over the generation process
Creating variations of a concept with different styles
Features:
Style-enhanced prompts for better artistic control
HD quality option for higher resolution details
Enhanced metadata in responses
š„ How Image Download Works
The GPT-Image-1 MCP server automatically processes and saves generated images to your local machine. Here's the complete process:
1. Image Generation Flow
API Call: Server calls OpenAI's GPT-Image-1 API
Response: OpenAI returns base64-encoded image data
Auto-Save: Server immediately converts and saves images as PNG files
Response: Returns local file paths and generation metadata
2. Base64 Processing Implementation
Save Function (saveBase64Image):
Filename Generation (generateImageFilename):
3. File Storage Details
Directory Structure:
Filename Format:
Prefix:
gpt_image_1_Prompt: First 50 chars, sanitized (alphanumeric + underscores)
Index: Image number (for multiple images)
Timestamp: ISO timestamp for uniqueness
Extension:
.png
4. Response Format
The server returns detailed information about saved images:
5. Benefits of Local Processing
ā
Persistent Storage: Images saved locally as standard PNG files
ā
Offline Access: View images without internet connection
ā
Organized Storage: All images in dedicated images directory
ā
Unique Naming: No filename conflicts with timestamp system
ā
Standard Format: PNG files compatible with all image viewers
ā
No URL Expiration: Local files never expire unlike temporary URLs
Example Usage
Basic Image Generation
With Specific Parameters
Advanced Usage with Style
Technical Details
Architecture
Language: TypeScript with ES2022 target
Runtime: Node.js 18+ with ES modules
Protocol: Model Context Protocol (MCP) SDK v1.0.0
API Client: OpenAI JavaScript SDK v4.0.0
Validation: Zod schema validation
API Model Used
Model:
gpt-image-1(OpenAI's latest image generation model)Response Format:
b64_json(base64-encoded PNG data)Supported Sizes: 1024x1024, 1024x1536, 1536x1024
Error Handling
Graceful API key handling: Server continues running even without OPENAI_API_KEY set
No crash failures: Removed
process.exit()calls that caused connection dropsNull safety checks: All tools validate API client availability before execution
Graceful shutdown: Proper SIGINT and SIGTERM signal handling
API error catching: Comprehensive error reporting with detailed context
File save error handling: Graceful fallback with detailed error messages
User-friendly messages: Clear error descriptions instead of technical crashes
Development
Project Structure
Scripts
npm run build- Compile TypeScript to JavaScriptnpm run dev- Watch mode for developmentnpm run start- Start the server directlynpm run test- Test server startup and basic functionalitynpm run get-path- Get configuration path for your system
Making Changes
Edit files in the
src/directoryRun
npm run buildto compileRestart your MCP client to use the updated server
Testing
This runs an OpenAI API connectivity test that verifies:
OpenAI API key is configured correctly
API connection is working
Available image generation models
GPT-Image-1 model access
API Costs
This server uses OpenAI's API, which charges per image generation. Check OpenAI pricing for current rates.
Typical costs (as of 2024):
GPT-Image-1: ~$0.04-0.08 per image depending on size and quality
HD quality images cost more than standard quality
Costs vary by resolution (1024x1024 vs 1536x1024)
Troubleshooting
Server not appearing in MCP client
Recommended: Use the npx configuration for universal compatibility
If using local installation, verify the path to
build/index.jsis correct and absoluteEnsure Node.js 18+ is installed:
node --versionTest server startup:
npm run testRestart your MCP client (Claude Desktop, Kilo Code, etc.)
Note: Server will start successfully even without OPENAI_API_KEY - check tool responses for API key errors
Image generation failing
Verify your OpenAI API key is valid and has sufficient credits
Ensure you have access to the GPT-Image-1 model (may require specific API tier)
Check that your prompt follows OpenAI's content policy
Try reducing the number of images or simplifying the prompt
Check the server logs for detailed error messages
Verify your account has image generation capabilities enabled
Build issues
If you need to rebuild the server:
Configuration issues
Use the helper script to get the correct path:
Support
For issues with:
This MCP server: Create an issue in this repository
OpenAI API: Check OpenAI documentation
MCP Protocol: See MCP documentation
License
MIT License - see LICENSE file for details.
Contributing
Fork the repository
Create a feature branch
Make your changes
Test with
npm run testSubmit a pull request
Changelog
v1.0.0 (Latest)
šØ Initial release with GPT-Image-1: Complete rewrite to use OpenAI's GPT-Image-1 model
š„ Automatic base64 processing: Generated images automatically converted and saved as PNG files
šļø Smart filename generation: Images saved with descriptive names including prompt and timestamp
š Enhanced tools: Two generation tools with different feature sets (basic and with variations)
š Auto-directory creation: Creates
imagesfolder automatically if it doesn't existš”ļø Robust error handling: Graceful handling of API errors and file save failures
šØ Style support: Enhanced tool with style guidance and quality control
š Universal portability: Updated for npx usage - works universally without local installation
ā Production ready: Comprehensive error handling and user-friendly messages
Migration from FAL Imagen 4
If you're migrating from the previous FAL Imagen 4 MCP server:
Update your configuration to use
OPENAI_API_KEYinstead ofFAL_KEYTool names changed:
imagen4_generateāgpt_image_1_generateimagen4_generate_asyncāgpt_image_1_generate_with_variations
Parameter changes:
aspect_ratioāsize(with specific resolution options)negative_promptā removed (not supported by GPT-Image-1)Added
qualityandstyleparameters for enhanced control
Response format: Now includes revised prompts and local PNG file paths
Image format: All images saved as PNG files instead of various formats