How to build an MCP server to connect Cursor to a RAG system (GroundX)

UnderfittedAbout 5 min readMar 17, 2025Watch original
THE SUMMARYAI-generated

Key Concepts

  • mCP Server: A server that allows tools, resources, or products to be shared.
  • Ground X: An enterprise-grade RAG (Retrieval-Augmented Generation) system that can be run on the cloud or internally within a Kubernetes instance.
  • RAG (Retrieval-Augmented Generation): A framework for augmenting LLMs with external knowledge.
  • Topics/Buckets: Group of related documents within Ground X.
  • Cursor: An IDE that supports mCP servers.
  • LLM (Large Language Model): The AI model used by Cursor to answer questions.
  • Ground X API/SDK: Tools used to interact with the Ground X system.

Ground X and Cursor Integration via mCP Server

Problem Statement

The presenter wants to enhance the Cursor IDE with access to class-related documentation stored in Ground X, enabling students to ask questions and receive contextually relevant answers.

Solution Architecture

The solution involves creating an mCP server that acts as an intermediary between Cursor and Ground X. Cursor uses this server to access information stored in Ground X.

  • Data Source: Documentation (tutorials, assignments, session PDFs) stored in Ground X.
  • mCP Server: A custom server built to expose Ground X data as tools.
  • Cursor IDE: The development environment where users interact with the AI agent.

Ground X Overview

  • Ground X is described as an enterprise-grade RAG system.
  • It can be deployed on the cloud or within a private Kubernetes cluster.
  • Data is organized into "buckets," referred to as "topics" in the video.
  • The presenter has four buckets: Leica camera, AI car, a Walmart presentation, and ML school (class materials).
  • Ground X performs preprocessing on documents, including extracting bounding boxes from PDFs, enabling it to understand the structure and content of complex documents.

mCP Server Implementation

The mCP server is implemented in Python and uses the Ground X API to interact with the RAG system.

  • Tools: The server exposes two tools:
    • list_available_rack_topics: Returns a list of available buckets (topics) in Ground X, including their IDs and names.
    • get_rack_context_by_topic: Given a topic ID and a query, retrieves relevant text passages from Ground X.
  • API Calls: The Ground X API is used to:
    • List available buckets.
    • Search for relevant documents within a specified bucket based on a query.
  • Data Retrieval: The get_rack_context_by_topic tool limits the results from Ground X to 10 answers and concatenates the text from these results into a single string for the LLM.
  • Configuration: The server uses environment variables for configuration, such as the Ground X API key and base URL.

Cursor Integration

  • The mCP server is registered with Cursor through the Cursor settings.
  • Cursor settings now have a dedicated "mCP" section (previously under "Features").
  • The command to run the mCP server (using uv and Python) is specified in the Cursor settings.
  • Cursor automatically detects the tools exposed by the mCP server.

Demonstration and Examples

The presenter demonstrates the integration with several examples:

  1. Leica Camera Specifications: Asking about the specifications of a Leica viewfinder.
    • Cursor uses the list_available_rack_topics tool to identify the "Leica" topic.
    • It then uses the get_rack_context_by_topic tool to retrieve relevant information from the Leica bucket.
    • The LLM in Cursor presents the information in a user-friendly format.
  2. ML School Session Content: Asking about the topics covered in session six of the ML school.
    • Cursor identifies the "ML School" topic.
    • It retrieves relevant information about session six from the ML School bucket.
    • The LLM accurately lists the topics covered in that session.
  3. Walmart Supply Chain Document: Asking about a specific step in a diagram within the Walmart document.
    • Cursor identifies the "Walmart" topic.
    • It retrieves information related to the diagram and the specified step (shipping LTL from the Fulfillment Center).
    • The LLM correctly identifies the corresponding action (following the ISTA 3B protocol).
    • A follow-up question about the alternative scenario (not shipping LTL) is also answered correctly, demonstrating the system's ability to understand and reason about complex documents.

Key Arguments and Perspectives

  • Ease of Integration: The presenter emphasizes the simplicity of connecting different APIs to an IDE using an mCP server.
  • Data Privacy: Ground X can be run locally, ensuring that data does not leave the user's network.
  • Contextual Understanding: Ground X's preprocessing capabilities enable the system to understand the structure and content of complex documents, including diagrams and tables.
  • LLM Empowerment: By providing the LLM with access to relevant information through the mCP server and Ground X, the system can answer questions more accurately and comprehensively.

Notable Quotes

  • "This thing is sick and all of it is by connecting my IDE to a rack application using a very very simple uh mCP server in the middle acting as a glue and this is sick stuff" - Expressing excitement about the capabilities of the integrated system.

Technical Terms

  • Bounding Boxes: Rectangular regions used to identify and extract elements from documents, particularly images and PDFs.
  • Similarity Search: A technique used by Ground X to find documents that are semantically similar to a given query.
  • Transport Standard In/Out: A method for communication between the mCP server and the IDE.

Logical Connections

The video logically connects the problem of accessing external data within an IDE to the solution of using an mCP server as a bridge to a RAG system (Ground X). It demonstrates how the mCP server exposes Ground X's capabilities as tools that the LLM in Cursor can use to answer questions.

Synthesis/Conclusion

The video demonstrates a powerful integration between the Cursor IDE and the Ground X RAG system using a simple mCP server. This integration allows users to ask questions about their data stored in Ground X and receive accurate and contextually relevant answers, enhancing productivity and knowledge discovery. The presenter highlights the ease of implementation, data privacy benefits, and the ability to understand complex documents as key advantages of this approach.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.