ikamman/gemini-image-mcp
If you are the rightful owner of gemini-image-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Gemini Image MCP Server is a robust server designed for image analysis, generation, and editing using Google's Gemini API, integrated with the Model Context Protocol (MCP) for seamless client interactions.
Gemini Image MCP Server
A powerful MCP server for image analysis, generation, and editing using Google's Gemini API
Installation ⢠Usage ⢠API Reference ⢠Examples
⨠Features
- š¼ļø Image Analysis - Analyze images from URLs or local files using Gemini 2.5 Flash
- šØ Image Generation - Generate high-quality images from text prompts
- āļø Image Editing - Edit existing images with natural language instructions
- š Custom Prompts - Use system and user prompts for specific analysis needs
- š High Performance - Built with Rust for speed and reliability
- š”ļø Robust Error Handling - Comprehensive error handling and validation
- š” MCP Protocol - Seamless integration with MCP-compatible clients
- š Multi-Format Support - JPEG, PNG, GIF, WebP, and more
š Quick Start
Using npx (Recommended)
npx @ikamman/gemini-image-mcp --gemini-api-key "your-api-key"
Global Installation
npm install -g @ikamman/gemini-image-mcp
gemini-image-mcp --help
š¦ Installation
Prerequisites
- Gemini API Key: Get one here
- Node.js: 14+ (for npm installation)
- Rust: 1.70+ (for building from source)
Option 1: Install via npm (Automated with cargo-dist)
npm install -g @ikamman/gemini-image-mcp
Option 2: Build from Source
git clone https://github.com/ikamman/gemini-image-mcp.git
cd gemini-image-mcp
cargo build --release
š§ Configuration
Set your Gemini API key using one of these methods:
Environment Variable
export GEMINI_API_KEY="your-api-key-here"
Command Line Argument
gemini-image-mcp --gemini-api-key "your-api-key"
Using .env File
echo "GEMINI_API_KEY=your-api-key-here" > .env
š Usage
As MCP Server
The server communicates via JSON-RPC over stdio:
gemini-image-mcp
Integration with Claude Desktop
Using npx (No Installation Required)
Add to your claude_desktop_config.json
:
{
"mcpServers": {
"gemini-image-mcp": {
"command": "npx",
"args": ["@ikamman/gemini-image-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
Using Global Installation
First install globally:
npm install -g @ikamman/gemini-image-mcp
Then add to your claude_desktop_config.json
:
{
"mcpServers": {
"gemini-image-mcp": {
"command": "gemini-image-mcp",
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
Alternative: Using Full Path
For more reliability, you can use the full npx path:
{
"mcpServers": {
"gemini-image-mcp": {
"command": "/usr/local/bin/npx",
"args": ["@ikamman/gemini-image-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
Manual Testing
# Test image analysis
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"analyze_image","arguments":{"image_source":"https://example.com/image.jpg","user_prompt":"What do you see?"}}}' | gemini-image-mcp
# Test image generation
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"generate_image","arguments":{"user_prompt":"A sunset over mountains","output_path":"./sunset.png"}}}' | gemini-image-mcp
š API Reference
š analyze_image
Analyzes images using Google's Gemini API.
Parameters:
image_source
(required) - Image URL or local file pathsystem_prompt
(optional) - System instructions for analysisuser_prompt
(optional) - Analysis question (default: "Caption this image.")
Example:
{
"image_source": "https://example.com/photo.jpg",
"system_prompt": "You are a professional photographer.",
"user_prompt": "Analyze the composition and lighting of this image."
}
šØ generate_image
Generates images from text descriptions.
Parameters:
user_prompt
(required) - Description of the image to generateoutput_path
(required) - Path where the image should be savedsystem_prompt
(optional) - Additional generation guidelines
Example:
{
"user_prompt": "A cyberpunk cityscape at night with neon lights",
"output_path": "./generated_city.png",
"system_prompt": "Create a high-quality, detailed image."
}
āļø edit_image
Edits existing images using natural language instructions.
Parameters:
image_source
(required) - Source image URL or file pathuser_prompt
(required) - Editing instructionsoutput_path
(required) - Path for the edited imagesystem_prompt
(optional) - Additional editing guidelines
Example:
{
"image_source": "./my_photo.jpg",
"user_prompt": "Add a vintage filter and increase the warmth",
"output_path": "./edited_photo.jpg"
}
š” Examples
Image Analysis Examples
# Analyze a webpage screenshot
gemini-image-mcp analyze "https://example.com/screenshot.png" "What UI elements do you see?"
# Analyze a local photo
gemini-image-mcp analyze "./vacation.jpg" "Describe the location and activities"
# Technical analysis
gemini-image-mcp analyze "./chart.png" "Extract the key data points and trends"
Image Generation Examples
# Generate artwork
gemini-image-mcp generate "Abstract watercolor painting of a forest" "./forest.png"
# Generate technical diagrams
gemini-image-mcp generate "Network architecture diagram showing microservices" "./diagram.png"
# Generate marketing assets
gemini-image-mcp generate "Modern logo for a tech startup, minimalist design" "./logo.png"
Image Editing Examples
# Basic editing
gemini-image-mcp edit "./portrait.jpg" "Remove the background" "./portrait_nobg.png"
# Style changes
gemini-image-mcp edit "./photo.jpg" "Convert to black and white with high contrast" "./photo_bw.jpg"
# Object manipulation
gemini-image-mcp edit "./room.jpg" "Add a plant in the corner" "./room_with_plant.jpg"
šļø Supported Image Formats
Format | Extensions | Analysis | Generation | Editing |
---|---|---|---|---|
JPEG | .jpg , .jpeg | ā | ā | ā |
PNG | .png | ā | ā | ā |
GIF | .gif | ā | ā | ā |
WebP | .webp | ā | ā | ā |
ā” Performance & Limits
- Image Size: Up to 20MB per image
- Concurrent Requests: Handled via async Rust runtime
- Rate Limits: Follows Gemini API rate limits
- Response Time: Typically 2-10 seconds depending on image size and complexity
š ļø Development
Building from Source
git clone https://github.com/your-username/gemini-image-mcp.git
cd gemini-image-mcp
cargo build --release
Running Tests
cargo test
Testing with Sample Images
cargo test -- --nocapture
Project Structure
gemini-image-mcp/
āāā src/
ā āāā main.rs # Application entry point
ā āāā jsonrpc.rs # JSON-RPC handler
ā āāā gemini_client.rs # Gemini API client
ā āāā image_service.rs # Image processing service
ā āāā validation.rs # Input validation
ā āāā error.rs # Error handling
āāā test/ # Sample images for testing
āāā Cargo.toml # Rust dependencies & cargo-dist config
āāā .github/workflows/ # Automated CI/CD with cargo-dist
š¤ Contributing
We welcome contributions! Please see our for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
š License
This project is licensed under the MIT License - see the file for details.
š Troubleshooting
Common Issues
ā "Missing GEMINI_API_KEY"
export GEMINI_API_KEY="your-api-key-here"
ā "Image not found" for URLs
- Ensure the URL is publicly accessible
- Check your internet connection
- Verify the image format is supported
ā "Binary not found" after npm install
- Try reinstalling:
npm uninstall -g @ikamman/gemini-image-mcp && npm install -g @ikamman/gemini-image-mcp
- The binary is automatically managed by cargo-dist
ā Rate limit errors
- Wait a moment before retrying
- Consider implementing exponential backoff in your client
Getting Help
- š Documentation
- š Report Issues
- š¬ Discussions
š Acknowledgments
- Model Context Protocol - For the excellent MCP standard
- Google Gemini - For the powerful AI capabilities
- Rust MCP SDK - For the Rust implementation
Made with ā¤ļø using Rust and Google Gemini
ā Star this repo ⢠š Report Bug ⢠⨠Request Feature