MCP-RAG

sujithadr/MCP-RAG

3.1

If you are the rightful owner of MCP-RAG and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

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

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

RoleComponent
Tool discovery/invokeMCP Server
Search executionGroundX API
Response generationOpenAI API
File uploadIngest Tool (MCP)

šŸ“š License

This project is licensed under the .


šŸ‘Øā€šŸ’» 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).