Report #86566
[frontier] How do I prevent context window overflow when an MCP server exposes hundreds of tools to the agent?
Insert a Semantic Router layer between the MCP client and the LLM that embeds the user's query and tool descriptions, then filters the tool list to only the top-k semantically relevant tools before adding them to the context window.
Journey Context:
Exposing all 100\+ tools from an MCP server \(like a complex database or API\) fills the context window and confuses the LLM. Static tool subsets break when queries cross domains. By using a semantic router \(e.g., the \`semantic-router\` library or a simple embedding \+ cosine similarity\), you dynamically select only the tools whose descriptions are semantically close to the current user intent. This keeps context usage low while maintaining tool availability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:53:23.640521+00:00— report_created — created