Skip to main content
Glama

OpenRouter MCP Server

OpenRouter MCP サーバー

OpenRouter.aiの多様なモデルエコシステムとのシームレスな統合を実現するモデルコンテキストプロトコル(MCP)サーバー。キャッシュ、レート制限、エラー処理を内蔵した統合型セーフインターフェースを通じて、様々なAIモデルにアクセスできます。

特徴

  • モデルアクセス
    • すべてのOpenRouter.aiモデルへの直接アクセス
    • 自動モデル検証と機能チェック
    • デフォルトのモデル構成のサポート
  • パフォーマンスの最適化
    • スマートモデル情報のキャッシュ(1時間で有効期限切れ)
    • 自動レート制限管理
    • 失敗したリクエストに対する指数バックオフ
  • 統一応答形式
    • すべてのレスポンスに一貫したToolResult構造
    • isErrorフラグでエラー識別をクリアする
    • コンテキスト付きの構造化されたエラーメッセージ

インストール

pnpm install @mcpservers/openrouterai

構成

前提条件

  1. OpenRouter KeysからOpenRouter APIキーを取得します。
  2. デフォルトモデルを選択する(オプション)

環境変数

OPENROUTER_API_KEY=your-api-key-here OPENROUTER_DEFAULT_MODEL=optional-default-model

設定

MCP 設定構成ファイル ( cline_mcp_settings.jsonまたはclaude_desktop_config.json ) に追加します。

{ "mcpServers": { "openrouterai": { "command": "npx", "args": ["@mcpservers/openrouterai"], "env": { "OPENROUTER_API_KEY": "your-api-key-here", "OPENROUTER_DEFAULT_MODEL": "optional-default-model" } } } }

応答フォーマット

すべてのツールは、標準化された構造で応答を返します。

interface ToolResult { isError: boolean; content: Array<{ type: "text"; text: string; // JSON string or error message }>; }

成功例:

{ "isError": false, "content": [{ "type": "text", "text": "{\"id\": \"gen-123\", ...}" }] }

エラー例:

{ "isError": true, "content": [{ "type": "text", "text": "Error: Model validation failed - 'invalid-model' not found" }] }

利用可能なツール

チャット完了

OpenRouter.ai モデルにメッセージを送信します。

interface ChatCompletionRequest { model?: string; messages: Array<{role: "user"|"system"|"assistant", content: string}>; temperature?: number; // 0-2 } // Response: ToolResult with chat completion data or error

検索モデル

利用可能なモデルを検索してフィルタリングします:

interface ModelSearchRequest { query?: string; provider?: string; minContextLength?: number; capabilities?: { functions?: boolean; vision?: boolean; }; } // Response: ToolResult with model list or error

モデル情報を取得する

特定のモデルに関する詳細情報を取得します。

{ model: string; // Model identifier }

検証モデル

モデル ID が有効かどうかを確認します。

interface ModelValidationRequest { model: string; } // Response: // Success: { isError: false, valid: true } // Error: { isError: true, error: "Model not found" }

エラー処理

サーバーは、コンテキスト情報を含む構造化されたエラーを提供します。

// Error response structure { isError: true, content: [{ type: "text", text: "Error: [Category] - Detailed message" }] }

一般的なエラー カテゴリ:

  • Validation Error : 入力パラメータが無効です
  • API Error : OpenRouter API通信の問題
  • Rate Limit : リクエストスロットリング検出
  • Internal Error : サーバー側の処理エラー

応答の処理:

async function handleResponse(result: ToolResult) { if (result.isError) { const errorMessage = result.content[0].text; if (errorMessage.startsWith('Error: Rate Limit')) { // Handle rate limiting } // Other error handling } else { const data = JSON.parse(result.content[0].text); // Process successful response } }

発達

詳細については、 CONTRIBUTING.md を参照してください。

  • 開発セットアップ
  • プロジェクト構造
  • 機能実装
  • エラー処理ガイドライン
  • ツールの使用例
# Install dependencies pnpm install # Build project pnpm run build # Run tests pnpm test

変更履歴

以下の内容を含む最近の更新については、 CHANGELOG.md を参照してください。

  • 統一された応答形式の実装
  • 強化されたエラー処理システム
  • 型安全なインターフェースの改善

ライセンス

このプロジェクトは、Apache License 2.0 に基づいてライセンスされています。詳細については、 LICENSEファイルを参照してください。

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

OpenRouter.ai との統合を提供し、統一されたインターフェースを通じてさまざまな AI モデルにアクセスできるようになります。

  1. 特徴
    1. インストール
      1. 構成
        1. 前提条件
        2. 環境変数
        3. 設定
      2. 応答フォーマット
        1. 利用可能なツール
          1. チャット完了
          2. 検索モデル
          3. モデル情報を取得する
          4. 検証モデル
        2. エラー処理
          1. 発達
            1. 変更履歴
              1. ライセンス

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  This server facilitates the invocation of AI models from providers like Anthropic, OpenAI, and Groq, enabling users to manage and configure large language model interactions seamlessly.
                  Last updated -
                  9
                  Python
                  MIT License
                • -
                  security
                  A
                  license
                  -
                  quality
                  A proxy server that bridges AI agents and external APIs by dynamically translating OpenAPI specifications into standardized MCP tools, enabling seamless interaction without custom integration code.
                  Last updated -
                  39
                  Python
                  MIT License
                  • Linux
                  • Apple
                • -
                  security
                  A
                  license
                  -
                  quality
                  Enables AI agents to interact with multiple LLM providers (OpenAI, Anthropic, Google, DeepSeek) through a standardized interface, making it easy to switch between models or use multiple models in the same application.
                  Last updated -
                  3
                  Python
                  MIT License
                  • Linux
                  • Apple
                • A
                  security
                  A
                  license
                  A
                  quality
                  An AI router that connects applications to multiple LLM providers (OpenAI, Anthropic, Google, DeepSeek, Ollama, etc.) with smart model orchestration capabilities, enabling dynamic switching between models for different reasoning tasks.
                  Last updated -
                  3
                  8
                  11
                  TypeScript
                  MIT License
                  • Linux
                  • Apple

                View all related MCP servers

                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/heltonteixeira/openrouterai'

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