MCP-RAG: Modular RAG Pipeline using MCP & GroundX

by sujithadr

222 downloads
Not rated
GitHub

About

MCP server Implantation for RAG (GroundX API)

Details

Author
sujithadr
Downloads
222
Categories
Knowledge Base

- Modular tool design using MCP server interface
- YAML-based prompt templates with Jinja2 rendering
- PDF file ingestion into GroundX vector store
- Real-time semantic search via GroundX Search Tool
- Plug-and-play API integration for new tools

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP-RAG: Modular RAG Pipeline using MCP & GroundX
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Set up a .env file with your OPENAI_API_KEY and GROUNDEX_API_KEY, then install dependencies with uv pip install -r pyproject.toml. Start the MCP server with mcp dev server.py. Ingest a PDF using mcp call ingest_documents --args '{"file_path": "data/sample.pdf"}' and perform a search with mcp call process_search_query --args '{"query": "What is explained in section 3?"}'.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp-rag: modular rag pipeline using mcp & groundx": {
            "mcp-rag-sujithadr": {
                "command": "uv",
                "args": [
                    "pip",
                    "install",
                    "-r",
                    "pyproject.toml"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-rag-sujithadr": {
        "command": "uv",
        "args": [
            "pip",
            "install",
            "-r",
            "pyproject.toml"
        ]
    }
}

MCP-RAG: Modular RAG Pipeline using MCP & GroundX

A production-ready Retrieval-Augmented Generation setup

License
Python

πŸš€ Overview

MCP-RAG is a modular, production-grade implementation of a Retrieval-Augmented Generation (RAG) system, powered by:

- 🧠 MCP (Model Context Protocol) for standardized tool orchestration
- πŸ” GroundX for semantic search, ingestion, and vector store operations
- πŸ€– OpenAI GPT-4 for LLM-powered contextual response generation

It allows clean separation of responsibilities across ingestion, search, generation, and tool discovery β€” making it scalable, flexible, and enterprise-ready.

> πŸ“Œ Developed by Sujith Somanunnithan for teams building AI-driven applications with reusable components.

---

πŸ“¦ Features

- πŸ”§ Modular Tool Design using MCP server interface
- 🧩 YAML-Based Prompt Templates with Jinja2 rendering
- πŸ“‚ PDF File Ingestion into GroundX vector store
- πŸ” Real-Time Semantic Search via GroundX Search Tool
- 🀝 Plug-and-Play API Integration for new tools and services

---

πŸ“ Project Structure

mcp-rag/
β”œβ”€β”€ server.py                     # MCP Server initialization
β”œβ”€β”€ config.py                     # Environment and config management
β”œβ”€β”€ ingestion.py                  # File ingestion tool logic
β”œβ”€β”€ search.py                     # Search + LLM generation logic
β”œβ”€β”€ prompts.yaml                  # Prompt template in Jinja2
β”œβ”€β”€ models.py                     # Pydantic models for configs
β”œβ”€β”€ .env                          # API keys (excluded from version control)
β”œβ”€β”€ pyproject.toml                # Project config for uv / MCP
β”œβ”€β”€ README.md                     # This file

---

🧠 Architectural Flow

1. User query arrives at the MCP server
2. Server routes it to the Search Tool
3. Search Tool queries GroundX API
4. Snippets are rendered via YAML prompt
5. OpenAI API generates final LLM response

> πŸ”„ All tools are discoverable and invocable via MCP dynamically.

---

πŸ”‘ Environment Setup

Create .env with your keys:

OPENAI_API_KEY=your-openai-key
GROUNDEX_API_KEY=your-groundx-key

Install using uv:

uv pip install -r pyproject.toml

---

βš™οΈ Usage

Start the server:

mcp dev server.py

Ingest a PDF:

mcp call ingest_documents --args '{"file_path": "data/sample.pdf"}'

Search with a query:

mcp call process_search_query --args '{"query": "What is explained in section 3?"}'

---

πŸ“Œ Clean Separation of Concerns

| Role | Component |
|-------------------------|------------------------|
| Tool discovery/invoke | MCP Server |
| Search execution | GroundX API |
| Response generation | OpenAI API |
| File upload | Ingest Tool (MCP) |

---

πŸ“š License

This project is licensed under the MIT License.

---

πŸ‘¨β€πŸ’» Author

Sujith Somanunnithan
Cloud & AI Architect | sujith.de

---

πŸ’¬ Feedback & Contributions

Feel free to raise issues, pull requests, or connect with the author for improvements or extensions (like multi-file ingestion, RAG fallback chains, etc).

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.