Skip to main content
Glama

GenImgMCP 🎨

Local MCP (Model Context Protocol) server for image generation and editing using the google/gemini-3.1-flash-image model via OpenRouter.

Designed specifically for coding agents (such as Antigravity, Claude Code, Cursor, and other MCP clients), saving images directly to the project's local file system and returning the file path and structured metadata in a lightweight manner (without cluttering the context window with Base64 strings).


✨ Features

  • πŸ–ΌοΈ Image Generation (generate_image): Create images from detailed text prompts.

  • πŸ–ŒοΈ Image Editing and Variations (edit_image): Transform, refine, or add elements to existing images on disk.

  • πŸ’Ύ Automatic Local Saving: Saves image files directly to the project directory requested by the agent (or in ./generated_images/).

  • ⚑ Lightweight & Efficient Response: Returns only the absolute file path and metadata (size, format, aspect ratio), preserving the caller LLM's context tokens.

  • πŸ“ Aspect Ratio & Format Control: Supports multiple aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9) and file formats (png, webp, jpeg).

  • πŸ”„ Model Flexibility: Defaults to google/gemini-3.1-flash-image, with support for any multimodal model available on OpenRouter.


Related MCP server: openrouter-imgen-mcp

πŸš€ Installation and Build

1. Prerequisites

2. Install Dependencies and Build

# In the project root:
npm install
npm run build

βš™οΈ Configuration

You can configure the API key in one of three ways:

  1. Environment Variable: Set OPENROUTER_API_KEY in your environment.

  2. .env File: Create a .env file in the root of the project:

    OPENROUTER_API_KEY=sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    DEFAULT_IMAGE_MODEL=google/gemini-3.1-flash-image
    DEFAULT_OUTPUT_DIR=./generated_images
  3. Command Line Argument: Pass --api-key <your_key> in arguments when starting the server.


πŸ› οΈ Available Tools

1. generate_image

Generates a new image based on a text prompt.

Parameter

Type

Required

Description

prompt

string

Yes

Detailed description of the image to generate.

output_path

string

No

File path where the image will be saved (e.g., ./assets/banner.png).

aspect_ratio

string

No

Aspect ratio of the image (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9). Default: 1:1.

output_format

string

No

File format (png, webp, jpeg). Default: png.

model

string

No

Model on OpenRouter (Default: google/gemini-3.1-flash-image).

2. edit_image

Modifies an existing image provided by local file path.

Parameter

Type

Required

Description

image_path

string

Yes

Source image path (e.g., ./assets/logo.png) or Data URL.

prompt

string

Yes

Modification instructions or elements to add.

output_path

string

No

Destination path for the edited image.

aspect_ratio

string

No

Desired aspect ratio for the resulting image.

output_format

string

No

Output file format (png, webp, jpeg).

model

string

No

Model on OpenRouter (Default: google/gemini-3.1-flash-image).


πŸ”Œ How to Integrate with MCP Clients

Configuration in Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "genimg": {
      "command": "node",
      "args": [
        "D:/MyProjs.Github/GenImgMCP/dist/index.js"
      ],
      "env": {
        "OPENROUTER_API_KEY": "sk-or-v1-your-key-here"
      }
    }
  }
}

Configuration in Antigravity / Cursor / MCP Config (mcp_config.json)

{
  "mcpServers": {
    "genimg": {
      "command": "node",
      "args": [
        "D:/MyProjs.Github/GenImgMCP/dist/index.js"
      ],
      "env": {
        "OPENROUTER_API_KEY": "sk-or-v1-your-key-here"
      }
    }
  }
}

πŸ§ͺ Testing the Server Locally

You can run the server directly in the terminal to verify startup:

node dist/index.js

The server will start and wait for JSON-RPC messages on the stdio channel.


πŸ“„ License

MIT

Available Tools

2 tools
edit_imageA

Edits or transforms an existing image from a local file and natural language instructions (add elements, change backgrounds, alter style, etc.).

Inputs: prompt (required), image_path (required), model, output_path, +2 more.

generate_imageA

Generates an image from a detailed text prompt using the Gemini 3.1 Flash Image model via OpenRouter. Saves the image locally and returns the absolute path and metadata.

Inputs: prompt (required), model, output_path, aspect_ratio, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 2 tools

    Disambiguation5/5

    generate_image and edit_image have clearly distinct purposes: one creates new images from a prompt, while the other transforms an existing local image. There is no meaningful overlap or ambiguity between the two tools.

    Naming Consistency5/5

    Both tools follow a consistent verb_noun pattern: generate_image and edit_image. The naming is predictable, clear, and uniform.

    Tool Count3/5

    Two tools is on the thin side for an image generation/editing server, even though both are core operations. The count is borderline but not unreasonable for a minimal focused toolset.

    Completeness4/5

    The server covers the two primary image operations: generation and editing. It lacks supporting operations like listing locally saved images or deleting them, but these are minor gaps that agents can work around using file paths.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers