A Model Context Protocol (MCP) server that provides Google Gemini image generation capabilities, specifically supporting the Imagen 4 model for high-quality image generation with enhanced text rendering and detailed imagery.
- Imagen 4 Support: Generate high-quality images using Google's latest Imagen 4 model
- Multiple Models: Support for both standard and ultra versions of Imagen 4
- Flexible Parameters: Configurable aspect ratios, number of images, and person generation settings
- Automatic File Management: Images are automatically saved to your Desktop
- TypeScript: Full TypeScript support with proper type definitions
- MCP Protocol: Seamless integration with MCP-compatible clients
- Clone this repository
- Install dependencies:
npm install
- Build the project:
npm run build
- Get a Google API key from the Google Cloud Console
- Enable the Generative AI API for your project
- Start the MCP server
- Use the
configure-server
tool to set your API key before generating images- Note: Your API key will be automatically saved to
~/.mcp-gemini-image.json
for future use
- Note: Your API key will be automatically saved to
npm start
Generate images using Google Gemini Imagen 4.
Parameters:
prompt
(required): Text description of the desired imagemodel
(optional): Choose betweenimagen-4.0-generate-preview-06-06
(default) orimagen-4.0-ultra-generate-preview-06-06
aspect_ratio
(optional):square
,portrait
, orlandscape
(default:square
)num_images
(optional): Number of images to generate (1-4 for standard, 1 for ultra) (default: 1)person_generation
(optional):dont_allow
,allow_adult
, orallow_all
(default:allow_adult
)filename
(optional): Custom filename for the saved image
Example:
{
"prompt": "A serene mountain landscape with a crystal clear lake reflecting the snow-capped peaks at sunset",
"model": "imagen-4.0-generate-preview-06-06",
"aspect_ratio": "landscape",
"num_images": 2
}
Configure Google API credentials.
Parameters:
api_key
(required): Your Google API keyproject_id
(optional): Your Google Cloud project ID
Note: Credentials are automatically saved to ~/.mcp-gemini-image.json
and will persist between server restarts.
Example:
{
"api_key": "your-google-api-key"
}
Check the current configuration status of the server.
Returns:
- Configuration status
- Available models
- Image save directory
List all supported Google Gemini image generation models with their capabilities.
Returns:
- Model details
- Maximum number of images per model
- Model features
- Max Images: 1-4 per request
- Features: High-quality, detailed images with good lighting
- Best for: General image generation, multiple variations
- Max Images: 1 per request
- Features: Enhanced quality and detail, premium version
- Best for: High-quality single images, professional use
Images are automatically saved to:
- Directory:
~/Desktop/gemini-images/
- Format: PNG files with timestamp
- Metadata: JSON files with generation parameters
The server provides comprehensive error handling for:
- Invalid API credentials
- Model parameter validation
- Network connectivity issues
- File system errors
npm run build
: Build the TypeScript projectnpm run dev
: Watch mode for developmentnpm run clean
: Clean build directory
src/
├── index.ts # Main entry point
├── server.ts # MCP server implementation
├── config-manager.ts # Configuration management
├── image-generator.ts # Google Gemini API integration
├── file-manager.ts # File operations
└── types.ts # TypeScript definitions
- Node.js 18.0.0 or later
- Google API key with Generative AI API enabled
- TypeScript 5.0.0 or later
MIT License
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
For issues and questions, please open an issue on the GitHub repository.
- Initial release with Imagen 4 support
- Basic image generation functionality
- Configuration management
- File management system