MCP Router
Why
11 个 MCP 服务器常驻 = 每轮注入 11,000 tokens 的工具描述。按需求载可省 **80%** 的 MCP 注入开销。
Task → MCP Mapping
| Task Type |
What you do |
Load These MCPs |
Est. tokens/turn |
| coding |
Write/edit code, review PRs |
token-savior, entroly, github |
~3,500 |
| research |
Search papers, academic work |
token-savior, entroly, semantic-scholar |
~3,000 |
| ui |
Design review, generate images/diagrams |
token-savior, entroly, ui-expert-mcp, image-generation, diagram-generator |
~5,500 |
| debug |
Deep debugging, complex reasoning |
token-savior, entroly, thinking |
~3,000 |
| docs |
Write docs, web fetch |
token-savior, entroly |
~2,000 |
| ops |
Deploy, server ops |
token-savior, entroly |
~2,000 |
| full |
Need everything |
All 11 (use .mcp.json.full) |
~11,000 |
Built-in alternatives — Prefer these over MCP servers to save tokens:
- File ops → Kimi
Shell/Glob/ReadFile (no MCP overhead)
- Web fetch → Kimi
WebFetch (no MCP overhead)
- Browser → Only use
puppeteer when screenshots needed
How to Use
1. Auto-detect on session start
At the start of every conversation, read .mcp.json and compare against the user's first request. If the loaded MCPs don't match the task type:
- State: "Current MCP set: [X, Y]. Task type: [coding]. Recommended: [X, Y, Z]."
- Ask: "Switch to [coding] profile?" (or auto-switch if user previously approved)
- Modify
.mcp.json → reload
2. Switch command
When user says any of these, trigger a profile switch:
| User says |
Action |
| "查论文" / "search paper" / "semantic scholar" |
Load semantic-scholar, unload others |
| "生成图片" / "image" / "diagram" |
Load ui-expert-mcp + image-generation + diagram-generator |
| "调试" / "debug" / "think step by step" |
Load thinking |
| "操作 GitHub" / "PR" / "issue" |
Load github |
| "用全部 MCP" / "full mode" |
Restore .mcp.json.full |
| "精简 MCP" / "minimal" |
Keep only token-savior + entroly |
3. One-off usage (no profile switch)
If user only needs an MCP for a single query:
- Load it temporarily
- Execute the tool call
- Unload it immediately
This avoids paying the token cost for the rest of the conversation.
Configuration Files
| File |
Purpose |
.mcp.json |
Active config (2-3 MCPs max) |
.mcp.json.full |
Full config (all 11 MCPs) |
.mcp.json.ondemand |
Per-server snippets for manual copy |
mcp-servers/mcp-shrink.js |
Shrink proxy (compresses tool descriptions, ~30% savings) |
scripts/rtk-filter.ps1 |
RTK-style shell output filter (reduces tool output tokens) |
Token Budget Rules
- Input > 60K in one session → Start new session
- Tool output > 5K chars → Truncate or use
rtk-filter.ps1
- Session switching →
/compact before new task
- Never keep > 5 MCPs loaded simultaneously
Shrink Proxy
All MCP servers in .mcp.json and .mcp.json.ondemand are wrapped with mcp-servers/mcp-shrink.js.
This intercepts tools/list responses and compresses description fields using caveman rules:
- Removes filler: "This tool allows you to..." → ""
- Removes hedging: "likely", "probably", "generally" → ""
- Removes articles: "a", "an", "the" → ""
- Preserves code, URLs, paths, identifiers
Saves ~30% on MCP description tokens with zero semantic loss.
RTK Output Filter
For shell commands that produce long output, use scripts/rtk-filter.ps1:
# Instead of: git status (2,000 tokens)
# Use:
.\scripts\rtk-filter.ps1 git status # ~200 tokens
# Instead of: npm test (25,000 tokens on failure)
# Use:
.\scripts\rtk-filter.ps1 npm test # ~2,500 tokens
# Supports: git, npm, cargo, pytest, docker, kubectl, ls, cat, grep
Or manually apply RTK principles to any shell output:
- Filter: Strip progress bars, ASCII art, timestamps
- Group: Aggregate by file/type instead of listing every line
- Truncate:
Select-Object -First 50, add "... (N more)"
- Deduplicate: Collapse repeated lines with count
Verification
After any MCP profile switch, verify shrink proxy works:
- Check
.mcp.json uses "command": "node", "args": ["mcp-servers/mcp-shrink.js", ...]
- Run a tool call → descriptions should be terse
- If shrink fails, fall back to direct command (remove shrink wrapper)
Anti-patterns
❌ All 11 MCPs loaded for a simple code edit
❌ Loading MCPs preemptively "just in case"
❌ Forgetting to unload after one-off usage
❌ Using filesystem MCP when Kimi Shell/ReadFile works
❌ Using fetch MCP when Kimi WebFetch works
❌ Running npm test without rtk-filter.ps1 on large test suites
1---2name: mcp-router3description: MCP 服务器自动按需加载技能。避免常驻 MCP 导致的 token 浪费。 每次对话开始时检测任务类型,只加载当前任务必需的 MCP 服务器。 复用 github.com/JuliusBrussee/caveman (shrink proxy) 和 github.com/rtk-ai/rtk (output filter) 策略。4---56# MCP Router78## Why91011 个 MCP 服务器常驻 = 每轮注入 ~11,000 tokens 的工具描述。按需求载可省 **~80%** 的 MCP 注入开销。1112## Task → MCP Mapping1314| Task Type | What you do | Load These MCPs | Est. tokens/turn |15|-----------|-------------|-----------------|------------------|16| **coding** | Write/edit code, review PRs | `token-savior`, `entroly`, `github` | ~3,500 |17| **research** | Search papers, academic work | `token-savior`, `entroly`, `semantic-scholar` | ~3,000 |18| **ui** | Design review, generate images/diagrams | `token-savior`, `entroly`, `ui-expert-mcp`, `image-generation`, `diagram-generator` | ~5,500 |19| **debug** | Deep debugging, complex reasoning | `token-savior`, `entroly`, `thinking` | ~3,000 |20| **docs** | Write docs, web fetch | `token-savior`, `entroly` | ~2,000 |21| **ops** | Deploy, server ops | `token-savior`, `entroly` | ~2,000 |22| **full** | Need everything | All 11 (use `.mcp.json.full`) | ~11,000 |2324**Built-in alternatives** — Prefer these over MCP servers to save tokens:25- File ops → Kimi `Shell`/`Glob`/`ReadFile` (no MCP overhead)26- Web fetch → Kimi `WebFetch` (no MCP overhead)27- Browser → Only use `puppeteer` when screenshots needed2829## How to Use3031### 1. Auto-detect on session start3233At the start of **every conversation**, read `.mcp.json` and compare against the user's first request. If the loaded MCPs don't match the task type:34351. State: "Current MCP set: [X, Y]. Task type: [coding]. Recommended: [X, Y, Z]."362. Ask: "Switch to [coding] profile?" (or auto-switch if user previously approved)373. Modify `.mcp.json` → reload3839### 2. Switch command4041When user says any of these, trigger a profile switch:4243| User says | Action |44|-----------|--------|45| "查论文" / "search paper" / "semantic scholar" | Load `semantic-scholar`, unload others |46| "生成图片" / "image" / "diagram" | Load `ui-expert-mcp` + `image-generation` + `diagram-generator` |47| "调试" / "debug" / "think step by step" | Load `thinking` |48| "操作 GitHub" / "PR" / "issue" | Load `github` |49| "用全部 MCP" / "full mode" | Restore `.mcp.json.full` |50| "精简 MCP" / "minimal" | Keep only `token-savior` + `entroly` |5152### 3. One-off usage (no profile switch)5354If user only needs an MCP for a single query:551. Load it temporarily562. Execute the tool call573. Unload it immediately5859This avoids paying the token cost for the rest of the conversation.6061## Configuration Files6263| File | Purpose |64|------|---------|65| `.mcp.json` | Active config (2-3 MCPs max) |66| `.mcp.json.full` | Full config (all 11 MCPs) |67| `.mcp.json.ondemand` | Per-server snippets for manual copy |68| `mcp-servers/mcp-shrink.js` | Shrink proxy (compresses tool descriptions, ~30% savings) |69| `scripts/rtk-filter.ps1` | RTK-style shell output filter (reduces tool output tokens) |7071## Token Budget Rules7273- **Input > 60K** in one session → Start new session74- **Tool output > 5K chars** → Truncate or use `rtk-filter.ps1`75- **Session switching** → `/compact` before new task76- **Never** keep > 5 MCPs loaded simultaneously7778## Shrink Proxy7980All MCP servers in `.mcp.json` and `.mcp.json.ondemand` are wrapped with `mcp-servers/mcp-shrink.js`.81This intercepts `tools/list` responses and compresses `description` fields using caveman rules:82- Removes filler: "This tool allows you to..." → ""83- Removes hedging: "likely", "probably", "generally" → ""84- Removes articles: "a", "an", "the" → ""85- Preserves code, URLs, paths, identifiers8687**Saves ~30% on MCP description tokens** with zero semantic loss.8889## RTK Output Filter9091For shell commands that produce long output, use `scripts/rtk-filter.ps1`:9293```powershell94# Instead of: git status (2,000 tokens)95# Use:96.\scripts\rtk-filter.ps1 git status # ~200 tokens9798# Instead of: npm test (25,000 tokens on failure)99# Use:100.\scripts\rtk-filter.ps1 npm test # ~2,500 tokens101102# Supports: git, npm, cargo, pytest, docker, kubectl, ls, cat, grep103```104105Or manually apply RTK principles to any shell output:1061. **Filter**: Strip progress bars, ASCII art, timestamps1072. **Group**: Aggregate by file/type instead of listing every line1083. **Truncate**: `Select-Object -First 50`, add "... (N more)"1094. **Deduplicate**: Collapse repeated lines with count110111## Verification112113After any MCP profile switch, verify shrink proxy works:1141. Check `.mcp.json` uses `"command": "node", "args": ["mcp-servers/mcp-shrink.js", ...]`1152. Run a tool call → descriptions should be terse1163. If shrink fails, fall back to direct command (remove shrink wrapper)117118## Anti-patterns119120❌ All 11 MCPs loaded for a simple code edit 121❌ Loading MCPs preemptively "just in case" 122❌ Forgetting to unload after one-off usage 123❌ Using `filesystem` MCP when Kimi `Shell`/`ReadFile` works 124❌ Using `fetch` MCP when Kimi `WebFetch` works 125❌ Running `npm test` without `rtk-filter.ps1` on large test suites