home / mcp / mcp imagen server

MCP Imagen Server

An MCP server that uses Google Imagen API to generate images from text prompts, with style transfer and background removal.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "anton-proto-mcp-imagen": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/mcp-imagen-server",
        "run",
        "mcp-imagen-server"
      ],
      "env": {
        "USE_VERTEXAI": "true",
        "GOOGLE_API_KEY": "your-api-key-here",
        "GOOGLE_CLOUD_PROJECT": "your-project-id",
        "GOOGLE_CLOUD_LOCATION": "us-central1"
      }
    }
  }
}

You run an MCP Imagen Server to generate images from text prompts using Google's Imagen models, with optional style transfer and background removal. This server is designed to be used with MCP clients and supports multiple Imagen variants, flexible output options, and two authentication methods for quick starts or production readiness.

How to use

Start the server and connect via an MCP client to generate images, apply style transfers, remove backgrounds, or autocrop outputs. You can generate up to 4 images per request, choose from multiple Imagen variants, and output PNGs with optional transparency. Use an MCP client to send a request with your prompt, selected model, aspect ratio, and output location.

How to install

# Prerequisites
# - Python 3.11 or later
# - uvx command runner

# 1. Clone the repository and navigate to the server directory
git clone https://github.com/anton-proto/mcp-imagen.git
cd mcp-imagen/mcp-imagen-server

# 2. Install with uvx (the project uses uv to manage dependencies)
uv sync

# Or install in development mode with all extras
uv sync --all-extras

# 3. Start the server
uv run mcp-imagen-server

Configuration and authentication

You have two authentication options. For quick starts, use Gemini API by providing an API key. For production, use Vertex AI with Google Cloud credentials. You can supply these values through environment variables in your MCP client configurations.

# Gemini API (quick start)
export GOOGLE_API_KEY=your-api-key-here
```

```bash
# Vertex AI (production)
# Point to your Google Cloud project and location
export GOOGLE_CLOUD_PROJECT=your-project-id
export GOOGLE_CLOUD_LOCATION=us-central1
export USE_VERTEXAI=true

Run configurations for MCP clients (stdio)

The server runs as an MCP stdio service. You can configure your MCP client (for example, Claude Desktop) to start the server using uv from the command line, pointing to the server directory.

{
  "mcpServers": {
    "imagen": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/mcp-imagen-server",
        "run",
        "mcp-imagen-server"
      ],
      "env": {
        "GOOGLE_API_KEY": "your-api-key-here"
      }
    }
  }
}

Vertex AI integration example

{
  "mcpServers": {
    "imagen": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/mcp-imagen-server",
        "run",
        "mcp-imagen-server"
      ],
      "env": {
        "USE_VERTEXAI": "true",
        "GOOGLE_CLOUD_PROJECT": "your-project-id",
        "GOOGLE_CLOUD_LOCATION": "us-central1"
      }
    }
  }
}

Available tools

text-to-image

Generates images from text prompts using Google Imagen API. Supports multiple models, batch generation (1-4), and configurable aspect ratios.

style-to-image

Generates images following a reference style using Imagen 3 Customization. Requires a style image and a style description.

remove-background

Removes the background from images using the rembg AI model, producing PNGs with transparent backgrounds.

autocrop

Automatically crops images to remove transparent or empty borders with optional padding and parallel processing.