Skip to main content
Glama
hz1ulqu01gmnZH4

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_imageB

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

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYesText description of the image to generate. Include style details (e.g., "photorealistic", "oil painting"), aspect ratio (e.g., "square image", "landscape"), and composition details directly in the prompt.
save_to_fileNoSave generated image to local file
filenameNoBase filename for saved image (without extension)
show_full_responseNoShow full response including base64 data (default: false)

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must shoulder the burden of behavioral disclosure. It fails to mention key traits such as authentication requirements, failure behavior, rate limits, or whether the image is returned as a URL or base64 data. The description only states the general function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no fluff, front-loaded with the main action. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description should compensate by explaining what the tool returns. It does not mention output format or any other contextual details required for correct usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds redundancy by repeating the prompt's role but adds no new meaning beyond the schema's detailed parameter descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Generate images using Google Gemini API' and explains how to control style, aspect ratio, and composition, distinguishing it from the sibling tool 'list_models'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use or not use this tool versus alternatives. Only one sibling exists, which serves a completely different purpose, so usage context is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_modelsB

Show information about the Gemini image generation model

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It implies a read-only operation but lacks details on return format, rate limits, or authentication needs. Minimum adequacy.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with verb and resource. No wasted words, but could be more accurate with plural form.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description does not explain what information is shown (e.g., model IDs, capabilities). Incomplete for a list tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters exist, so schema coverage is 100% trivially. The description adds meaning by explaining the tool's purpose, but no parameter-specific detail is needed. Baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description states 'Show information about the Gemini image generation model' which is a clear verb and resource. However, the singular phrasing may be confusing given the plural tool name and sibling 'generate_image'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. The sibling 'generate_image' is present but no comparison or conditions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.4/5.0
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
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hz1ulqu01gmnZH4/openrouter-image-gen-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server