mcp -gemini-image-generator
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.
claude mcp add --transport stdio qhdrl12-mcp-server-gemini-image-generator uv --directory /absolute/path/to/mcp-server-gemini-image-generator run mcp-server-gemini-image-generator \ --env GEMINI_API_KEY="your-gemini-api-key-here" \ --env OUTPUT_IMAGE_PATH="/absolute/path/to/your/images/directory"
How to use
Gemini Image Generator MCP Server exposes tools to create and transform images using Google's Gemini model. It offers a text-to-image capability and image transformation utilities, enabling AI assistants to generate new images from prompts, or modify existing images via file paths or base64-encoded inputs. The server handles prompt processing, translation, file naming, and local storage, so clients can obtain either raw image data or a path to the saved image. The main tools are: generate_image_from_text, which returns both the image bytes and the saved file path; transform_image_from_encoded, which applies a text prompt to a base64-encoded image and returns the transformed image bytes and its saved path; and transform_image_from_file, which performs the same transformation using a local image file path. These tools support both simple prompts and more complex edits, such as style changes, background alterations, or additions to the scene, with automatic filename generation and optional translation of non-English prompts. When integrating with an MCP client, you can request the image data directly or reference the saved file path for subsequent processing or display.
How to install
Prerequisites:
- Python 3.11 or newer
- Internet access to install dependencies
- An active Gemini API key from Google AI Studio
- An MCP host application (Claude Desktop, Cursor, or any MCP-compatible client)
Installation steps:
- Clone the repository and navigate to it
git clone https://github.com/your-username/mcp-server-gemini-image-generator.git
cd mcp-server-gemini-image-generator
- Create and activate a Python virtual environment (uv is recommended):
# Using uv (recommended)
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv install -e .
- Install dependencies and set up environment variables:
# Install in editable mode if using a local package
pip install -e .
- Set up environment variables (example methods):
- Option A: Use a .env file in project root with:
GEMINI_API_KEY=your-gemini-api-key-here
OUTPUT_IMAGE_PATH=/absolute/path/to/your/images/directory
- Option B: Configure directly in your MCP client (e.g., Claude Desktop config) with the same keys and values.
-
Configure your MCP client to run the server (example shown in Claude Desktop config below).
-
Start the MCP server via your chosen host. Ensure the OUTPUT_IMAGE_PATH directory exists and is writable.
Additional notes
Tips and caveats:
- Ensure OUTPUT_IMAGE_PATH is an absolute path and the process has write permissions to that directory.
- Keep your Gemini API key secure; rotate it per Google’s guidance and update the environment variable accordingly.
- The transform_image_from_encoded method may be slower due to base64 data transfer overhead; use transform_image_from_file when possible for better performance.
- If you encounter path resolution issues in clients like Claude Desktop, prefer transform_image_from_file with a local image path instead of encoded data.
- When using Smithery for installation, you can automate client setup, but you still need to provide a valid Gemini API key and image output directory.
- Respect API quotas on Gemini; implement basic rate limiting or caching in your MCP client to avoid hitting limits unexpectedly.
- For debugging, log the raw prompts, image paths, and any error messages from the Gemini API to help diagnose issues quickly.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP