Gemini Image Generator MCP Server
Integrates with Google's Gemini AI model to generate and transform images from text prompts.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Gemini Image Generator MCP Servercreate an image of a futuristic city at dawn"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
This repo is fork from @qhdrl12/mcp-server-gemini-image-generator with new models and better visibility of errors.

Gemini Image Generator MCP Server
Generate high-quality images from text prompts using Google's Gemini model through the MCP protocol.
Overview
This MCP server allows any AI assistant to generate images using Google's Gemini AI model. The server handles prompt engineering, text-to-image conversion, filename generation, and local image storage, making it easy to create and manage AI-generated images through any MCP client.
Related MCP server: Gemini Image MCP
Features
Text-to-image generation using Gemini 2.5 Flash
Image-to-image transformation based on text prompts
Support for both file-based and base64-encoded images
Automatic intelligent filename generation based on prompts
Automatic translation of non-English prompts
Local image storage with configurable output path
Strict text exclusion from generated images
High-resolution image output
Direct access to both image data and file path
Available MCP Tools
The server provides the following MCP tools for AI assistants (uses only Gemini generate_content with gemini-2.5-flash-image):
1. generate_image_from_text
Creates a new image from a text prompt description.
generate_image_from_text(
prompt: str,
output_image_path: Optional[str] = None
) -> Tuple[bytes, str]Parameters:
prompt: Text description of the image you want to generateoutput_image_path(optional): Absolute directory path to save the image. If omitted, usesOUTPUT_IMAGE_PATHor~/gen_image.
Returns:
A tuple containing:
Raw image data (bytes)
Path to the saved image file (str)
This dual return format allows AI assistants to either work with the image data directly or reference the saved file path.
Examples:
"Generate an image of a sunset over mountains"
"Create a photorealistic picture of a fluffy ginger cat"
Pass a custom output directory (if your MCP client allows specifying arguments):
generate_image_from_text(
prompt="futuristic city at dawn",
output_image_path="/Users/username/Pictures/ai"
)Example Output
This image was generated using the prompt:
"A photorealistic picture of a fluffy ginger cat sitting on a wooden floor, looking directly at the camera. Soft, natural light from a window."
A photorealistic picture of a fluffy ginger cat sitting on a wooden floor, looking directly at the camera. Soft, natural light from a window.
Known Issues
When using this MCP server with Claude Desktop Host:
Performance Issues: Using
transform_image_from_encodedmay take significantly longer to process compared to other methods. This is due to the overhead of transferring large base64-encoded image data through the MCP protocol.Path Resolution Problems: There may be issues with correctly resolving image paths when using Claude Desktop Host. The host application might not properly interpret the returned file paths, making it difficult to access the generated images.
For the best experience, consider using alternative MCP clients or the transform_image_from_file method when possible.
2. transform_image_from_encoded
Transforms an existing image based on a text prompt using base64-encoded image data.
transform_image_from_encoded(
encoded_image: str,
prompt: str,
output_image_path: Optional[str] = None
) -> Tuple[bytes, str]Parameters:
encoded_image: Base64 encoded image data with format header (must be in format: "data:image/[format];base64,[data]")prompt: Text description of how you want to transform the imageoutput_image_path(optional): Absolute directory path to save the transformed image. If omitted, usesOUTPUT_IMAGE_PATHor~/gen_image.
Returns:
A tuple containing:
Raw transformed image data (bytes)
Path to the saved transformed image file (str)
Example:
"Add snow to this landscape"
"Change the background to a beach"
With custom output directory:
transform_image_from_encoded(
encoded_image="data:image/png;base64,iVBORw0K...",
prompt="add cinematic teal-orange grading",
output_image_path="/tmp/ai_out"
)3. transform_image_from_file
Transforms an existing image file based on a text prompt.
transform_image_from_file(
image_file_path: str,
prompt: str,
output_image_path: Optional[str] = None
) -> Tuple[bytes, str]Parameters:
image_file_path: Path to the image file to be transformedprompt: Text description of how you want to transform the imageoutput_image_path(optional): Absolute directory path to save the transformed image. If omitted, usesOUTPUT_IMAGE_PATHor~/gen_image.
Returns:
A tuple containing:
Raw transformed image data (bytes)
Path to the saved transformed image file (str)
Examples:
"Add a llama next to the person in this image"
"Make this daytime scene look like night time"
With custom output directory:
transform_image_from_file(
image_file_path="/Users/username/Pictures/input.png",
prompt="convert to watercolor style",
output_image_path="/Users/username/Pictures/ai_out"
)Example Transformation
Using the ginger cat image created above, we applied a transformation with the following prompt:
"Using the provided image of my cat, please add a small, knitted wizard hat on its head. Make it look like it's sitting comfortably and not falling off."Before:

After:

