Skip to main content
Glama
OpenRouter MCP Server

OpenRouter MCP Server

by lumishoang

OpenRouter MCP 服务器

用于发现和查询 OpenRouter 上 300 多种可用 AI 模型的 MCP (Model Context Protocol) 服务器。

功能

  • 列出模型 — 浏览所有可用模型,包括定价、上下文限制和功能

  • 搜索与筛选 — 按提供商、价格、上下文长度、功能(工具、视觉等)查找模型

  • 比较模型 — 并排比较多个模型

  • 获取详情 — 获取任何特定模型的完整元数据

  • 缓存响应 — 5 分钟缓存以减少 API 调用

Related MCP server: NanoBanana MCP Server

安装

pip install openrouter-mcp

使用方法

在 OpenClaw 中使用

添加到你的 openclaw.json MCP 服务器配置中:

{
  "mcp": {
    "servers": {
      "openrouter-models": {
        "command": "openrouter-mcp",
        "env": {
          "OPENROUTER_API_KEY": "your-api-key"
        }
      }
    }
  }
}

然后重启网关。代理现在可以使用 MCP 工具来查询 OpenRouter 模型。

注意: OPENROUTER_API_KEY 是可选的,但建议使用以获得更高的速率限制(200 次请求/分钟 vs 20 次请求/分钟)。 在此处获取你的密钥:https://openrouter.ai/keys

代理使用示例:

# Agent can now call MCP tools like:
list_models(sort_by="context_length")
search_models(query="claude", max_input_price=5.0)
get_model(model_id="anthropic/claude-sonnet-4.6")
compare_models(model_ids="qwen/qwen3.6-plus,anthropic/claude-sonnet-4.6")

独立运行 (stdio)

export OPENROUTER_API_KEY=your-key
python -m openrouter_mcp.server

可用工具

工具

描述

list_models

列出所有模型,支持可选的模态筛选和排序

get_model

通过 ID 获取特定模型的详细信息

search_models

按查询、提供商、价格、上下文、功能搜索和筛选模型

compare_models

并排比较多个模型

refresh_cache

强制从 OpenRouter API 刷新模型缓存

示例

按上下文长度排序列表模型

{
  "name": "list_models",
  "arguments": {
    "modality": "text",
    "sort_by": "context_length"
  }
}

搜索每 100 万 token 价格低于 $5 的 Claude 模型

{
  "name": "search_models",
  "arguments": {
    "query": "claude",
    "provider": "anthropic",
    "max_input_price": 5.0,
    "requires_tools": true
  }
}

比较 3 个模型

{
  "name": "compare_models",
  "arguments": {
    "model_ids": "anthropic/claude-sonnet-4.6,qwen/qwen3.6-plus,openai/gpt-5.4"
  }
}

获取模型详情

{
  "name": "get_model",
  "arguments": {
    "model_id": "anthropic/claude-sonnet-4.6"
  }
}

API 参考

list_models(modality, sort_by)

  • modality (str, 默认: "text"): 按输出类型筛选。选项: text, image, audio, embeddings, all

  • sort_by (str, 默认: "name"): 排序方式: name, created, price, context_length

get_model(model_id)

  • model_id (str, 必填): 模型标识符,例如 anthropic/claude-sonnet-4.6

search_models(query, provider, max_input_price, min_context, requires_tools, requires_vision, free_only)

  • query (str): 在模型名称/ID/描述中进行自由文本搜索

  • provider (str): 按提供商筛选 (例如 anthropic, google, openai)

  • max_input_price (float): 每 100 万 token 的最大输入价格 (0 = 无限制)

  • min_context (int): 最小上下文窗口大小

  • requires_tools (bool): 仅限支持工具调用的模型

  • requires_vision (bool): 仅限具有视觉/图像输入功能的模型

  • free_only (bool): 仅限免费模型

compare_models(model_ids)

  • model_ids (str, 必填): 以逗号分隔的模型 ID 列表

refresh_cache()

强制从 OpenRouter API 刷新模型缓存。

速率限制

  • 无 API 密钥:20 次请求/分钟

  • 有 API 密钥:200 次请求/分钟

  • 模型数据缓存 5 分钟

在此处获取你的 API 密钥:https://openrouter.ai/keys

许可证

MIT

贡献

欢迎贡献!请在 GitHub 上提交 issue 或 PR。

Available Tools

5 tools
compare_modelsB

Compare multiple models side by side.

Args: model_ids: Comma-separated model IDs

Inputs: model_ids (required). Returns: result

get_modelA

Get detailed info for one model.

Args: model_id: Model slug, e.g. 'anthropic/claude-sonnet-4.6'

Inputs: model_id (required). Returns: result

list_modelsB

List models available on OpenRouter.

Args: modality: Filter by output type. Options: text, image, audio, embeddings, all sort_by: Sort by: name, created, price, context_length

Inputs: modality, sort_by. Returns: result

refresh_cacheA

Force refresh the model cache from OpenRouter.

Inputs: no named parameters. Returns: result

search_modelsA

Search and filter OpenRouter models.

Args: query: Free-text search in model name/id/description provider: Filter by provider (anthropic, google, openai, etc.) max_input_price: Max input price per 1M tokens, 0 = no limit min_context: Minimum context window size requires_tools: Only models supporting tool calling requires_vision: Only models with vision/image input free_only: Only free models

Inputs: query, provider, max_input_price, min_context, +3 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a distinct purpose: get single model details, list with basic filters, search with advanced filters, compare multiple, and cache refresh. No overlapping functionality; descriptions clearly differentiate them.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using lowercase with underscores: list_models, search_models, get_model, compare_models, refresh_cache. No mixing of conventions.

    Tool Count5/5

    With 5 tools, the server provides a focused set for model discovery and management. This is neither too few nor too many for the domain of querying model information from OpenRouter.

    Completeness5/5

    The tool set covers all essential operations for interacting with OpenRouter models: listing, searching, getting details, comparing, and cache management. No obvious gaps like missing model capability queries, as search covers those.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      An MCP server that retrieves and provides AI model information from OpenAI, Anthropic, and Google through a unified interface.
      3
      84 npm
      MIT
    • 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.
      -