Proposal for an MCP-RAG System in Cursor IDE: Optimizing Intelligent MCP Tool Selection

Overview

As the number of MCP (Model Context Protocol) tools in Cursor IDE increases, prompt bloat and the growing complexity of tool selection for LLMs (Large Language Models) present significant challenges. Currently, Cursor supports up to 40 tools. however, this approach still carries the potential for inefficiency and reduced accuracy. This proposal suggests the introduction of an intelligent MCP tool selection system named “MCP-RAG” for Cursor IDE, by directly applying the ideas presented in the paper “RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation” (arXiv:2505.03275) by Tiantian Gan and Qiyao Sun. This system aims to efficiently pre-select the most suitable tools for a user’s request using RAG technology before passing tool information to the LLM.

Current Situation & Problems

  1. Prompt Bloat: As the number of integrated MCP tools grows, attempting to include all tool information in the LLM prompt can exceed context length limits or drastically increase token usage, leading to higher API costs and slower response times.
  2. Tool Selection Complexity and Reduced Accuracy: The burden on the LLM to identify and select the optimal tool from numerous descriptions increases the likelihood of task failure and can impair the accuracy of results due to distractions from irrelevant tools.
  3. Scalability Limitations: The current fixed-limit approach to tool quantity will struggle to maintain effectiveness as a wider variety of MCP tools are added in the future.

Proposed Solution: Introduction of an MCP-RAG System

We propose building an MCP-RAG system within Cursor IDE by adopting the core principles of the framework presented in the “RAG-MCP” paper:

  1. MCP Tool Indexing (External Indexing): Metadata for all MCP tools registered in Cursor—including descriptions, functionalities, schemas, and usage examples—will be vector-embedded and stored in an external, searchable index.
  2. Request-Based Retrieval: When a user request (query) is received, it will be embedded, and a semantic search will be performed against the MCP tool index to retrieve the top-K most semantically similar and relevant MCP tools. (Corresponds to the Retriever stage in the paper.)
  3. Selective Prompting: Only information about the small subset of MCP tools selected during the retrieval phase will be included in the prompt sent to the LLM. This frees the LLM from processing a large volume of tool information irrelevant to the task.
  4. LLM Tool Execution: The LLM will then perform the task based on the tool information provided within this optimized context.

Expected Benefits (Including effects demonstrated in the RAG-MCP paper):

  1. Significant Prompt Token Reduction: By delivering only relevant MCP tool information, prompt token counts can be drastically reduced by over 50%, as reported in the paper.
  2. Substantial Improvement in Tool Selection Accuracy: Reducing the information load on the LLM prevents confusion and allows it to focus on task-relevant tools, thereby potentially more than tripling tool selection accuracy (e.g., from 13.62% to 43.13% based on the paper’s benchmarks).
  3. Improved Cost Efficiency and Response Speed: Reduced token usage directly translates to lower API costs and contributes to faster LLM processing due to lighter prompts.
  4. Excellent Scalability: As new MCP tools are added, only the external index needs updating, without requiring retraining of the entire LLM. This significantly enhances system scalability and maintainability.
  5. Optimized Resource Usage: Selectively considering only necessary MCPs can reduce potential resource wastage.

Core Idea & Reference Paper

This MCP-RAG system proposal is directly based on the methodology and experimental results presented in the following paper:

  • Paper Title: RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation
  • Authors: Tiantian Gan, Qiyao Sun
  • ArXiv Link: https://arxiv.org/abs/2505.03275

This paper details a framework that utilizes RAG in an MCP environment to offload the LLM’s tool discovery process, thereby addressing prompt bloat issues and improving tool selection accuracy.

Conclusion

Introducing the MCP-RAG system into Cursor IDE, as demonstrated by the “RAG-MCP” paper, would be a significant strategy to maximize the efficiency and accuracy of MCP tool utilization. This will enable users to experience Cursor IDE’s rich tool ecosystem in a more powerful and scalable manner. We request your positive consideration of this proposal.

2 Likes