Generate high-quality images from text prompts using Google's Gemini model through the MCP protocol.
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.
The server provides the following MCP tools for AI assistants:
generate_image_from_text
Creates a new image from a text prompt description.
generate_image_from_text(prompt: str) -> Tuple[bytes, str]
Parameters:
- prompt
: Text description of the image you want to generate
Returns:
- A tuple containing:
- Raw image data (bytes)
- Path to the saved image file (str)
Examples:
- "Generate an image of a sunset over mountains"
- "Create a photorealistic flying pig in a sci-fi city"
This image was generated using the prompt:
"Hi, can you create a 3d rendered image of a pig with wings and a top hat flying over a happy futuristic scifi city with lots of greenery?"
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) -> 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 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"
transform_image_from_file
Transforms an existing image file based on a text prompt.
transform_image_from_file(image_file_path: str, prompt: str) -> Tuple[bytes, str]
Parameters:
- image_file_path
: Path to the image file to be transformed
- prompt
: Text description of how you want to transform the 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"
Using the flying pig image created above, we applied a transformation with the following prompt:
"Add a cute baby whale flying alongside the pig"
Before:
After:
git clone https://github.com/your-username/gemini-image-generator.git
cd gemini-image-generator
# Using regular venv
python -m venv .venv
source .venv/bin/activate
pip install -e .
# Or using uv
uv venv
source .venv/bin/activate
uv pip install -e .
cp .env.example .env
.env
file to include your Google Gemini API key and preferred output path:GEMINI_API_KEY="your-gemini-api-key-here"
OUTPUT_IMAGE_PATH="/path/to/save/images"
Add the following to your claude_desktop_config.json
:
{
"mcpServers": {
"gemini-image-generator": {
"command": "uv",
"args": [\
"--directory",\
"/absolute/path/to/gemini-image-generator",\
"run",\
"server.py"\
],
"env": {
"GEMINI_API_KEY": "GEMINI_API_KEY",
"OUTPUT_IMAGE_PATH": "OUTPUT_IMAGE_PATH"
}
}
}
}
Once installed and configured, you can ask Claude to generate or transform images using prompts like:
You can test the application by running the FastMCP development server:
fastmcp dev server.py
This command starts a local development server and makes the MCP Inspector available at http://localhost:5173/.
MIT License
MCP server for AI image generation and editing using Google's Gemini Flash models. Create images from text prompts with intelligent filename generation and strict text exclusion. Supports text-to-image generation with future expansion to image editing capabilities.
No releases published
No packages published