OpenRouter Image Generation MCP Server
Enables image generation via OpenRouter API, supporting models like Gemini 2.5 Flash Image Preview with options to save files locally.
README
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
Installation
- Clone the repository:
git clone https://github.com/yourusername/openrouter-image-gen-mcp.git
cd openrouter-image-gen-mcp
- Install dependencies:
npm install
- Build the TypeScript code:
npm run build
- 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 generatemodel: 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 imagesshow_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:
- Your API key is correctly set in the environment or Claude Desktop config
- The API key starts with
sk-or-(OpenRouter format) - The API key is valid and has not expired
- 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_KEYis set in your Claude Desktop config'senvsection - 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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.