AegisRAG
Provides tools for listing and fetching files from a scoped Google Drive folder, with MIME-type-aware extraction for Docs, Sheets, PDFs, and other formats.
Provides tools for listing and fetching Notion pages, recursively converting block content into normalized text for ingestion.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AegisRAGlist the Notion pages and Drive files in the Royal Industries corpus"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AegisRAG – Enterprise RAG Strategy Evaluator & MCP Knowledge Agent
An enterprise-grade autonomous knowledge agent utilizing the Model Context Protocol (MCP), LangGraph, and Guardrails AI, featuring a rigorous RAGAS-scored chunking-strategy evaluation harness.
🚀 Overview
AegisRAG is a production-ready AI engineering project that moves beyond basic "upload a PDF" demos. It simulates a real-world enterprise environment (Royal Industries) with unstructured and structured data scattered across Notion and Google Drive.
The system leverages a LangGraph multi-agent workflow connected to a custom Model Context Protocol (MCP) Server for secure, live ingestion. Furthermore, rather than guessing which retrieval method works best, the project implements a rigorous evaluation harness using RAGAS to benchmark 4 distinct retrieval strategies, ensuring data-backed architecture decisions. Final outputs are secured using Guardrails AI to prevent hallucinations and redact PII.
Related MCP server: Docs MCP Server
✨ Key Achievements
Model Context Protocol (MCP): Architected a custom MCP server connecting a LangGraph agent to live Notion and Google Drive workspaces, enabling secure, natural-language querying over enterprise documentation.
RAG Evaluation Harness: Designed and benchmarked 4 retrieval strategies (fixed-size, semantic, hierarchical chunking, and hybrid BM25+vector search) against a 50-query ground-truth dataset using the Ragas framework.
Measurable Improvements: The comparative evaluation identified Hybrid BM25+Vector Search as the optimal strategy, improving Context Precision@5 from 51% to 83% and Answer Faithfulness to 96%.
Enterprise Guardrails: Enforced strict source-grounded generation with inline citation tagging and integrated Guardrails AI for hallucination detection, off-topic blocking, and PII redaction across all agent responses.
🏗️ Project Architecture & Phases
Phase | Description | Status |
0 – Corpus | 11 synthetic Royal Industries documents across Notion + Drive | ✓ Complete |
1 – MCP Server | Live Notion + Google Drive connectors behind a unified MCP tool interface | ✓ Complete |
2 – Retrieval Engineering | Four distinct chunking/retrieval strategies implemented (Fixed, Semantic, Hierarchical, Hybrid) | ✓ Complete |
3 – Eval Harness | RAGAS-scored comparison across 50 curated queries establishing the 83% Context Precision benchmark | ✓ Complete |
4 – Guardrails Pipeline | Citation-backed LangGraph agent generation with Guardrails AI hallucination/PII protection | ✓ Complete |
Architecture Diagram
graph TD
subgraph Client [LangGraph Agent Workflows]
A[User Query] --> B(LangGraph Router Agent)
B -->|Tool Call| C{MCP Client}
B -->|RAG| G[ChromaDB Vector Store]
G --> H[Generation Agent]
H --> I{Guardrails AI}
I -->|Pass| J[Secure Response + Citations]
I -->|Fail| K[Redacted/Blocked Response]
end
subgraph Server [AegisRAG MCP Server]
C -->|stdio| D[MCP Server Interface]
D --> E[Notion Connector]
D --> F[Google Drive Connector]
end
E -->|API| L[(Notion Workspace)]
F -->|OAuth| M[(Google Drive)]📊 RAGAS Evaluation Results
Most RAG demos apply one chunking strategy without justification and evaluate it qualitatively. AegisRAG was built to answer the question: for a realistic, multi-source enterprise knowledgebase, which retrieval strategy actually performs best, and by how much?
Using a LLaMA 70B judge model on a 50-query dataset, the strategies yielded the following results:
Strategy | Context Precision@5 | Context Recall | Faithfulness | Answer Relevancy |
Fixed-Size Chunking (Baseline) | 51.2% | 63.4% | 71.1% | 85.0% |
Semantic Chunking | 68.5% | 72.1% | 84.3% | 88.2% |
Hierarchical Chunking | 74.0% | 81.5% | 91.0% | 91.5% |
Hybrid (BM25 + Vector + RRF) | 83.1% | 89.2% | 96.4% | 94.8% |
Note: Hybrid retrieval combined with structure-aware processing proved essential for retrieving tabular data hidden within Google Sheets alongside prose policies in Notion.
🛠️ Setup & Installation
Prerequisites
Python 3.10+
A Notion workspace with a Personal Access Token (PAT)
A Google Cloud project with Drive API enabled (OAuth 2.0 Desktop credentials)
API Keys for LLM usage (OpenAI, Groq, etc.)
Installation
# Clone the repo
git clone https://github.com/Yash22o2/AegisRAG.git
cd AegisRAG
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # macOS/Linux (or .venv\Scripts\activate for Windows)
# Install dependencies
pip install -r requirements.txtConfiguration
Create a .env file in the project root:
NOTION_API_KEY=your_notion_pat_here
GOOGLE_CREDENTIALS_PATH=credentials.json
DRIVE_FOLDER_ID=your_drive_folder_id_here
GROQ_API_KEY=your_api_key
OPENAI_API_KEY=your_api_keyRunning the System
Authorize Google Drive:
python authorize_drive.py(One-time setup)Test MCP Connectors:
python test_mcp_connection.pyRun Ingestion & Chunking:
python ingest.pyRun RAGAS Evaluation Harness:
python evaluate.pyStart LangGraph Agent:
python agent.py
🔒 Security & Guardrails
Enterprise environments require strict data security. The final generation pipeline enforces:
Source Grounding: All answers must be strictly grounded in the retrieved context.
Inline Citations: Every claim is tagged with
[Source: Doc_ID].PII Redaction: Guardrails AI intercepts and masks Personal Identifiable Information before it reaches the user.
Off-topic Blocking: Queries unrelated to the corporate knowledgebase are safely deflected.
License
MIT License
This server cannot be deployed
Maintenance
Related MCP Connectors
Make your knowledge agent-ready. One MCP endpoint, 5 connectors, 3 search modes.
Ingest, manage, and retrieve documents for RAG-powered AI applications
Team docs served to AI agents over MCP - search, Markdown reads, version pinning, read audit.
Publish and share access-controlled Markdown documents from any MCP-enabled AI tool.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA multi-backend gateway that enables access to various services like Google Drive and Notion through a single MCP connector. It currently provides comprehensive Google Drive integration for reading, writing, and managing files and folders.MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude to interact with collaborative Docs instances, providing document management, content editing, access control, and AI-powered transformations via MCP.1MIT
- AlicenseNot gradedqualityDmaintenanceProvides RAG (Retrieval Augmented Generation) access to technical documentation through MCP, enabling LLMs to search and retrieve relevant documentation on-demand.4MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to securely search and ingest corporate documents via MCP, offering hybrid retrieval, PII sanitization, role-based access control, and citation validation.MIT