Skip to main content
Glama
tsilva
by tsilva

🚀 One MCP server for OpenRouter models 🚀

mcp-openrouter is a Python MCP server that lets Codex, Claude Code, opencode, and other MCP hosts call OpenRouter models from local stdio tools.

It exposes chat, image generation, embeddings, model listing, and model search through a small FastMCP server with retry handling, host-aware installation, and optional default model environment variables.

Install

Install the published server into every detected MCP client:

uvx mcp-openrouter install --yes

Install into selected clients:

uvx mcp-openrouter install --yes --clients codex,claude,opencode

Run from a local checkout:

git clone https://github.com/tsilva/mcp-openrouter.git
cd mcp-openrouter
uv sync --dev
keyenv doctor
keyenv run -- uv run mcp-openrouter

mcp-openrouter with no arguments starts the stdio server. The explicit command is uv run mcp-openrouter serve.

Related MCP server: Perplexity Ask OpenRouter

Commands

uvx mcp-openrouter install --yes                 # install into detected MCP clients
uvx mcp-openrouter install --yes --force         # replace an existing openrouter config
uvx mcp-openrouter uninstall --yes               # remove from detected MCP clients
uv run mcp-openrouter                            # run the local stdio server
uv run pytest tests/test_cli.py tests/test_client.py tests/test_config.py tests/test_installer.py tests/test_release_metadata.py tests/test_server.py
keyenv run -- uv run pytest tests/test_tools.py
uv run ruff check src/
uv run ruff format src/

Tools

Tool

Purpose

chat

Send a prompt or message list to an OpenRouter chat model.

generate_image

Generate one image and optionally save it to an absolute local path.

embed

Generate embeddings for a string or list of strings.

list_models

List models, optionally filtered by vision, image_gen, embedding, tools, or long_context.

find_models

Search model names and slugs, returning up to 20 matches.

Example MCP prompts:

Use openrouter chat with anthropic/claude-sonnet-4 to summarize this file
Use openrouter generate_image with google/gemini-3-pro-image-preview to create a square app icon
Use openrouter embed with mistralai/mistral-embed-2312 to embed "Hello world"
Use openrouter list_models with capability "image_gen"
Use openrouter find_models to search for "claude"

Configuration

OPENROUTER_API_KEY is required for all tool calls. For a local checkout, its .keyenv.toml maps the variable to macOS Keychain: use keyenv set OPENROUTER_API_KEY to replace it, keyenv doctor to verify it, and keyenv run -- ... to launch the server or live tests. Python still reads the value normally from os.environ.

Optional defaults make the model parameter optional for matching tools:

DEFAULT_TEXT_MODEL=google/gemini-3-pro-image-preview
DEFAULT_IMAGE_MODEL=google/gemini-3-pro-image-preview
DEFAULT_CODE_MODEL=anthropic/claude-sonnet-4.5
DEFAULT_VISION_MODEL=google/gemini-3-pro-image-preview
DEFAULT_EMBEDDING_MODEL=mistralai/mistral-embed-2312

The current tools read DEFAULT_TEXT_MODEL, DEFAULT_IMAGE_MODEL, and DEFAULT_EMBEDDING_MODEL. DEFAULT_CODE_MODEL and DEFAULT_VISION_MODEL are available for client conventions. Non-secret defaults may remain in .env; the API key must not.

Notes

  • Python 3.10+ is required.

  • The published runtime command installed into hosts is uvx mcp-openrouter.

  • Supported installer targets are Codex, Claude Code, and opencode.

  • generate_image.output_path must be absolute, for example /Users/you/output.png.

  • Unit tests mock network calls. tests/test_tools.py requires a live OPENROUTER_API_KEY.

  • After changing server code, restart the MCP host so it launches a fresh server process.

  • Keep server.json, CHANGELOG.md, and the package version in sync before release. The Makefile release helper is make release-x.y.z.

Local MCP Development

Register a local checkout when you want an MCP host to run your working tree instead of the published PyPI package.

Claude Code:

claude mcp add openrouter --scope user -- keyenv run --manifest /path/to/mcp-openrouter/.keyenv.toml -- uv run --directory /path/to/mcp-openrouter mcp-openrouter

Codex:

codex mcp add openrouter -- keyenv run --manifest /path/to/mcp-openrouter/.keyenv.toml -- uv run --directory /path/to/mcp-openrouter mcp-openrouter

opencode:

{
  "mcp": {
    "openrouter": {
      "type": "local",
      "command": ["keyenv", "run", "--manifest", "/path/to/mcp-openrouter/.keyenv.toml", "--", "uv", "run", "--directory", "/path/to/mcp-openrouter", "mcp-openrouter"],
      "enabled": true
    }
  }
}

