OpenRouter

io.github.tsilva由 GitHub 帳號 tsilva 發布v1.1.8更新於 Oct 24, 2026

MCP server providing access to 300+ AI models via OpenRouter

發布方自己的服務:370.ai — AI Gateway: 100+ Chat Models, Image & Speech Generation

已驗證STDIO僅桌面媒體與設計AI 與機器學習

概覽

AI 產生的概覽

一個本機 MCP 伺服器,讓助理透過 OpenRouter 呼叫 300 多個 AI 模型,用於對話、影像生成、嵌入與模型查找。

可以做什麼
將提示或訊息清單送往 OpenRouter 對話模型,並在助理工作階段中取回回覆。依提示生成一張影像,可選擇儲存到你指定的絕對本機路徑。為單一字串或字串清單產生嵌入向量。列出可用模型,可依視覺、影像生成、嵌入、工具呼叫或長上下文等能力篩選。搜尋模型名稱與識別碼,最多回傳 20 筆符合項目。
適用情境
適合想在同一個助理工作階段中,透過單一 OpenRouter 帳戶存取多家模型供應商的情況,例如比較模型、生成影像或產生嵌入,而不必分別安裝各家整合。
執行需求
以 Python 套件形式透過 stdio 在本機執行(需 Python 3.10 以上),通常以 uvx 啟動。需要 OpenRouter 帳戶,且所有工具呼叫都需要 OPENROUTER_API_KEY 環境變數。選用的 DEFAULT_TEXT_MODEL、DEFAULT_IMAGE_MODEL 與 DEFAULT_EMBEDDING_MODEL 變數可提供預設模型。需要連線至 OpenRouter 的網路存取。
安裝前請注意
伺服器需要你的 OpenRouter API 金鑰,且每次工具呼叫都會在你的 OpenRouter 帳戶產生費用。不要把金鑰放在明文的 .env 檔案中,建議使用密鑰管理工具。影像生成會寫入你指定的絕對路徑,使用前請確認該路徑。提示、文字與影像會傳送給 OpenRouter 及其背後的模型供應商。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 OpenRouter,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[mcp-openrouter]
🚀 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:

bash
uvx mcp-openrouter install --yes

Install into selected clients:

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

Run from a local checkout:

bash
git clone https://github.com/tsilva/mcp-openrouter.gitcd mcp-openrouteruv sync --devkeyenv doctorkeyenv run -- uv run mcp-openrouter

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

Commands

bash
uvx mcp-openrouter install --yes                 # install into detected MCP clientsuvx mcp-openrouter install --yes --force         # replace an existing openrouter configuvx mcp-openrouter uninstall --yes               # remove from detected MCP clientsuv run mcp-openrouter                            # run the local stdio serveruv 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.pykeyenv run -- uv run pytest tests/test_tools.pyuv run ruff check src/uv run ruff format src/

Tools

ToolPurpose
chatSend a prompt or message list to an OpenRouter chat model.
generate_imageGenerate one image and optionally save it to an absolute local path.
embedGenerate embeddings for a string or list of strings.
list_modelsList models, optionally filtered by vision, image_gen, embedding, tools, or long_context.
find_modelsSearch model names and slugs, returning up to 20 matches.

Example MCP prompts:

text
Use openrouter chat with anthropic/claude-sonnet-4 to summarize this fileUse openrouter generate_image with google/gemini-3-pro-image-preview to create a square app iconUse 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:

bash
DEFAULT_TEXT_MODEL=google/gemini-3-pro-image-previewDEFAULT_IMAGE_MODEL=google/gemini-3-pro-image-previewDEFAULT_CODE_MODEL=anthropic/claude-sonnet-4.5DEFAULT_VISION_MODEL=google/gemini-3-pro-image-previewDEFAULT_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:

bash
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:

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

opencode:

json
{  "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

來源:README.md,提交 9dbab24

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.1.8最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Router 整合