Gemini Claude Integration
STDIOMCP server enabling Claude Desktop to generate images using Google's Gemini AI models.
MCP server enabling Claude Desktop to generate images using Google's Gemini AI models.
A Model Context Protocol (MCP) server that enables Claude Desktop to generate images using Google's Gemini AI models.
npm install -g gemini-mcp-server # Run the setup wizard npx gemini-mcp-setup
# Create a directory for the server mkdir gemini-mcp-server cd gemini-mcp-server # Install locally npm install gemini-mcp-server # Run the setup wizard npx gemini-mcp-setup
You can also run the Gemini MCP server using Docker:
# Build the Docker image docker build -t gemini-mcp-server . # Run the Docker container docker run -e GEMINI_API_KEY="your-api-key" -e OUTPUT_DIR="/app/output" -v /path/on/host:/app/output gemini-mcp-server
The setup wizard will guide you through the configuration process:
If you prefer manual setup, see the Manual Configuration section below.
Once installed and configured, restart Claude Desktop to enable the Gemini MCP server. Then:
Claude will call the Gemini API to generate the image and provide you with the path to the saved image file.
You can customize the image generation with additional parameters:
Example: "Generate an image of a cyberpunk city with neon lights in a realistic style with temperature 0.7"
If you prefer not to use the setup wizard, follow these steps:
Create a JSON configuration file with your settings:
{ "apiKey": "YOUR_GEMINI_API_KEY_HERE", "outputDir": "/path/to/your/output/directory", "debug": true, "modelOptions": { "model": "gemini-2.0-flash-exp", "temperature": 0.4 } }
Create a bash script to run the server:
#!/bin/bash # Set environment variables export GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE" export OUTPUT_DIR="/path/to/your/output/directory" export DEBUG="true" # Execute the server exec "$(which node)" "$(npm root -g)/gemini-mcp-server/bin/gemini-mcp-server.js"
Make the script executable:
chmod +x gemini-mcp-wrapper.sh
Edit your ~/.config/claude/claude_desktop_config.json
file to add the Gemini MCP server:
{ "mcpServers": { "gemini-image": { "command": "/bin/bash", "args": [ "-c", "/path/to/your/gemini-mcp-wrapper.sh" ], "env": { "GEMINI_API_KEY": "YOUR_GEMINI_API_KEY_HERE", "DEBUG": "true" } } } }
This MCP server includes a Dockerfile for easy deployment and sharing. The Docker image is configured to:
/app/output
docker build -t gemini-mcp-server .
docker run \ -e GEMINI_API_KEY="your-api-key" \ -e OUTPUT_DIR="/app/output" \ -e DEBUG="false" \ -v /path/on/host:/app/output \ gemini-mcp-server
When running the Docker container, you can configure the server using these environment variables:
GEMINI_API_KEY
: Your Google Gemini API key (required)OUTPUT_DIR
: Directory to save generated images (default: /app/output
)DEBUG
: Enable debug logging (default: false
)When using the Docker container with Claude Desktop, you'll need to:
gemini-mcp-server [options]
Options:
-k, --api-key <key>
: Google Gemini API key-o, --output-dir <dir>
: Directory to save generated images-d, --debug
: Enable debug logging-c, --config <path>
: Path to custom configuration file-r, --reset-config
: Reset configuration to defaults-v, --version
: Display version informationGEMINI_API_KEY
: Your Google Gemini API keyOUTPUT_DIR
: Directory to save generated imagesDEBUG
: Enable debug logging (true
or false
)LOG_LEVEL
: Set log level (ERROR
, WARN
, INFO
, or DEBUG
)GEMINI_LOG_FILE
: Custom log file pathOption | Description | Default |
---|---|---|
apiKey | Google Gemini API key | (required) |
outputDir | Directory to save generated images | ~/Claude/gemini-images |
debug | Enable debug logging | false |
modelOptions.model | Gemini model to use | gemini-2.0-flash-exp |
modelOptions.temperature | Control creativity/randomness | 0.4 |
modelOptions.topK | Top-k sampling parameter | 32 |
modelOptions.topP | Top-p sampling parameter | 1 |
modelOptions.maxOutputTokens | Maximum output tokens | 8192 |
~/Claude/logs/gemini-image-mcp.log
This usually means Claude is trying to call a method that the MCP server doesn't support. Check the logs to see what method was requested.
docker logs [container-id]
Enable debug mode for more detailed logs:
npx gemini-mcp-server --debug
Or set the environment variable:
export DEBUG=true npx gemini-mcp-server
MIT