The original ginger cat with a hat
Setup
Prerequisites
Python 3.11+
Google AI API key (Gemini)
MCP host application (Claude Desktop App, Cursor, or other MCP-compatible clients)
Getting a Gemini API Key
Sign in with your Google account
Click "Create API Key"
Copy your new API key for use in the configuration
Note: The API key provides a certain quota of free usage per month. You can check your usage in the Google AI Studio
Installation
Manual Installation
Clone the repository:
git clone https://github.com/your-username/mcp-server-gemini-image-generator.git
cd mcp-server-gemini-image-generatorCreate a virtual environment and install dependencies:
# Using uv (recommended)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .
# Or using regular venv
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e .Set up environment variables (choose one method):
Method A: Using .env file (optional)
# Create .env file in the project root
cat > .env << 'EOF'
GEMINI_API_KEY=your-gemini-api-key-here
OUTPUT_IMAGE_PATH=/path/to/save/images
EOFMethod B: Set directly in Claude Desktop config (recommended)
Set environment variables directly in the
claude_desktop_config.json(shown in configuration section below)
Configure Claude Desktop
Add the following to your claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"gemini-image-generator": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp-server-gemini-image-generator",
"run",
"mcp-server-gemini-image-generator"
],
"env": {
"GEMINI_API_KEY": "your-actual-gemini-api-key-here",
"OUTPUT_IMAGE_PATH": "/absolute/path/to/your/images/directory"
}
}
}
}Important Configuration Notes:
Replace paths with your actual paths:
Change
/absolute/path/to/mcp-server-gemini-image-generatorto the actual location where you cloned this repositoryChange
/absolute/path/to/your/images/directoryto where you want generated images to be saved
Environment Variables:
Replace
your-actual-gemini-api-key-herewith your real Gemini API key from Google AI StudioUse absolute paths for
OUTPUT_IMAGE_PATHto ensure images are saved correctly
Example with real paths:
{
"mcpServers": {
"gemini-image-generator": {
"command": "uv",
"args": [
"--directory",
"/Users/username/Projects/mcp-server-gemini-image-generator",
"run",
"mcp-server-gemini-image-generator"
],
"env": {
"GEMINI_API_KEY": "GEMINI_API_KEY",
"OUTPUT_IMAGE_PATH": "OUTPUT_IMAGE_PATH"
}
}
}
}Usage
Once installed and configured, you can ask Claude to generate or transform images using prompts like:
Generating New Images
"Generate an image of a sunset over mountains"
"Create an illustration of a futuristic cityscape"
"Make a picture of a cat wearing sunglasses"
Transforming Existing Images
"Transform this image by adding snow to the scene"
"Edit this photo to make it look like it was taken at night"
"Add a dragon flying in the background of this picture"
The generated/transformed images will be saved to the provided output_image_path when specified, otherwise to your configured default path (OUTPUT_IMAGE_PATH or ~/gen_image). With the updated return types, AI assistants can also work directly with the image data without needing to access the saved files.
Testing
You can test the application by running the FastMCP development server:
fastmcp dev server.pyThis command starts a local development server and makes the MCP Inspector available at http://localhost:5173/. The MCP Inspector provides a convenient web interface where you can directly test the image generation tool without needing to use Claude or another MCP client. You can enter text prompts, execute the tool, and see the results immediately, which is helpful for development and debugging.
License
MIT License
Available Tools
3 toolsgenerate_image_from_textA
Generate an image based on the given text prompt using Google's Gemini model.
Args: prompt: User's text prompt describing the desired image to generate output_image_path: Optional path to save the generated image. If not provided, uses default path.
Returns: Path to the generated image file using Gemini's image generation capabilities
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | ||
| output_image_path | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description should disclose behavioral traits. It mentions using Gemini, but lacks details about side effects (e.g., file overwrite), required permissions, or error handling. For a tool without annotations, this is insufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and well-structured with 'Args:' and 'Returns:' sections. It is front-loaded with the main action. No unnecessary words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given two parameters, no annotations, and 0% schema coverage, the description covers parameters and return value. However, it lacks prerequisites (e.g., API key) and error scenarios, making it adequately but not fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must explain parameters. It defines 'prompt' as the user's text prompt and 'output_image_path' as an optional save path with default behavior, adding substantial meaning beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'generate' and the resource 'image from text prompt', and explicitly mentions using Google's Gemini model. Sibling tools like transform_image_from_encoded and transform_image_from_file are about image transformations, so this tool is distinct.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage when an image needs to be generated from a text prompt. It does not explicitly state when not to use it, but the sibling tools are for different purposes, so the context is clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
transform_image_from_encodedA
Transform an existing image based on the given text prompt using Google's Gemini model.
Args: encoded_image: Base64 encoded image data with header. Must be in format: "data:image/[format];base64,[data]" Where [format] can be: png, jpeg, jpg, gif, webp, etc. prompt: Text prompt describing the desired transformation or modifications output_image_path: Optional path to save the transformed image. If not provided, uses default path.
Returns: Path to the transformed image file saved on the server
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | ||
| encoded_image | Yes | ||
| output_image_path | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It discloses the use of Gemini model and that the output is saved to a server path. However, it does not mention any side effects, authentication requirements, rate limits, or error handling behavior. While the tool is likely non-destructive (creates a new file), more transparency about API calls and limitations would strengthen this dimension.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and well-structured. The first sentence immediately states the purpose, followed by a bullet-style list of arguments with clear explanations. Every sentence adds value, and there is no redundant or extraneous text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has 3 parameters, no output schema, and no annotations, the description provides solid coverage of inputs and the return value (path to transformed image). It could be slightly improved by mentioning default output path location or error scenarios, but overall it is sufficiently complete for an agent to understand and invoke the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has no descriptions (0% coverage), but the description compensates by detailing the required format for 'encoded_image' (data:image/[format];base64,[data]), explaining 'prompt' as describing desired transformations, and noting that 'output_image_path' is optional with a default. This adds significant meaning beyond the schema types and titles.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool transforms an existing image using a text prompt via Google's Gemini model. It identifies the specific input format (base64 encoded) and distinguishes from siblings: 'generate_image_from_text' creates images from text, while 'transform_image_from_file' uses a file path. The verb 'transform' and resource 'image' are precise.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implicitly indicates usage when an encoded image is available, but it lacks explicit guidance on when to use this tool versus alternatives like 'transform_image_from_file' or 'generate_image_from_text'. No exclusions or scenarios are provided. Context from sibling names helps, but the description itself does not offer clear when-to or when-not-to guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
transform_image_from_fileA
Transform an existing image file based on the given text prompt using Google's Gemini model.
Args: image_file_path: Path to the image file to be transformed prompt: Text prompt describing the desired transformation or modifications output_image_path: Optional path to save the transformed image. If not provided, uses default path.
Returns: Path to the transformed image file saved on the server
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | ||
| image_file_path | Yes | ||
| output_image_path | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses the use of Google's Gemini model, the optional output path, and the return of a file path. However, it does not clarify whether the original file is modified or if there are constraints like file size limits.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise, using a single introductory sentence followed by a well-structured argument list and return value description. It is front-loaded with the transformation purpose and uses no redundant text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the presence of an output schema and the tool's moderate complexity, the description covers core functionality and return type. It lacks details on error handling, file format support, or a note distinguishing from transform_image_from_encoded, which would improve completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must provide parameter meaning. It explains image_file_path, prompt, and output_image_path clearly, including the optional nature and default behavior, adding significant value beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool transforms an existing image file using a text prompt with Google's Gemini model. It specifies the verb (transform) and resource (existing image file), distinguishing it from sibling tools like generate_image_from_text and transform_image_from_encoded.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description does not provide explicit guidance on when to use this tool versus its siblings. It only describes what the tool does, leaving the agent to infer usage context without any exclusion or alternative recommendations.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
Each tool has a distinct purpose: one generates an image from a text prompt, and two transform existing images but accept different input formats (base64-encoded vs file path), leaving no ambiguity.
All tool names follow a consistent verb_noun pattern with snake_case (generate_image_from_text, transform_image_from_encoded, transform_image_from_file), making them predictable and easy to understand.
With 3 tools, the server is well-scoped for its purpose of image generation and transformation, covering the essential operations without being too sparse or bloated.
The tool set covers the primary workflows: generating from text and transforming images via two input methods. A minor gap is the lack of tools for listing or managing generated images, but the core functionality is complete.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Generate AI images and videos from any compatible MCP client.
AI image, video, voice and music generation over MCP, routed to Veo 3.1, Seedance 2.0 and more.
Generate images with any major model — one API key, one prepaid balance, one MCP.
Generate on-brand images from your AI agent: design, edit, and render templates over MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceAllows AI assistants to generate and transform high-quality images from text prompts using Google's Gemini model via the MCP protocol.334MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI-powered image generation and editing using Gemini and Imagen models, supporting text-to-image, image editing, and multi-image composition through MCP tools.MIT
- AlicenseAqualityDmaintenanceMCP server for Google Gemini image generation with configurable model support, enabling text-to-image generation, image editing, and iterative refinement.639MIT
- FlicenseNot gradedqualityDmaintenanceProvides image generation capabilities using Google's Gemini 2.0 Flash Preview model through the MCP protocol, enabling AI assistants to generate high-quality images from text prompts.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/olegfour3/mcp-server-gemini-image-generator'
If you have feedback or need assistance with the MCP directory API, please join our Discord server