Sponsored by Deepsite.site

Gemini Image Generation MCP

Created By
collactivelabs6 months ago
A Model Calling Protocol (MCP) server that allows Claude and other LLMs to generate images using Google's Gemini AI model.
Content

Gemini Image Generation MCP

A Model Calling Protocol (MCP) server that allows Claude and other LLMs to generate images using Google's Gemini AI model.

Overview

This MCP server enables Large Language Models (LLMs) like Claude to delegate image generation tasks to Google's Gemini model. It follows the MCP standard to provide a seamless integration experience.

Features

  • Generate images from text prompts using Google's Gemini model (gemini-2.0-flash-preview-image-generation)
  • Save generated images locally
  • Configure generation parameters like temperature, topK, and topP
  • Interactive web interface for testing and demonstration
  • Docker support for easy deployment
  • Simple MCP standard implementation

Prerequisites

  • Node.js 18 or higher
  • Google API key with access to Gemini API (specifically the image generation preview model)
  • For Docker: Docker and Docker Compose

Getting Started

Installation

  1. Clone this repository:
git clone https://your-repository-url/gemini-image-gen-mcp.git
cd gemini-image-gen-mcp
  1. Install dependencies:
npm install
  1. Create your environment configuration:
cp .env.example .env
  1. Edit the .env file to add your Google API key:
GEMINI_API_KEY=your_gemini_api_key_here

Running the Server

Option 1: Using Node.js directly

For MCP server only:

node src/mcp-server.js

For web interface only:

node src/web-server.js

Or use the provided script:

# Run both MCP server and web interface
./start-server.sh --both

# Run MCP server only
./start-server.sh --mcp-only

# Run web interface only
./start-server.sh --web-only

# Default (MCP server only)
./start-server.sh

The web interface will be available at http://localhost:3070 (or the port specified in your .env file).

Option 2: Using Docker

docker-compose up -d

Web Interface

The project includes a web interface for testing and demonstrating the image generation capabilities:

  • Generator: Create images by entering text prompts and adjusting parameters
  • Gallery: View all previously generated images
  • About: Information about the project and its features

To access the web interface, navigate to http://localhost:3070 in your browser after starting the web server.

Usage with Claude

API Usage

When making API requests to Claude, include the MCP configuration:

{
  "mcpServers": {
    "openai-image-generation": {
      "command": "node",
      "args": ["/full/path/to/openai-image-gen-mcp/src/mcp-server.js"],
      "env": {
        "OPENAI_API_KEY": "your-openai-api-key-here"
      }
    }
  }
}

Claude Console Usage

  1. Go to Developer Settings
  2. Navigate to the MCPs section
  3. Click "Add MCP"
  4. Fill in the details:
    • Name: gemini_image_generation
    • URL: https://your-server-url.com/mcp
    • Authentication (if implemented): Select Bearer Token and enter your token

Gemini Image Generation API

This server uses the Gemini API for image generation. Specifically, it uses the gemini-2.0-flash-preview-image-generation model which is optimized for image generation tasks. The implementation follows Google's official API documentation for properly formatting requests and handling responses.

Key features of the Gemini image generation implementation:

  • Uses proper response modality for image generation
  • Handles base64-encoded image data from response
  • Provides enhanced prompts alongside generated images
  • Automatically saves generated images for later use

Configuration Options

The MCP server supports the following configuration options:

OptionDescriptionDefault
GEMINI_API_KEYGoogle API key with Gemini access(Required)
MCP_AUTH_TOKENAuthentication token for MCP(Optional)
PORTWeb server port3070
OUTPUT_DIRDirectory for saved images./generated-images
LOG_LEVELLogging level (debug, info, warn, error)info

License

ISC

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Playwright McpPlaywright MCP server
ChatWiseThe second fastest AI chatbot™
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
CursorThe AI Code Editor
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Serper MCP ServerA Serper MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Amap Maps高德地图官方 MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Tavily Mcp
DeepChatYour AI Partner on Desktop