home / mcp / gemini image mcp server
Provides image generation and editing via Gemini API through an MCP server and a JavaScript module for programmatic control.
Configuration
View docs{
"mcpServers": {
"jk7g14-gemini-image-mcp": {
"command": "claude",
"args": [
"mcp",
"add",
"--transport",
"stdio",
"gemini-image",
"--",
"node",
"server.js"
],
"env": {
"API_KEY": "YOUR_API_KEY"
}
}
}
}You can generate and edit images using Geminiโs API through a dedicated MCP server. This setup lets you run an MCP server locally and drive it from Claude Code or use a JavaScript module to create, edit, and manage multi-step image workflows with ease.
You can interact with the Gemini image MCP server in two ways. First, register the MCP server with Claude Code to run in stdio mode, then issue natural language requests like generating a cat image or editing it. Second, use the JavaScript module to call the image generation and editing functions directly from your code. The MCP server supports multiple tools for image creation and editing, including multi-turn sessions.
Prerequisites: ensure Node.js and npm are installed on your machine.
cd gemini-image-mcp
npm installSet up your Gemini API key to enable image generation and editing. Create a local environment file and place your actual API key in it.
cp .env.example .env
# Put your actual API key in the .env fileRegister and run the MCP server using Claude Code. This starts a stdio-based MCP server named gemini-image that communicates through the Claude runtime.
claude mcp add --transport stdio gemini-image -- node server.jsYou can drive image generation, editing, and multi-turn sessions directly from JavaScript. Import the functions from the module and call them with prompts and outputs.
import { generateImage, editImage, createSession } from './gemini-image.js';
// Image generation
await generateImage('cat', { output: './cat.png' });
// Image editing
await editImage('./cat.png', 'change background to space', { output: './cat-space.png' });
// Multi-turn session
const session = createSession();
await session.send('mountain landscape', { output: './v1.png' });
await session.send('add a lake', { output: './v2.png' });
await session.sendWithImage('./photo.png', 'change style', { output: './v3.png' });The MCP server exposes a set of image-related tools to perform generation, editing, and session-based workflows.
- generate_image: Create an image from text prompts.
- edit_image: Edit an existing image using a prompt.
- start_image_session: Begin a multi-turn editing session.
- continue_image_session: Continue a multi-turn editing session.
- get_image_config_info: Retrieve current configuration options for images.
Create an image from a text prompt and save it to a specified output path.
Edit an existing image using a prompt and save the result to a specified output path.
Start a multi-turn image editing session to iteratively refine results.
Begin a multi-turn editing session (alternate entry point for starting sessions).
Continue a multi-turn editing session by sending additional prompts.
Query available configuration options for image generation and editing.