
rag
Example of a Rag and swift parser
Repository Info
About This Server
Example of a Rag and swift parser
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
🔍 Teach AI Your Internal Library (RAG for Custom Codebases)
This project shows how to turn your internal codebase into a searchable, intelligent assistant using Retrieval-Augmented Generation (RAG), without retraining any models or exposing private code.
💡 Why This Matters
Most organizations use custom libraries that AI coding agents can't access. This project bridges that gap by:
- Parsing your code into meaningful chunks
- Generating natural language summaries with a local LLM
- Storing and retrieving these chunks with a vector DB
- Serving them to an LLM via API for intelligent Q&A
🧱 Architecture
Codebase → Parser → Chunks → LLM Summaries → Vector DB
↓
RAG API via FastAPI
↓
→ Smart AI Answers
You can also inject this context into any MCP server used by coding agents.
📂 Components
1. Parser.py / Parser_chroma.py
- Parses
.swiftfiles (or any similar structured language) - Extracts declarations (classes, funcs, etc.)
- Summarizes each chunk using Phi-3-mini
- Outputs to markdown or ChromaDB
2. rag_server.py
- FastAPI server
- Accepts natural language queries
- Uses semantic search from ChromaDB
- Builds prompts and sends to the LLM
- Returns helpful contextual answers
🚀 How to Run
Prerequisites
- Python 3.10+
- Local LLM running at
http://localhost:1234(e.g., Phi-3-mini via LM Studio) chromafor vector storage
pip install httpx chromadb fastapi uvicorn
Step 1: Parse & Summarize
python Parser_chroma.py
This will:
- Walk through the
./BPdirectory - Extract Swift code chunks
- Generate summaries
- Store them in ChromaDB
Step 2: Start the RAG API Server
uvicorn rag_server:app --reload
Step 3: Ask Questions
Send a POST request:
POST /ask
{
"query": "What does the LoginCard component do?",
"top_k": 5
}
🧪 Tested On
- Custom Swift-like component library mimicking Bootstrap
- Local setup using
Phi-3-miniLLM - Works offline and secure (no cloud calls)
🧠 Future Additions
- Tree-sitter-based language support
- UI interface for interactive exploration
- Support for other languages beyond Swift
📜 License
MIT License — Use it, extend it, contribute to it.
🙌 Credits
Created by Renjith For devs who want their AI to actually understand their code.
Quick Start
Clone the repository
git clone https://github.com/renjithr/ragInstall dependencies
cd rag
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.