ruvnet / ruvnet/ruflo

Feature request: MCP tool filtering prior to LLM with semantic search

Open
#665 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
72.7k
Forks
8.6k
Avg merge
3d 3h
Merged PRs (30d)
85

Description

# The issue
Too many tools confuse even the SotA models even with 1M context window, creating [context rot issue](https://github.com/chroma-core/context-rot) 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)

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the repository's existing MCP tool-selection flow and the referenced mcp-use implementation. Define the semantic pre-filtering scope, retrieval and reranking choices, and evaluation criteria for tool-selection quality and token reduction before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, databases, search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.