Architecture

mcp-openrouter architecture diagram

License

MIT

Available Tools

5 tools
chatB

Send a chat completion request to any OpenRouter model.

ParametersJSON Schema
NameRequiredDescriptionDefault
seedNoRandom seed for deterministic outputs
stopNoList of stop sequences
modelNoModel identifier (e.g., "anthropic/claude-sonnet-4", "openai/gpt-4o"). If not specified, uses DEFAULT_TEXT_MODEL environment variable.
top_kNoTop-k sampling (number of top tokens to consider)
top_pNoNucleus sampling threshold 0-1
promptNoUser message to send (provide either prompt or messages, not both)
systemNoOptional system prompt to set context
messagesNoMulti-turn conversation as a list of {role, content} dicts (provide either prompt or messages, not both)
providerNoProvider routing control (e.g., {"order": ["Anthropic", "Google"]})
json_modeNoIf True, request JSON-formatted response (backward compat)
max_tokensNoMaximum tokens in response (model default if not specified)
temperatureNoSampling temperature 0-2 (model default if not specified)
response_formatNoResponse format spec, e.g. {"type": "json_schema", ...}. Supersedes json_mode if both provided.
presence_penaltyNoPenalize tokens already present (-2 to 2)
reasoning_effortNoReasoning effort level: "minimal", "medium", or "high"
assistant_prefillNoText to prefill the assistant response with
frequency_penaltyNoPenalize repeated tokens (-2 to 2)

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.1/5.0
Behavior2/5

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

With no annotations provided, the description bears full responsibility for disclosing behavioral traits. It only states the action without explaining rate limits, cost implications, error handling, or output format. The schema adds some detail, but the description itself lacks transparency.

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?

The description is one sentence, front-loaded with the main purpose. It is efficient and to the point, though it could provide a bit more context without becoming overly verbose.

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?

Despite a full output schema, the description is too brief for a tool with 17 parameters. It does not explain parameter interplay (e.g., prompt vs messages) or provide context on typical use cases. An agent would benefit from more guidance.

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 description coverage is 100%, so baseline is 3. The description does not add any parameter-specific meaning beyond what the schema already provides, but it does not need to since the schema is thorough.

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?

The description uses a specific verb ('Send') and resource ('chat completion request') and mentions 'any OpenRouter model', which clearly distinguishes it from sibling tools like 'embed' or 'generate_image'. It aligns with common terminology.

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 is provided on when to use this tool versus alternatives. There is no mention of criteria for selecting it over other tools like 'embed' or 'find_models', nor any exclusions or prerequisites.

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

embedB

Generate embeddings for text input using an OpenRouter embedding model.

ParametersJSON Schema
NameRequiredDescriptionDefault
inputYesText string or list of strings to embed
modelNoEmbedding model (e.g., "mistralai/mistral-embed-2312"). If not specified, uses DEFAULT_EMBEDDING_MODEL environment variable.
dimensionsNoCustom embedding dimensions (model-dependent)
encoding_formatNoOutput format: "float" or "base64" (default: float)

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are provided, so the description must carry the burden. It does not disclose whether the tool is read-only, has side effects, requires authentication, or any other behavioral traits beyond the basic action.

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?

The description is a single sentence that efficiently conveys the core purpose. It is concise but lacks structure or additional sections.

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

Completeness3/5

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

With an output schema present and full schema coverage, the description is partially complete. However, it lacks usage guidance and behavioral transparency, which would be needed for an agent to use it confidently.

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 description coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond the schema's parameter descriptions, but does not detract either.

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?

The description clearly states the verb (generate), the resource (embeddings), the input (text), and the provider (OpenRouter). It is specific and distinguishes from sibling tools like chat, generate_image, and 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 Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, nor any context about appropriate use cases or preconditions. It only states the function.

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

find_modelsA

Search for models by name or slug.

ParametersJSON Schema
NameRequiredDescriptionDefault
search_termYesText to search for in model names (e.g., "claude", "gpt", "gemini")

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior2/5

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

With no annotations, the description carries full burden. It only states what it does (search by name or slug) but fails to disclose important behavioral traits such as case sensitivity, partial matching, or whether it returns exact matches only.

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?

The description is a single, efficient sentence that is front-loaded and contains no fluff.

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

Completeness3/5

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

For a simple tool with one parameter and an output schema, the description is adequate but lacks behavioral details like whether the search is case-insensitive or returns partial matches. It is minimally complete.

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

Parameters4/5

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

Schema coverage is 100% with a description for 'search_term'. The tool description adds the concept of 'slug' which is not in the schema description, providing additional meaning beyond the schema.

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?

