๐ผ๏ธ๐ค OpenRouter Image MCP Server
๐ฅ Supercharge your AI agents with powerful image analysis capabilities! ๐ฅ
A blazing-fast โก MCP (Model Context Protocol) server that enables AI agents to see and understand images using OpenRouter's cutting-edge vision models. Perfect for screenshots, photos, diagrams, and any visual content! ๐ธโจ
๐ What Makes This Special?
- ๐ฏ Multi-Model Support: Choose from Claude, Gemini, GPT-4 Vision, and more!
- ๐ Lightning Fast: Built with TypeScript and optimized for performance
- ๐ง Flexible Input: Support for file paths, URLs, and base64 data
- ๐ฐ Cost-Effective: Smart model selection for the best price-to-quality ratio
- ๐ก๏ธ Production Ready: Robust error handling, retries, and comprehensive logging
- ๐จ Easy Integration: Works seamlessly with Claude Code, Cline, Cursor, and more!
๐ Quick Start
Prerequisites ๐
- Node.js 18+ โก
- OpenRouter API Key ๐ (Get one at openrouter.ai)
- Your favorite MCP client ๐ค (Claude Code, Cline, etc.)
Installation ๐ฆ
bash# ๐ Option 1: Use immediately with npx (recommended) npx openrouter-image-mcp # ๐ Option 2: Install globally for frequent use npm install -g openrouter-image-mcp # ๐ ๏ธ Option 3: Clone and build locally git clone https://github.com/JonathanJude/openrouter-image-mcp.git cd openrouter-image-mcp npm install npm run build npm install -g .
๐ก Why npx is recommended: No installation required, always gets the latest version, and works perfectly for MCP server usage!
Configuration โ๏ธ
The MCP server requires an OpenRouter API key. You can configure it in several ways:
Method 1: Environment Variables (Recommended)
bash# ๐ Set your API key export OPENROUTER_API_KEY=sk-or-v1-your-api-key-here # ๐ฏ Set model (uses free model by default) export OPENROUTER_MODEL=google/gemini-2.0-flash-exp:free
Method 2: .env File
bash# ๐ Copy the environment template cp .env.example .env # โ๏ธ Edit with your credentials nano .env
Add your OpenRouter credentials to .env:
bash# ๐ Required OPENROUTER_API_KEY=sk-or-v1-your-api-key-here # ๐ Model (FREE by default - great for getting started!) OPENROUTER_MODEL=google/gemini-2.0-flash-exp:free # ๐๏ธ Optional settings LOG_LEVEL=info MAX_IMAGE_SIZE=10485760 RETRY_ATTEMPTS=3
Method 3: Direct Configuration in MCP Client
Add the API key directly in your MCP client configuration (see examples below).
๐ Works Locally - No Restarts Needed! ๐ฏ
๐ HUGE ADVANTAGE: This MCP server works perfectly locally with zero manual intervention once configured! No restarts, no manual server starts, no fiddling with settings. It just works! โจ
๐ How It Works Automatically
- ๐ฏ Configure once โ Set up your MCP client one time
- ๐ Auto-launches โ Client starts the server automatically
- ๐ง Connects โ Validates API and loads models instantly
- ๐ ๏ธ Ready to use โ All 3 tools available immediately
โก Local Setup Benefits
- ๐ฅ Fire-and-forget: Set up once, forget forever
- โก Lightning startup: ~5 seconds total ready time
- ๐ Persistent across restarts: Survives laptop shutdowns
- ๐ฑ Cross-platform: Works on any OS with Node.js
- ๐ฏ Zero maintenance: No babysitting required
๐ง MCP Configuration
Option 1: Using npx (Recommended - No Installation Required)
The easiest way to use this MCP server is with npx, which automatically downloads and runs the package without any installation:
For Claude Code
Add to ~/.claude.json:
json{ "mcp": { "servers": { "openrouter-image": { "command": "npx", "args": ["openrouter-image-mcp"], "env": { "OPENROUTER_API_KEY": "sk-or-v1-your-api-key-here", "OPENROUTER_MODEL": "google/gemini-2.0-flash-exp:free" } } } } }
For Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
json{ "mcpServers": { "openrouter-image": { "command": "npx", "args": ["openrouter-image-mcp"], "env": { "OPENROUTER_API_KEY": "sk-or-v1-your-api-key-here", "OPENROUTER_MODEL": "google/gemini-2.0-flash-exp:free" } } } }
For Other MCP Clients
- Cursor:
~/.cursor/mcp.json - Cline:
~/.cline/mcp.json - Windsurf: MCP settings file
- Other agents: Check your agent's MCP documentation
โจ Benefits of npx:
- ๐ No installation needed - works immediately
- ๐ Always latest version - automatically updates
- ๐ฑ Cross-platform - works everywhere Node.js is installed
- ๐งน Clean system - no global packages required
Option 2: Global Installation (For Frequent Users)
If you plan to use this MCP server frequently, install it globally:
bashnpm install -g openrouter-image-mcp
Then use this configuration:
json{ "mcp": { "servers": { "openrouter-image": { "command": "openrouter-image-mcp", "env": { "OPENROUTER_API_KEY": "sk-or-v1-your-api-key-here", "OPENROUTER_MODEL": "google/gemini-2.0-flash-exp:free" } } } } }
Benefits of global installation:
- โก Faster startup - no download time
- ๐ Works offline - once installed
- ๐ง Simpler command - shorter configuration
Option 3: Local Development
If you cloned the repo locally for development:
json{ "mcpServers": { "openrouter-image": { "command": "node", "args": ["/path/to/openrouter-image-mcp/dist/index.js"], "env": { "OPENROUTER_API_KEY": "sk-or-v1-your-api-key-here", "OPENROUTER_MODEL": "google/gemini-2.0-flash-exp:free" } } } }
๐ฏ Pro Tip: Replace the API key with your actual OpenRouter key. The free model works great for most use cases!
๐ก Recommendation: Start with npx (Option 1) - it's the easiest and most reliable way to get started!
๐ก Pro Tips for Local Setup
๐ฏ Path Management
- Absolute paths work best:
/path/to/openrouter-image-mcp/dist/index.js - Avoid relative paths: May break when switching directories
- Use your actual path: Update the examples with your real project location
๐ง Environment Variables
- Set in
.envfile: Keep your API key secure - OR set in system:
export OPENROUTER_API_KEY=sk-or-v1-... - Test quickly: Run
OPENROUTER_API_KEY=... node dist/index.js
๐ Quick Verification
bash# ๐ Test if server works export OPENROUTER_API_KEY=sk-or-v1-your-key export OPENROUTER_MODEL=google/gemini-2.5-flash-lite-preview-09-2025 node dist/index.js # โ Should see logs: "Starting OpenRouter Image MCP Server"
๐ Troubleshooting Local Issues
โ "Command not found"
bash# โ Use absolute path to node "$(which node)" "/path/to/openrouter-image-mcp/dist/index.js"
โ "File not found"
bash# โ Verify the built file exists ls -la /path/to/openrouter-image-mcp/dist/index.js # ๐ Rebuild if missing npm run build
โ "API key required"
bash# โ Check your environment variables echo $OPENROUTER_API_KEY # ๐ง Or create .env file echo "OPENROUTER_API_KEY=sk-or-v1-your-key" > .env
๐ Local Development Workflow
- ๐ ๏ธ Build once:
npm run build - โ๏ธ Configure once: Add MCP config to your AI agent
- ๐ Restart agent: Pick up the new configuration
- ๐ฏ Use immediately: No manual server management needed!
๐ฅ Usage Examples
With Claude Code ๐ค
Add this to your ~/.claude.json:
json{ "mcp": { "servers": { "openrouter-image": { "command": "npx", "args": ["openrouter-image-mcp"], "env": { "OPENROUTER_API_KEY": "sk-or-v1-your-api-key-here", "OPENROUTER_MODEL": "google/gemini-2.0-flash-exp:free" } } } } }
With Claude Desktop ๐ฅ๏ธ
Add this to your claude_desktop_config.json:
json{ "mcpServers": { "openrouter-image": { "command": "npx", "args": ["openrouter-image-mcp"], "env": { "OPENROUTER_API_KEY": "sk-or-v1-your-api-key-here", "OPENROUTER_MODEL": "google/gemini-2.0-flash-exp:free" } } } }
๐ฏ Amazing Things You Can Do!
bash# ๐ธ Analyze any screenshot "Analyze this screenshot: /path/to/screenshot.png" # ๐ Extract text from images "What text do you see in this document: /path/to/scan.jpg" # ๐จ Review UI designs "Review this UI mockup for accessibility issues: /path/to/design.png" # ๐ฑ Debug mobile apps "Analyze this mobile app screenshot for UX problems: /path/to/app.png" # ๐ Analyze webpages "What can you tell me about this webpage: https://example.com/screenshot.png"
๐ ๏ธ Available Tools
๐ผ๏ธ analyze_image - General Image Analysis
Perfect for photos, diagrams, charts, and general visual content!
Parameters:
type๐ Input type:file,url, orbase64data๐ธ Image data (path, URL, or base64 string)prompt๐ญ Custom analysis promptformat๐ Output:textorjsonmaxTokens๐ข Maximum response tokens (default: 4000)temperature๐ก๏ธ Creativity 0-2 (default: 0.1)
๐ analyze_webpage_screenshot - Webpage Specialist
Designed specifically for web page analysis and debugging!
Features:
- ๐ฏ Layout analysis
- ๐ฑ Content extraction
- ๐ Navigation review
- ๐ Form analysis
- โฟ Accessibility evaluation
- ๐ Structured JSON output
๐ฑ analyze_mobile_app_screenshot - Mobile App Expert
Specialized for mobile application UI/UX analysis!
Features:
- ๐ iOS/๐ค Android platform detection
- ๐จ UI design review
- ๐ User experience evaluation
- โฟ Accessibility analysis
- ๐ UX heuristic scoring
- ๐ Performance insights
๐ฐ Vision Model Recommendations
| Model | Cost | Vision Quality | Best For |
|---|---|---|---|
๐ google/gemini-2.0-flash-exp:free | FREE | โญโญโญโญโญ | Great for beginners! General analysis, docs |
๐ meta-llama/llama-3.2-90b-vision-instruct | FREE | โญโญโญโญ | Charts, diagrams, technical content |
๐ google/gemini-2.5-flash-lite-preview-09-2025 | ๐ฐ Very Low | โญโญโญโญโญ | Best value! High quality at low cost |
๐ง anthropic/claude-3-5-sonnet-20241022 | ๐ฐ๐ฐ Medium | โญโญโญโญโญ | Detailed analysis, complex reasoning |
๐ฅ anthropic/claude-3-5-haiku-20241022 | ๐ฐ๐ฐ๐ฐ Higher | โญโญโญโญโญ | High accuracy, professional use |
๐ฏ Recommended Models
- ๐ Start with FREE models:
google/gemini-2.0-flash-exp:freeworks excellently for most use cases - ๐ฐ Upgrade when needed: Move to paid models only if you need higher accuracy or specific features
- ๐ฅ Best performance:
anthropic/claude-3-5-sonnet-20241022for professional analysis
๐ก Cost Tips
- Free models handle ~80% of use cases perfectly
- Paid models cost ~$0.001-0.01 per image
- Monitor usage at OpenRouter Dashboard
๐ ๏ธ Development
Local Setup ๐ง
bash# ๐ด Clone the repository git clone https://github.com/your-username/openrouter-image-mcp.git cd openrouter-image-mcp # ๐ฆ Install dependencies npm install # ๐จ Build the project npm run build # ๐ Start in development mode npm run dev # ๐งช Run tests npm test # ๐ Lint and format npm run lint npm run format
๐งช Testing
Run Test Suite ๐งช
bash# ๐งช Run all tests npm test # ๐ Run with coverage npm run test:coverage # ๐ Debug mode DEBUG=* npm test
Manual Testing ๐ฏ
bash# ๐ธ Test with a sample image node test-image-analysis.js # ๐ Test different models OPENROUTER_MODEL=anthropic/claude-sonnet-4 node test-image-analysis.js # ๐ Test with URL input echo '{"type":"url","data":"https://example.com/image.png","prompt":"What do you see?"}' | node dist/index.js
๐ค Contributing
Contributions welcome! Fork the repo, make changes, and submit a pull request. Please follow the existing code style and add tests for new features.
๐ Supported Image Formats
| Format | Extension | MIME Type | Status |
|---|---|---|---|
| ๐ผ๏ธ JPEG | .jpg, .jpeg | image/jpeg | โ |
| ๐ผ๏ธ PNG | .png | image/png | โ |
| ๐ผ๏ธ WebP | .webp | image/webp | โ |
| ๐ผ๏ธ GIF | .gif | image/gif | โ |
| ๐ Max Size | - | - | 10MB (configurable) |
๐ก๏ธ Security & Privacy
- ๐ API Keys: Loaded from environment variables only
- ๐ซ No Sensitive Logging: Personal data never logged
- โ Input Validation: All parameters validated
- ๐ Size Limits: Configurable file size restrictions
- ๐ HTTPS Only: All API communications encrypted
- ๐๏ธ Data Cleanup: Temporary files automatically removed
๐ Troubleshooting
๐ง Common Issues & Solutions
๐ "OPENROUTER_API_KEY environment variable is required"
bash# โ Solution: Set your API key export OPENROUTER_API_KEY=sk-or-v1-your-key-here # Or add to .env file
๐ค "Invalid or unsupported model"
bash# โ Check available models curl -H "Authorization: Bearer $OPENROUTER_API_KEY" \ https://openrouter.ai/api/v1/models | jq '.data[] | select(.architecture.input_modalities | contains(["image"])) | .id'
๐ก "Failed to connect to OpenRouter API"
bash# โ Test connection curl -H "Authorization: Bearer $OPENROUTER_API_KEY" \ https://openrouter.ai/api/v1/models
๐ "Image size exceeds maximum"
bash# โ Increase limit or compress image export MAX_IMAGE_SIZE=20971520 # 20MB
๐ Debug Mode
bash# ๐ Enable detailed logging export LOG_LEVEL=debug npm start # ๐ Monitor API usage curl -H "Authorization: Bearer $OPENROUTER_API_KEY" \ https://openrouter.ai/api/v1/auth/key
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Ready to give your AI agents the power of sight?
โญ Star this repo โข ๐ Report Issues โข ๐ก Suggest Features
Made with โค๏ธ by the open-source community




