OpenRouter MCP server

Communityheltonteixeira (community)Config last verified Jun 1, 2026

Community OpenRouter MCP server: chat with 300+ language models through one unified API, search the model catalog, and validate model IDs from your agent.

OpenRouter is a unified API gateway that routes a single request format to hundreds of language models from OpenAI, Anthropic, Google, Meta, Mistral, and dozens of other providers, handling provider failover, pricing, and routing for you. This MCP server (the widely used @mcpservers/openrouterai package, written in TypeScript and built on the official MCP SDK) puts that gateway behind an agent's tool calls so a coding assistant can send chat completions to any OpenRouter model, discover what models are available, and look up a model's capabilities and pricing without leaving the editor.

The server is intentionally small and focused: it exposes four tools — a chat-completion tool that forwards messages to the OpenRouter Chat Completions API with a model you choose, a model-search tool that filters the registry by query, provider, and capabilities, a model-info tool that returns full metadata for one model, and a validation tool that checks whether a model ID exists. It runs locally over stdio with npx and reads an OPENROUTER_API_KEY environment variable; optional environment variables set a default model, a max-token cap, and OpenRouter's provider-routing preferences (sort order, quantizations, fallbacks, data-collection policy, and more). A short-lived model cache keeps repeated catalog lookups fast.

Quick install

Copy-paste configs are provided for all 8 supported clients. Pick your client below.

Add to ~/.claude.json

~/.claude.json
json
{
  "mcpServers": {
    "openrouter": {
      "command": "npx",
      "args": [
        "-y",
        "@mcpservers/openrouterai"
      ],
      "env": {
        "OPENROUTER_API_KEY": "<OPENROUTER_API_KEY>",
        "OPENROUTER_DEFAULT_MODEL": "<OPENROUTER_DEFAULT_MODEL>",
        "OPENROUTER_MAX_TOKENS": "<OPENROUTER_MAX_TOKENS>"
      }
    }
  }
}
Or via CLI
bash
claude mcp add openrouter -- npx -y @mcpservers/openrouterai

Available tools

ToolDescription
chat_completionSend conversational context (messages) to OpenRouter for completion using a model you specify, with optional temperature and provider-routing parameters.
search_modelsSearch and filter the OpenRouter model registry by query string, provider, and capabilities such as pricing, context length, or modality.
get_model_infoRetrieve the complete metadata for a single OpenRouter model specified by its unique ID, including context window, pricing, and supported parameters.
validate_modelVerify whether a given model ID exists within the OpenRouter registry before you attempt a completion with it.

Required configuration

  • OPENROUTER_API_KEYRequired

    OpenRouter API key from openrouter.ai/keys. Required.

  • OPENROUTER_DEFAULT_MODELOptional

    Default model ID to use when a tool call omits one.

  • OPENROUTER_MAX_TOKENSOptional

    Default max tokens per completion.

  • OPENROUTER_PROVIDER_SORTOptional

    Provider routing sort preference (price, throughput, or latency).

  • OPENROUTER_PROVIDER_ALLOW_FALLBACKSOptional

    Whether OpenRouter may fall back to other providers if the preferred one is unavailable.

What you can do with it

Try one prompt across many models

Ask the agent to run the same prompt through GPT-4, Claude, and a Llama model and compare the answers. It calls chat_completion with each model ID, so you can pick the best price/quality tradeoff without juggling three SDKs or three API keys.

Discover and validate models before wiring them in

Use search_models to find every model that supports a long context window or a given provider, get_model_info to read pricing and limits, and validate_model to confirm an ID is correct — all before you hardcode a model into your app.

FAQ

Is it free?
The MCP server is open source (Apache-2.0) and free to run. It calls the OpenRouter API, which is paid per token against your OPENROUTER_API_KEY; OpenRouter also lists some free model variants you can call through it.
Does it support remote/OAuth?
No. This is a local stdio server launched with npx @mcpservers/openrouterai and authenticated with an OPENROUTER_API_KEY environment variable. There is no hosted remote endpoint or OAuth flow.
← Browse all ai-ml servers