The Gemini MCP Server allows Claude Desktop to generate images through Google's Gemini AI models. It acts as a connector that enables Claude to harness Gemini's image generation capabilities through the Model Context Protocol (MCP).
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
# Clone the repository
git clone https://github.com/Garblesnarff/gemini-mcp-server.git
cd gemini-mcp-server
# Build the Docker image
docker build -t gemini-mcp-server .
# Run the container
docker run -e GEMINI_API_KEY=your_api_key -e OUTPUT_DIR=/app/output -v $(pwd)/output:/app/output gemini-mcp-server
The setup wizard guides you through configuration:
After installation and configuration:
Claude will call the Gemini API and provide you with the path to the saved image.
Customize 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:
{
"apiKey": "YOUR_GEMINI_API_KEY_HERE",
"outputDir": "/path/to/your/output/directory",
"debug": true,
"modelOptions": {
"model": "gemini-2.0-flash-exp",
"temperature": 0.4
}
}
#!/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:
{
"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"
}
}
}
}
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 pathdocker run -e GEMINI_API_KEY=your_api_key -e OUTPUT_DIR=/app/output -v $(pwd)/output:/app/output gemini-mcp-server
GEMINI_API_KEY
: Your Google Gemini API key (required)OUTPUT_DIR
: Directory inside the container to save generated images (default: /app/output
)DEBUG
: Enable debug logging (default: false
)LOG_LEVEL
: Set log level (default: INFO
)~/Claude/logs/gemini-image-mcp.log
npx gemini-mcp-server --debug
Or set the environment variable:
export DEBUG=true
npx gemini-mcp-server
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.