The description clearly states the tool searches for models by name or slug, which is a specific verb-resource combination. It implicitly differentiates from sibling 'list_models' that likely lists all 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?

The description implies usage when you need to find a specific model, but it does not explicitly state when to use this tool over alternatives like 'list_models', nor does it provide any when-not-to-use guidance.

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

generate_imageB

Generate an image using an OpenRouter image generation model.

ParametersJSON Schema
NameRequiredDescriptionDefault
sizeNoImage size - 1K, 2K, or 4K1K
modelNoImage model (e.g., "google/gemini-3-pro-image-preview"). If not specified, uses DEFAULT_IMAGE_MODEL environment variable.
promptYesImage description - be specific about style, colors, composition
qualityNoQuality setting (e.g., "high", "medium", "low")
backgroundNoBackground setting (e.g., "transparent" for PNG/WebP)
output_pathNoOptional absolute file path to save the image. Must be an absolute path if provided (e.g., "/Users/name/output.png").
aspect_ratioNoAspect ratio - 1:1, 16:9, 9:16, 4:3, 3:4, or 21:91:1
output_formatNoOutput format (e.g., "png", "webp", "jpeg")

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for disclosing behavioral traits. It only states that the tool generates an image via OpenRouter, with no mention of costs, rate limits, authorization, error handling, or potential side effects. This is insufficient for a tool with mutation-like behavior.

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?

The description is a single sentence, front-loaded with the core action. It is concise with no wasted words, though it may be too brief for the complexity of the tool (8 parameters). Overall efficient.

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 the tool has 8 parameters, no output schema, and no annotations, the description is too brief. It does not explain return values, error behavior, or any contextual details about the generation process. The completeness is lacking for a tool of this complexity.

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 description coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond the schema; it does not explain parameter interactions or provide usage examples. It neither enhances nor detracts from the schema's clarity.

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?

The description clearly states the verb 'Generate' and the resource 'image', and specifies the platform 'OpenRouter image generation model'. This differentiates it from sibling tools (chat, embed, find_models, list_models) which serve different purposes.

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?

The description implies the tool is for generating images, but it does not provide explicit guidance on when to use this tool versus alternatives, nor does it mention any prerequisites or limitations. The context is clear but lacks explicit usage direction.

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

list_modelsA

List available OpenRouter models, optionally filtered by capability.

ParametersJSON Schema
NameRequiredDescriptionDefault
capabilityNoFilter by capability: - "vision": Models that can analyze images - "image_gen": Models that can generate images - "embedding": Models that can generate embeddings - "tools": Models that support tool/function calling - "long_context": Models with 100k+ context window

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/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 full burden. It correctly implies a read-only operation but does not explicitly state that it is non-destructive or idempotent. For a simple list tool, this is minimally adequate.

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?

Single, front-loaded sentence with no wasted words. Every part is essential.

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

Completeness5/5

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

Given low complexity (1 optional param, output schema present), the description and schema together fully define the tool's behavior. No additional context is needed.

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 baseline 3. The description mentions 'filtered by capability' but defers to the schema for details. It adds marginal value beyond the schema's own description of the parameter.

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?

The description clearly states the action (list), resource (available OpenRouter models), and the optional filter by capability. It distinguishes well from siblings like chat and embed which are usage tools, not discovery tools.

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?

The description does not provide when to use list_models versus alternatives like find_models. No explicit context for usage or exclusions, leaving the agent to infer based on tool names alone.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv0.1.0
    • First observedchat
    • First observedembed
    • First observedfind_models
    • First observedgenerate_image
    • First observedlist_models

TDQS

A3.7/5.0
Disambiguation5/5

Each tool targets a distinct operation: chat for text generation, embed for embeddings, generate_image for images, find_models and list_models for model discovery with different query types. No overlap.

Naming Consistency5/5

All tool names use lowercase with underscores, following a consistent verb or verb_noun pattern (chat, embed, generate_image, find_models, list_models).

Tool Count5/5

5 tools cover the core functionalities of the OpenRouter API—chat, embedding, image generation, model search, and listing—without being excessive or insufficient.

Completeness4/5

The set covers the primary OpenRouter capabilities (chat, embed, image gen, model discovery). A minor gap is the lack of an explicit streaming tool, but chat can be parameterized for streaming.

Maintenance

ActivityMaintained
ResponsivenessUnresponsive

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

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    An MCP server that wraps the OpenRouter API, enabling users to access diverse language models like Google Gemini 3 Pro for chat and image tasks. It provides tools for generating completions and listing available models within MCP-compatible clients.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that connects to OpenRouter's API to provide Perplexity's models (Sonar, Sonar Deep Research, Sonar Reasoning) for use with any MCP-compatible client.
    8
    MIT

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/tsilva/mcp-openrouter'

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