Get the FREE Ultimate OpenClaw Setup Guide →

gemini

Generate images using gemini

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio sanxfxteam-gemini-mcp-server npx -y github:sanxfxteam/gemini-mcp-server \
  --env GEMINI_API_KEY="your_api_key_here"

How to use

The Gemini Image Generation MCP Server exposes image generation capabilities via Google Gemini 2's experimental image generation API. It is designed to work with the Model Context Protocol (MCP) and can be launched through an npx-based setup, using your Gemini API key to authenticate requests. Once running, you can send MCP requests to the server to generate images by invoking the generateImage tool with a textual prompt and optional parameters like the number of samples, aspect ratio, and generation policies. The server communicates over stdio according to MCP conventions, so it can be wired into Claude Desktop or other MCP-compliant clients.

To use it, configure your MCP client to point at the gemini-imagen server (for example via Claude Desktop’s MCP configuration). Provide your Gemini API key as an environment variable (GEMINI_API_KEY) when starting the server. The Available Tools section describes the supported tool and its parameters. You can adjust prompt, aspect ratio, and the number of samples to tailor the output, and you can rely on the tool to return generated image data in the MCP response format.

How to install

Prerequisites:

  • Node.js and npm installed on your machine
  • Access to a Gemini API key from Google (Gemini API)

Step 1: Install dependencies and set up the project

# Ensure you have npm installed
node -v
npm -v

# If you are cloning a repository locally, install dependencies (example path):
# npm install

Step 2: Obtain and provide your Gemini API key

  • Get your API key from Google AI Studio (Makersuite) and keep it handy.
  • Store the key in an environment variable (recommended) or place it in a .env file at the project root:
GEMINI_API_KEY=your_api_key_here

Step 3: Run the MCP server

# Using npx as in the Quick Start configuration
npx -y github:sanxfxteam/gemini-mcp-server

Step 4: (Optional) Configure MCP client to connect to the server

  • If using Claude Desktop, add the following to your claude_desktop_config.json under mcpServers:
{
  "mcpServers": {
    "gemini-imagen": {
      "command": "npx",
      "args": ["-y", "github:sanxfxteam/gemini-mcp-server"],
      "env": {
        "GEMINI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Additional notes

Notes:

  • This server uses Gemini 2's experimental image generation API; access and behavior may vary as the API evolves.
  • Ensure your Gemini API key has appropriate permissions for image generation.
  • The server implements MCP over stdio; you can test it with MCP tooling or clients that support the protocol.
  • When testing, you can use the generateImage tool with prompts and optional parameters such as numSamples, aspectRatio, and personGeneration to control output.
  • If you encounter rate limits or authentication errors, verify the API key is correctly set in the environment and that the key is active for image generation features.

Related MCP Servers

Sponsor this space

Reach thousands of developers