Feature request: MCP tool filtering prior to LLM with semantic search
The issue
Too many tools confuse even the SotA models even with 1M context window, creating context rot issue that getting even worse with multi-step tasks.
Proposal
Semantic Search tool pre-filtering before LLM shows improved quality and reduced confusion, reduced LLM token consumption.
With each new user request, using the most recent and a few last questions in a conversation pre-filter tools with semantic search of user question against the tools descriptions. This is basically rag for MCP tools. RAG build for MCP tool selection can apply all traditional & advanced RAG techniques like: Reranking, HyDE/ReWOO/ReAct, Step-Back Prompting, Reflection, CoT, Query Transformation (Expansion and sub-query), Rule-based retrieval, Hybrid Search, etc. Its basically just RAG and all the tricks applicable here and can yield a better result for MCP Tool selection.
Filter out most semantically relevant tools before LLM call. Then inject the limited pre-filtered tools to LLM. This ensures improved quality and reduced LLM token consumption.
Similar how it is already implemented in https://github.com/mcp-use/mcp-use
Suggested tech stacks:
LanceDB/ChrimaDB/Turso/DuckDB as an embedded (in-progress) Vector DB. Suggested embedding models is Mistral Codestral-Embed,
Reranking Qwen3-reranker (Deep infra) or https://pub.towardsai.net/run-mxbai-rerank-v2-with-infinity-4b73858cd644
Context:
A few recent papers supporting the idea of RAG and semantic search for MCP Tools: TURA: https://www.arxiv.org/pdf/2508.04604 ScaleMCP: Dynamic and Auto-Synchronizing MCP Tools https://arxiv.org/abs/2505.06416 RAG MCP https://arxiv.org/abs/2505.03275
The papers conducted experiments demonstrating that both RAG techniques decrease the number of consumed tokens while at the same time increasing task completeness score with Vector Search + Reranker. We basically improve quality and making it cheaper.
Experiments, including an MCP stress test, demonstrate RAG-MCP significantly cuts prompt tokens (e.g., by over 50%) and more than triples tool selection accuracy (43.13% vs 13.62% baseline)
MCP-use implemented a tool semantic search mechanism https://github.com/mcp-use/mcp-use
MCP-Agent with EmbeddingRouter for semantic tool search and filtering.
https://github.com/lastmile-ai/mcp-agent
MCP-Universe: Benchmarking Large Language Models with Real-World Model Context Protocol Servers.
Key findings: βLong-Context Challenge
Token count increases rapidly with interaction steps, often leading to context overflow and degraded performance in multi-step tasks requiring extensive reasoning.β
This proves how MCP tool pre-filtering (prior LLM) is important, and as I was saying, especially manifests in multi-steps.
https://mcp-universe.github.io
Nightly triage β 2026-09-10
Status: needs human input
Genuine, substantial feature request (semantic-search pre-filtering of the MCP tool list shown to the LLM, per-query) β not a duplicate, and not implemented. The repo has adjacent-but-distinct pieces that address the same underlying "too many tools" problem differently: a static --tools/CLAUDE_FLOW_MCP_TOOLS allowlist (config-time, not per-query/semantic, from #2726) and ADR-112's "improve tool descriptions instead of filtering" approach β plus general embeddings/HNSW infrastructure that exists but isn't wired to tool-list filtering. None of these do what's asked here. This needs product/design judgment (embedding model choice, where to hook into the request pipeline, latency budget per turn, auto vs. opt-in, and how it should interact with the two related efforts already in flight) rather than a same-night unattended implementation.
Generated by Claude Code
Semantic pre-filter helps a lot, but we've also seen the failure mode where search returns the near-duplicate sibling (same verbs, slightly different nouns) and the model confidently picks the wrong one β filtering alone doesn't fix collision in the shortlist.
What has worked for us: measure confusion clusters on a labeled request set, then rename/disambiguate ("use this / not that") before shrinking to always-on core + deferred rest. Happy to share the confusion-score approach if useful: https://catalogslim-waitlist.vercel.app β permission-only.