multi-model-companion
Local MCP server that lets Claude Code delegate bounded, read-only tasks to external AI models (Codex, Grok, local OpenAI-compatible servers) via CLIProxyAPI.
README
multi-model-companion
Local MCP server that lets Claude Code delegate bounded, read-only tasks to external models through CLIProxyAPI:
- OpenAI Codex (ChatGPT / Codex subscription via OAuth)
- xAI Grok (Grok subscription via OAuth)
- Local OpenAI-compatible models (vLLM, Ollama, LM Studio, llama.cpp, …)
- Optionally any other backend CLIProxyAPI exposes (Kimi, OpenRouter, API keys, …)
Claude stays the coordinator: it decomposes work, selects models and context, verifies output, edits files, and runs tests. Companion models receive only the context you send and return text — they cannot run shell, read your disk, modify the repo, or use your credentials.
Native Claude Code
│ MCP (stdio)
▼
multi-model-companion
│ OpenAI-compatible HTTP
▼
CLIProxyAPI (127.0.0.1:8317)
├── Codex OAuth → GPT / Codex models
├── xAI OAuth → Grok models
├── Kimi OAuth → Kimi models (optional)
└── openai-compatibility → local vLLM / Ollama / …
Why MCP instead of the official Codex Claude Code plugin?
Short version: one uniform multi-provider bridge beats one CLI wrapper per vendor for everyday review, analysis, local-model routing, and multi-model compare. Keep a CLI plugin (or bare Codex CLI) only for rare write-mode “go implement this yourself” rescue tasks.
Full write-up (rephrased from a real migration off a Codex/Grok plugin stack):
- docs/06-mcp-vs-plugin.md — architecture contrast, trust surface, data governance, and the recommended split.
Upstream plugin reference: openai/codex-plugin-cc.
Requirements
- Python ≥ 3.12
- uv
- CLIProxyAPI running locally
- At least one configured backend (OAuth login and/or local OpenAI-compatible server)
- Claude Code CLI
Quickstart
git clone https://github.com/<you>/multi-model-companion.git
cd multi-model-companion
cp .env.example .env # set CLIPROXY_API_KEY and model IDs
uv sync --extra dev
- Install and start CLIProxyAPI — docs/01-cliproxyapi-setup.md
- Log in to subscriptions you want — docs/02-subscription-logins.md
- Optionally wire a local model — docs/03-local-models.md
- Register the MCP server with Claude Code — docs/04-claude-code-mcp.md
Confirm models from the proxy:
curl -s \
-H "Authorization: Bearer $CLIPROXY_API_KEY" \
"${CLIPROXY_BASE_URL:-http://127.0.0.1:8317/v1}/models" \
| jq -r '.data[].id' | sort
Set CODEX_MODEL, GROK_MODEL, and DEEPSEEK_MODEL in .env to IDs that
actually appear in that list.
MCP tools
| Tool | Purpose |
|---|---|
delegate_analysis |
Debugging hypotheses, architecture, research synthesis |
delegate_review |
Read-only code review of a supplied diff/excerpt |
delegate_patch |
Propose a minimal unified diff (never applies it) |
compare_models |
Same question to 2–3 providers in parallel |
list_companion_models |
Configured IDs vs what CLIProxyAPI currently exposes |
health_check |
Connectivity check (no inference) |
Providers in this package: codex, grok, deepseek (the third slot is
intended for your local OpenAI-compatible model; rename via env).
Model routing (house defaults)
- Drop-in agent guidance: CLAUDE.md
- Longer rationale: MODEL_ROUTING.md
Core policy:
- Prefer a local / cheap model (
deepseekslot) for anything that fits supplied context. - Escalate to Codex / Grok only on evidence (thin output, fuzzy spec, high blast radius).
- Claude verifies every material claim and applies every change itself.
- Never put secrets,
.env, or key material in delegated context.
Configuration
See .env.example. Required:
CLIPROXY_API_KEY=replace-with-a-long-random-client-key
Optional model overrides (examples — use IDs from your /v1/models list):
CLIPROXY_BASE_URL=http://127.0.0.1:8317/v1
CODEX_MODEL=gpt-5.6-codex
GROK_MODEL=grok-4
DEEPSEEK_MODEL=local/my-local-model
Example CLIProxyAPI + MCP snippets:
Security model
- Read-only delegation — no tool runs shell or writes files.
- Outbound context is redacted for common secret patterns and truncated.
- Repository content is wrapped as untrusted data in the prompt.
- Logs are metadata-only (provider, model, mode, sizes, status) — never full prompts, keys, or responses.
- Keep CLIProxyAPI bound to
127.0.0.1.
Details: docs/05-security.md.
Validation
uv sync --extra dev
uv run pytest -v
uv run ruff check src tests scripts
uv run python scripts/smoke_stdio.py # no live models required
Live path (CLIProxyAPI + backends up):
export CLIPROXY_API_KEY=...
uv run python scripts/e2e_live.py
Optional independent audit prompt: docs/validation-prompt.md.
Project layout
src/multi_model_companion/ # MCP server + CLIProxy client
tests/ # unit tests (httpx mocked)
scripts/ # smoke + optional live e2e
docs/ # setup guides + MCP vs plugin rationale
examples/ # sample CLIProxyAPI + MCP configs
CLAUDE.md # drop into a project for routing defaults
MODEL_ROUTING.md # longer routing rationale
Docs index
| Doc | Topic |
|---|---|
| docs/01-cliproxyapi-setup.md | Install / run the proxy |
| docs/02-subscription-logins.md | Codex, Grok, Kimi OAuth |
| docs/03-local-models.md | vLLM, Ollama, tunnels |
| docs/04-claude-code-mcp.md | Wire MCP into Claude Code |
| docs/05-security.md | Threat model and controls |
| docs/06-mcp-vs-plugin.md | Why MCP over CLI plugins |
Contributing
See CONTRIBUTING.md. Please read SECURITY.md before reporting vulnerabilities, and CODE_OF_CONDUCT.md for community expectations.
Release notes: CHANGELOG.md.
Related projects
- CLIProxyAPI
- CLIProxyAPI docs
- Claude Code
- Model Context Protocol
- openai/codex-plugin-cc (plugin alternative)
License
MIT — see LICENSE.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。