Skip to main content
Glama
OpenRouter Image Generation MCP Server

OpenRouter Image Generation MCP Server

OpenRouter Image Generation MCP Server

An MCP (Model Context Protocol) server that provides image generation capabilities through the OpenRouter API, supporting models like Gemini 2.5 Flash Image Preview.

Features

  • Image Generation: Generate images using Google Gemini 2.5 Flash Image Preview

  • Flexible Options:

    • Save generated images to local files

Related MCP server: OpenRouter MCP Multimodal Server

Installation

  1. Clone the repository:

git clone https://github.com/yourusername/openrouter-image-gen-mcp.git
cd openrouter-image-gen-mcp
  1. Install dependencies:

npm install
  1. Build the TypeScript code:

npm run build
  1. Set up your OpenRouter API key:

export OPENROUTER_API_KEY="your-api-key-here"

You can get an API key from OpenRouter.

Configuration for Claude Desktop

Add the following to your Claude Desktop configuration file:

macOS/Linux

Location: ~/.config/claude/claude_desktop_config.json

Windows

Location: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "openrouter-image-gen": {
      "command": "node",
      "args": ["/path/to/openrouter-image-gen-mcp/dist/index.js"],
      "env": {
        "OPENROUTER_API_KEY": "your-api-key-here"
      }
    }
  }
}

Replace /path/to/openrouter-image-gen-mcp with the actual path to your installation directory.

Available Tools

1. generate_image

Generate images using AI models.

Parameters:

  • prompt (required): Text description of the image to generate

  • model: Model to use (default: google/gemini-2.5-flash-image-preview:free)

  • n: Number of images to generate (1-4, default: 1)

  • size: Image dimensions (default: 1024x1024)

  • save_to_file: Save images locally (default: false)

  • filename: Base filename for saved images

  • show_full_response: Include full base64 data in response (default: false, returns concise info only)

Example:

{
  "prompt": "A serene Japanese garden with cherry blossoms",
  "model": "google/gemini-2.5-flash-image-preview:free",
  "save_to_file": true,
  "filename": "japanese_garden"
}

Note: Gemini image generation works through the chat completions API. The model will generate an image based on your prompt and return it as a URL or base64 data in the response. The size parameter is not used for Gemini models.

2. list_models

List all available image generation models.

Development

Build

npm run build

Run in development mode

npm run dev

Start the server

npm start

API Documentation

Troubleshooting

401 Authentication Error

If you get a 401 error, check:

  1. Your API key is correctly set in the environment or Claude Desktop config

  2. The API key starts with sk-or- (OpenRouter format)

  3. The API key is valid and has not expired

  4. You have credits available in your OpenRouter account

Test your API key loading:

node test-api-key.js

Common Issues

  • API Key not loading: Make sure the OPENROUTER_API_KEY is set in your Claude Desktop config's env section

  • Model access denied: Some models require specific permissions or higher tier accounts

  • Image not generating for Gemini: Gemini uses the chat completions endpoint, not the images endpoint

License

WTFPL - Do What The Fuck You Want To Public License

Contributing

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

Available Tools

2 tools
generate_imageA

Generate images using Google Gemini API. Control image style, aspect ratio, and composition through descriptive text in your prompt.

Inputs: prompt (required), save_to_file, filename, show_full_response.

list_modelsB

Show information about the Gemini image generation model

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: one generates images and the other lists available models. There is no overlap or ambiguity.

    Naming Consistency5/5

    Both tool names follow a consistent verb_noun pattern (generate_image, list_models), making them predictable and easy to understand.

    Tool Count3/5

    With only two tools, the server feels thin for an image generation service. While the core generation tool is present, the set may lack additional functionality like retrieving generation history or managing images, making it borderline.

    Completeness3/5

    The server covers the basic generate operation and model listing, but is missing potential features such as model selection parameter in generation, image deletion, or error handling details. This feels incomplete for a full image generation workflow.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers