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 集成