使用说明
Gemini Image Generator MCP Server
A Model Context Protocol (MCP) server that generates images using Google's Gemini AI.
Installation
Via npx (recommended)
npx gemini-image-mcp
Via npm (global install)
npm install -g gemini-image-mcp
gemini-image-mcp
From source
git clone https://github.com/YOUR_USERNAME/gemini-image-mcp.git
cd gemini-image-mcp
npm install
npm run build
npm start
Features
- generate_image: Generate an image from a text prompt and save it to a file
- generate_image_base64: Generate an image and return it as base64 encoded data
Prerequisites
- Node.js 18+
- A Google AI API key (get one from Google AI Studio)
Configuration
Set your API key as an environment variable:
# Windows PowerShell
$env:GEMINI_API_KEY = "your-api-key-here"
# Windows CMD
set GEMINI_API_KEY=your-api-key-here
# Linux/macOS
export GEMINI_API_KEY="your-api-key-here"
Or use GOOGLE_API_KEY instead.
Integration with Claude Desktop
Add the following to your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Using npx
{
"mcpServers": {
"gemini-image": {
"command": "npx",
"args": ["-y", "gemini-image-mcp"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
Using local installation
{
"mcpServers": {
"gemini-image": {
"command": "node",
"args": ["C:\\path\\to\\gemini-image-mcp\\dist\\index.js"],
"env": {
"GEMINI_API_KEY": "your-api-key-here"
}
}
}
}
Testing with MCP Inspector
npx @modelcontextprotocol/inspector npx gemini-image-mcp
Or from source:
npm run inspector
Tool Reference
generate_image
Generates an image and saves it to a file.
Parameters:
prompt(required): The text description of the image to generateoutputPath(optional): Where to save the image. Defaults togenerated_image_<timestamp>.png
Example:
Generate an image of a futuristic city at sunset
generate_image_base64
Generates an image and returns it as base64 data.
Parameters:
prompt(required): The text description of the image to generate
Example:
Create a picture of a nano banana dish in a fancy restaurant
Publishing to npm
-
Create an npm account at npmjs.com
-
Login to npm:
npm login
- Publish:
npm publish
License
MIT