openrouter-subagents
MCP server providing a model-agnostic subagent tool backed by OpenRouter, supporting multi-model Fusion and orchestration patterns.
README
openrouter-subagents
An MCP server and CLI that exposes a model-agnostic "subagent" tool backed by
OpenRouter — one API key, every model. It defaults to OpenRouter
Fusion (openrouter/fusion), which runs a panel of models in parallel and has a judge model
synthesize them into a single answer. Sibling to
gpt-subagents-api (OpenAI API key) and
gpt-subagents-subscription (ChatGPT
subscription), and it ships the same orchestration patterns system.
Note: Uses an OpenRouter API key (
Authorization: Bearer …) against the OpenAI-compatible Chat Completions endpoint. Not affiliated with or endorsed by OpenRouter.
Tools
| Tool | What it does |
|---|---|
ask_openrouter |
Ask any OpenRouter model. model defaults to openrouter/fusion (multi-model synthesis); pass any OpenRouter id to override (e.g. anthropic/claude-opus-latest, openai/gpt-latest, or a fast cheap model). Write instructions (the system prompt) every call. Reasoning is fully controllable (see below). For Fusion only — analysis_models (the panel, 1–8 ids) and judge_model (the synthesizer). |
list_patterns / get_pattern |
Orchestration patterns for driving the model well (see below). |
Fusion cost: a Fusion call bills for every panel model plus the judge. Reach for it when multiple perspectives are worth the spend (research, critique, high cost-of-being-wrong); for quick tactical prompts pass a single model id instead.
Reasoning & sampling controls
Any model's reasoning level can be set — the server exposes OpenRouter's full unified reasoning
object, and OpenRouter translates it into whatever the target model natively speaks (OpenAI/Grok
effort levels, Anthropic thinking budgets, Gemini thinkingLevel, Qwen thinking budgets, on/off
flags for models like DeepSeek/GLM). A level a model doesn't support is mapped to the nearest one
it offers.
| Param | Meaning |
|---|---|
reasoning_effort |
Named level, lowest → highest: none, minimal, low, medium, high, xhigh, max. (none disables reasoning. On Anthropic these become budget ratios ≈ 0.1/0.2/0.5/0.8/0.95 of max_tokens, clamped to [1024, 128000]; on Gemini they map to thinkingLevel.) |
reasoning_max_tokens |
Exact reasoning token budget (Anthropic/Gemini/Qwen-style) for fine-grained control. Mutually exclusive with reasoning_effort. |
reasoning_enabled |
Turn default-strength reasoning on/off without picking a level or budget. |
reasoning_exclude |
Model still reasons, but the reasoning tokens aren't returned in the response. |
temperature |
Sampling temperature, 0–2 (lower = more deterministic). Applied when the model supports it; OpenRouter drops it for models that don't. |
Note for agents (MCP or CLI): if a call fails or any error occurs — timeout, rate limit, model rejection, provider outage — retry the exact same call first (waiting briefly for transient errors). If it keeps failing, report the error and ask; do not downgrade or change the configuration the user set (model, reasoning level/budget, temperature, Fusion panel/judge) without their direct say-so. This rule is also baked into the server's MCP
instructionsand the CLI--help.
CLI
Everything the MCP server does is also available as a plain shell command — same client, same patterns library, but the answer comes back as raw text on stdout with zero JSON-RPC framing. For agents that can run shell commands, this is the token-cheap way to delegate: no MCP envelope in either direction, and piped stdin means large inputs (diffs, logs, files) never have to be echoed through the model's context at all.
npm run build # compiles dist/cli.js
npm link # optional: puts `openrouter-subagents` on your PATH
# ask (the subcommand is optional); raw answer on stdout
openrouter-subagents "why is the sky blue?"
openrouter-subagents ask -m anthropic/claude-haiku-4.5 -e xhigh "prove sqrt(2) is irrational"
# piped stdin becomes the prompt — or the context when a prompt is given
git diff | openrouter-subagents ask -p "review this diff for bugs" -e high
openrouter-subagents ask -p "summarize" --context-file big-report.md -m openai/gpt-5-mini
# patterns
openrouter-subagents patterns
openrouter-subagents pattern two-layer-cross-model-expert
Flags mirror the MCP tool: -m/--model, -i/--instructions (defaults to a terse general-purpose prompt),
-p/--prompt, -c/--context (each with a --*-file variant), -e/--effort
(none…max), --reasoning-tokens <n>, --reasoning on|off, --hide-reasoning,
-t/--temperature, and Fusion's --analysis-models / --judge. --help shows the full
reference. Exit codes: 0 success, 2 usage error, 1 API/network error.
Orchestration patterns
Patterns are reusable playbooks (Markdown in patterns/) that describe how to drive
the expert tool — splitting work, bundling context, calling the expert, verifying its output against
ground truth, and aggregating. They're exposed via list_patterns (catalog) and
get_pattern("<name>") (full text), read from disk at call time (no rebuild to add one), and the
server's instructions nudge the agent to consult them before non-trivial expert work.
| name | what it does |
|---|---|
two-layer-cross-model-expert |
Wrap the OpenRouter expert in verifying Claude subagents so the orchestrator only ever sees parallel, context-cheap, ground-truth-checked conclusions. (Fusion makes the "cross-model" premise even stronger — the expert is a whole panel of model families.) |
worker-orchestrator |
Fan concrete work out to the OpenRouter worker (ask_openrouter with a fast model) through cheap Sonnet wrapper subagents — validated by execution, not a verification gate. |
Both patterns ship a rendered diagram under patterns/html/. See
patterns/README.md to add your own.
Setup
Requires Node 18+ (uses the global fetch) and an OpenRouter API key.
npm install
npm run build
cp .env.example .env # then put your key in .env
Get a key at https://openrouter.ai/keys and set OPENROUTER_API_KEY in .env. .env is gitignored
and must never be committed — only .env.example is tracked.
Configuring a default Fusion panel + judge (optional)
By default, openrouter/fusion uses OpenRouter's built-in "Quality" preset. You can override that
default for every Fusion call from your .env:
# 1–8 panel models that answer in parallel:
OPENROUTER_FUSION_ANALYSIS_MODELS=anthropic/claude-opus-latest,openai/gpt-latest,google/gemini-pro-latest
# the judge that synthesizes them:
OPENROUTER_FUSION_JUDGE_MODEL=anthropic/claude-opus-latest
Precedence is per-call arg > .env default > OpenRouter preset, resolved independently for the panel
and the judge: a per-call analysis_models / judge_model on ask_openrouter overrides the matching
.env default, and these defaults apply only to openrouter/fusion (they're ignored for any other model).
Register with Claude Code
claude mcp add -s user openrouter-subagents -- node /absolute/path/to/openrouter-subagents/dist/server.js
(Claude Code reads MCP registrations at startup, so a newly added server appears after a full restart.)
How it works
ask_openrouterbuilds an OpenAI-style Chat Completions request (system+usermessages).- For
openrouter/fusion, the panel (analysis_models) and judge (judge_model) are resolved with precedence per-call arg >.envdefault > OpenRouter's preset, then sent as aplugins: [{ id: "fusion", … }]entry. With none of them set, OpenRouter's built-in Quality preset is used. - The request is POSTed to
https://openrouter.ai/api/v1/chat/completionswithAuthorization: Bearer $OPENROUTER_API_KEY; the answer ischoices[0].message.content. - Fusion is slow (parallel panel + synthesis), so the client uses a generous request timeout (~280s).
Security
- The API key lives in
.env(gitignored everywhere); only.env.example(a placeholder) is tracked. - Outbound
instructions/prompt/contextare run through a best-effort secret redactor (API keys, tokens, private keys) before they leave your machine — not a guarantee; don't paste highly sensitive data. - Data boundary: with the default
openrouter/fusion, a single call fans your input out to several third-party providers at once (e.g. Anthropic, OpenAI, Google) via OpenRouter. - Local agent/editor state (
.mempalace/,.claude/,CLAUDE.local.md, IDE folders) is gitignored.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。