OpenRouter MCP Server
OpenRouter MCP Server
A Model Context Protocol (MCP) server providing seamless integration with OpenRouter.ai's diverse model ecosystem. Access various AI models through a unified, type-safe interface with built-in caching, rate limiting, and error handling.
<a href="https://glama.ai/mcp/servers/xdnmf8yei0"><img width="380" height="200" src="https://glama.ai/mcp/servers/xdnmf8yei0/badge" alt="OpenRouter Server MCP server" /></a>
Features
- Model Access
- Direct access to all OpenRouter.ai models
- Automatic model validation and capability checking
- Default model configuration support
- Performance Optimization
- Smart model information caching (1-hour expiry)
- Automatic rate limit management
- Exponential backoff for failed requests
- Robust Error Handling
- Detailed error messages with context
- Rate limit detection and recovery
- Network timeout handling with retries
Installation
Configuration
Prerequisites
- Get your OpenRouter API key from OpenRouter Keys
- Choose a default model (optional)
Setup
Add to your MCP settings configuration file (cline_mcp_settings.json
or claude_desktop_config.json
):
Available Tools
chat_completion
Send messages to OpenRouter.ai models:
search_models
Search and filter available models:
get_model_info
Get detailed information about a specific model:
validate_model
Check if a model ID is valid:
Rate Limiting
The server implements intelligent rate limit handling:
- Tracks remaining requests through response headers
- Automatically waits when rate limits are reached
- Implements exponential backoff for failed requests
- Provides clear error messages for rate limit issues
Error Handling
The server uses McpError
for MCP-specific errors with clear messages:
- Invalid model errors
- API rate limiting
- Authentication issues
- Network errors
- Invalid parameter errors
Development
See CONTRIBUTING.md for detailed information about:
- Development setup
- Project structure
- Feature implementation
- Error handling guidelines
- Tool usage examples
Changelog
See CHANGELOG.md for version history and migration guides.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Provides integration with OpenRouter.ai, allowing access to various AI models through a unified interface.