RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation

Large language models (LLMs) struggle to effectively utilize a growing number of external tools, such as those defined by the Model Context Protocol (MCP)\cite{IntroducingMCP}, due to prompt bloat and selection complexity. We introduce RAG-MCP, a Retrieval-Augmented Generation framework that overcomes this challenge by offloading tool discovery. RAG-MCP uses semantic retrieval to identify the most relevant MCP(s) for a given query from an external index before engaging the LLM. Only the selected tool descriptions are passed to the model, drastically reducing prompt size and simplifying decision-making. 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) on benchmark tasks. RAG-MCP enables scalable and accurate tool integration for LLMs.

Paper

References (16)

08Selection & Validation : The retriever searches the vector index of MCP schemas, ranks candidates by semantic similarity, and optionally tests each via synthetic examples
09Evaluation report on mcp servers (2025)arxiv.org
10Validation. For each retrieved MCP, RAG-MCP can generate a few-shot example query and test its response to ensure basic compatibility, functioning as a “sanity check” before invocation
11Actual Match : Pre-filter the candidate pool using simple keyword matching on the task description and MCP metadata, then prompt the model on this reduced set
12What is retrieval-augmented generation aka rag (2025)blogs

Scroll for more · 4 remaining

Similar papers

© 2026 NYSGPT2525 LLC