MCP 上下文腐化問題:為何 15 個 MCP 伺服器會拖垮 AI 智能體
The MCP Context Rot Problem: Why 15 MCP Servers Are Crippling Your AI Agent
15 個 MCP 伺服器採用急切載入時,工具 JSON Schema 會令 AI 智能體每回合增加約 30,000 個提示詞 token,造成延遲與成本。文章提出語義 MCP 工具路由器,以向量搜尋挑選相關工具,將載入量由 30,000 個 token 降至 750 個。原文指出,30,000 個輸入 token 每回合約需 $0.09 至 $0.25,並增加 4–7 秒首 token 延遲。
The Model Context Protocol (MCP) is the best standard to hit the agentic ecosystem this year. Connecting local databases, GitHub repos, and third-party APIs via a unified JSON-RPC interface feels like magic.
Until you run 15 servers at the same time.
The Hidden Bottleneck: Eager Schema Loading
Most MCP host implementations (Claude Desktop, Cursor, custom LangChain/LlamaIndex loops) operate under an eager-loading paradigm:
Client starts up and executes the handshake with all configured MCP servers.
Client queries tools/list across all connected servers.
Every single tool's complete JSON Schema (parameters, descriptions, types, enums) is stringified and injected directly into the LLM's system prompt.
The Math of Context Bloat
Let's look at what 15 typical MCP servers actually look like in context:
Average tools per server: ~8 tools
Total functions: ~120 tools
Average JSON schema size per tool: ~250 tokens
Total system prompt overhead: ~30,000 tokens
Before your user types "What's the status of PR #42?", your LLM has already ingested 30,000 tokens of boilerplate schema definitions.
The Consequences
Severe Latency (TTFT): Ingesting 30,000 tokens on every conversational turn adds 4–7 seconds of Time-To-First-Token latency.
Financial Bleed: At current frontier model pricing, 30,000 input tokens cost ~$0.09 to $0.25 per turn. A 20-message debugging session costs $4.00+ purely in tool definitions.
Attention Dilution & Tool Confusion: Needle-in-a-haystack benchmarks prove that as system prompt length increases, instruction-following fidelity drops. The LLM gets confused between similar tools (e.g., github_search_issues vs linear_search_issues) and hallucinates parameter arguments.
The Solution: A Semantic MCP Tool Router
Instead of connecting your client to 15 disparate servers, you connect to a single virtual MCP Proxy.
[Claude / Cursor] <---> [MCP Smart Router] <---> [15 Real MCP Servers]
- The router exposes zero tool schemas initially.
- When the user sends a prompt, the router executes a fast local vector search (<5ms, 5MB embedding model) comparing the prompt against tool descriptions.
- It dynamically mounts only the top 2–3 relevant tools into the active turn context (reducing tokens from 30,000 down to 750).
- If the agent finishes, the tools unmount. Have you noticed your Claude Desktop or agent setup slowing down as your MCP config grows? How are you handling tool filtering today?
來源:DEV Community · dev.to