MCP server providing access to 300+ AI models via OpenRouter
Project description
mcp-openrouter
🚀 Access 300+ AI models through a single MCP server — text, images, embeddings, and model discovery at your fingertips 🤖
Overview
mcp-openrouter is an MCP (Model Context Protocol) server that provides seamless access to OpenRouter's extensive catalog of AI models. Use Claude, GPT, Gemini, Llama, and 300+ other models through a unified interface.
Features
- ✨ Text Completion — Chat with any OpenRouter model (Claude, GPT, Gemini, Mistral, etc.)
- 🎨 Image Generation — Create images with DALL-E, Gemini, and other image models
- 📐 Embeddings — Generate vector embeddings with Mistral, OpenAI, Gemini, and other embedding models
- 🔍 Model Discovery — List and search 300+ models by capability
- ⚡ Persistent Connection — No repeated setup or permission prompts
- 🔧 Zero Config — Just set your API key and go
Quick Start
Installation
uvx mcp-openrouter install
The installer auto-detects codex, claude, and opencode on your PATH, asks which detected clients should get the openrouter MCP server, stores your OPENROUTER_API_KEY in each selected client config, and registers the production runtime command uvx mcp-openrouter.
Requirements:
uvinstalled- an OpenRouter API key from openrouter.ai/keys
If OPENROUTER_API_KEY is already set in your shell, the installer reuses it. Otherwise it prompts securely.
Non-interactive install
Install into all detected clients:
uvx mcp-openrouter install --yes
Install only specific clients:
uvx mcp-openrouter install --yes --clients codex,claude
Replace existing openrouter configs automatically:
uvx mcp-openrouter install --yes --force
uvx mcp-openrouter install --yes --api-key sk-or-v1-...
What gets installed
- Codex:
codex mcp add openrouter --env OPENROUTER_API_KEY=... -- uvx mcp-openrouter - Claude Code:
claude mcp add -s user -e OPENROUTER_API_KEY=... openrouter -- uvx mcp-openrouter - opencode: writes
openrouterunder~/.opencode/settings.jsonin themcpobject
If an existing openrouter config already matches, the installer skips it. If it differs, the interactive installer asks before replacing it, and --force replaces it automatically.
Uninstall
codex mcp remove openrouter
claude mcp remove -s user openrouter
For opencode, remove the openrouter entry from ~/.opencode/settings.json under mcp.
Running the server directly
uvx mcp-openrouter serve
mcp-openrouter with no arguments also starts the stdio MCP server.
Default Models
Configure default models for different use cases. When set, the model parameter becomes optional in tool calls:
# Add to your .env file
DEFAULT_TEXT_MODEL=anthropic/claude-sonnet-4
DEFAULT_IMAGE_MODEL=google/gemini-3-pro-image-preview
DEFAULT_CODE_MODEL=anthropic/claude-sonnet-4
DEFAULT_VISION_MODEL=anthropic/claude-sonnet-4
DEFAULT_EMBEDDING_MODEL=mistralai/mistral-embed-2312
These are included in .env.example — copy it to .env and adjust as needed.
Tools
| Tool | Description |
|---|---|
chat |
Send chat completion requests to any model |
generate_image |
Generate images with image models |
embed |
Generate vector embeddings for text |
list_models |
List available models, filter by capability |
find_models |
Search for models by name |
Examples
Chat with any model:
Use openrouter chat with anthropic/claude-sonnet-4 to explain quantum computing
Generate an image:
Use openrouter generate_image with google/gemini-3-pro-image-preview to create a logo for my app
Find models:
Use openrouter find_models to search for "claude"
Generate embeddings:
Use openrouter embed with mistralai/mistral-embed-2312 to embed "Hello world"
List image generation models:
Use openrouter list_models with capability "image_gen"
API Reference
chat
Send a chat completion request to any OpenRouter model.
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
string | Yes | User message to send |
model |
string | No* | Model identifier (e.g., anthropic/claude-sonnet-4) |
system |
string | No | System prompt for context |
max_tokens |
int | No | Maximum tokens in response |
temperature |
float | No | Sampling temperature (0-2) |
json_mode |
bool | No | Request JSON-formatted response |
*Required unless DEFAULT_TEXT_MODEL is set.
generate_image
Generate an image using an OpenRouter image model.
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
string | Yes | Image description |
output_path |
string | Yes | Absolute path to save the image |
model |
string | No* | Image model (e.g., google/gemini-3-pro-image-preview) |
aspect_ratio |
string | No | 1:1, 16:9, 9:16, 4:3, 3:4, 21:9 |
size |
string | No | 1K, 2K, or 4K |
background |
string | No | Background setting (e.g., transparent) |
*Required unless DEFAULT_IMAGE_MODEL is set.
embed
Generate vector embeddings for text input.
| Parameter | Type | Required | Description |
|---|---|---|---|
input |
string or list | Yes | Text string or list of strings to embed |
model |
string | No* | Embedding model (e.g., mistralai/mistral-embed-2312) |
encoding_format |
string | No | Output format: float or base64 |
dimensions |
int | No | Custom embedding dimensions (model-dependent) |
*Required unless DEFAULT_EMBEDDING_MODEL is set.
list_models
List available models, optionally filtered by capability.
| Parameter | Type | Required | Description |
|---|---|---|---|
capability |
string | No | Filter: vision, image_gen, embedding, tools, long_context |
find_models
Search for models by name or slug.
| Parameter | Type | Required | Description |
|---|---|---|---|
search_term |
string | Yes | Text to search in model names |
Development
# Clone the repository
git clone https://github.com/tsilva/mcp-openrouter.git
cd mcp-openrouter
# Install dependencies
uv sync --dev
# Run the server
OPENROUTER_API_KEY=your-key uv run mcp-openrouter
# Run tests
OPENROUTER_API_KEY=your-key uv run pytest tests/
# Lint
uv run ruff check src/
uv run ruff format src/
Manual development install
If you want your MCP client to run directly from a local checkout instead of the published PyPI package, register the repo path manually.
Claude Code:
claude mcp add openrouter --scope user -- uv run --directory /path/to/mcp-openrouter mcp-openrouter
Codex:
codex mcp add openrouter --env OPENROUTER_API_KEY=your-key -- uv run --directory /path/to/mcp-openrouter mcp-openrouter
opencode:
Add this openrouter entry under mcp in ~/.opencode/settings.json:
{
"type": "local",
"command": ["uv", "run", "--directory", "/path/to/mcp-openrouter", "mcp-openrouter"],
"environment": {
"OPENROUTER_API_KEY": "your-key"
},
"enabled": true
}
Applying Code Changes
When you modify the MCP server code, Claude won't automatically pick up the changes. The server runs as a long-lived process that persists across tool calls within a session.
To apply your changes:
-
Start a new Claude Code session — Close your current terminal/conversation and open a new one. The MCP server process restarts when a new session begins.
-
Or use the
/mcpcommand — Check server status and restart options within Claude Code.
Why this works: The installation uses uv run --directory /path/to/mcp-openrouter which executes code directly from your source directory. There's no separate "install" step needed — just restart the server process to load your changes.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_openrouter-1.1.0.tar.gz.
File metadata
- Download URL: mcp_openrouter-1.1.0.tar.gz
- Upload date:
- Size: 188.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
262bf41623266f526e000f1afd7b0a7c3921ddb66ea8325137b267e2d32e7417
|
|
| MD5 |
257399457792410bfea8ad0d9a400dc7
|
|
| BLAKE2b-256 |
96f969497f556ec2976647bc750dab06a1ee082ce21f0dd2ec53ee31b11e007a
|
Provenance
The following attestation bundles were made for mcp_openrouter-1.1.0.tar.gz:
Publisher:
release.yml on tsilva/mcp-openrouter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_openrouter-1.1.0.tar.gz -
Subject digest:
262bf41623266f526e000f1afd7b0a7c3921ddb66ea8325137b267e2d32e7417 - Sigstore transparency entry: 1097009721
- Sigstore integration time:
-
Permalink:
tsilva/mcp-openrouter@517c5a5c57a852485832a9087004c31c11178b53 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@517c5a5c57a852485832a9087004c31c11178b53 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_openrouter-1.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_openrouter-1.1.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a30342db7220f9ca290caedfaf877eda16e8124ed1037cba2e953f9d22250ad
|
|
| MD5 |
0ada8bffeac63b04bdcf7e09e394bfed
|
|
| BLAKE2b-256 |
f71bd8b6fcb49afb0a0998e7d81fb664ecce93ad52ea552ae9c265d525d056d2
|
Provenance
The following attestation bundles were made for mcp_openrouter-1.1.0-py3-none-any.whl:
Publisher:
release.yml on tsilva/mcp-openrouter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_openrouter-1.1.0-py3-none-any.whl -
Subject digest:
9a30342db7220f9ca290caedfaf877eda16e8124ed1037cba2e953f9d22250ad - Sigstore transparency entry: 1097009723
- Sigstore integration time:
-
Permalink:
tsilva/mcp-openrouter@517c5a5c57a852485832a9087004c31c11178b53 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@517c5a5c57a852485832a9087004c31c11178b53 -
Trigger Event:
push
-
Statement type: