Users → Search → Answer = 😫
A local, intelligent Q&A system using:
┌──────────────────────┐
│ User Interface │ (CLI)
└──────────┬───────────┘
│
┌─────┴─────┐
▼ ▼
[RAG] [MCP]
Query Tools
│ │
└─────┬─────┘
▼
[Ollama LLM]
┌────────────────┐
│ FAISS Index │ Vector Database
│ + MCP Tools │
└────────┬───────┘
│
┌────▼─────┐
│ docs/ │
│directory │
└──────────┘
MCP provides standardized interface for LLM tool access:
read_document(file_path)
list_documents()
search_documents(query)
Language: Python 3.10+
Vector DB: FAISS
Embeddings: SentenceTransformers
LLM: Ollama (local)
MCP: FastMCP
src/
├── config.py Configuration
├── main.py CLI entry point
├── assistant.py Main orchestrator
├── rag/
│ ├── ingest.py Load documents
│ ├── chunk.py Split text
│ ├── embed.py Generate embeddings
│ ├── build_index.py Build FAISS index
│ └── query.py Retrieve & generate
├── mcp/
│ ├── server.py MCP tool definitions
│ └── client.py MCP client wrapper
└── docs/ Documentation
$ python main.py build-index
1. Load documents
↓
2. Split into chunks
↓
3. Generate embeddings
↓
4. Build FAISS index
↓
5. Save files
User Question
↓
Embed question
↓
Search FAISS → Top 5 chunks
↓
LLM decides: Use MCP tools?
↓
Build prompt + context
↓
Call Ollama
↓
Return answer + sources
CHUNK_SIZE = 700
CHUNK_OVERLAP = 100
EMBEDDING_MODEL = "all-MiniLM-L6-v2"
OLLAMA_MODEL = "qwen3:0.6b"
TOP_K = 5
$ python main.py
Output:
🤖 Company Knowledge Base
Ask questions about documentation
Type 'exit' to stop
❓ What are company values?
🤖 Innovation, integrity, collaboration
📚 Sources:
• Loan Rangers Team.md
• Info Security.md
❓ What documents do we have?
🤖 [Uses MCP list_documents]
• Loan Rangers Team.md
• Information Security.md
• Services.md
❓ Full security policy?
🤖 [Uses MCP read_document]
[Full document content...]
Cloud: Data → Internet → Server - ⚠️ Network transmission - ⚠️ External storage - ⚠️ Subscription costs
Local: Data → Local System - ✅ No transmission - ✅ Local storage only - ✅ No costs
Index Building: ~30s (one-time)
Query Embedding: ~50ms
FAISS Search: ~5ms
LLM Generation: 2-5s
Total Cycle: 2-6s
# Faster (smaller model):
OLLAMA_MODEL = "qwen3:0.6b"
# Faster retrieval:
TOP_K = 3
CHUNK_SIZE = 500
1. Install Ollama & Python deps
2. Copy docs/ to server
3. Build index
4. Run with nohup
$ nohup python main.py > log &
[HTTP Clients] [HTTP Clients + Webllm]
↓ ↓
[FastAPI] [FastAPI]
↓ ↓
[Ollama + FAISS] [FAISS]
[Clients] → [Load Balancer]
↓
[Multiple Retrievers]
Docs Index Build
10 MB ~2 MB ~5s
100 MB ~20 MB ~30s
1 GB ~200 MB ~5min
| Aspect | Traditional | Our RAG |
|---|---|---|
| Understanding | Keywords | Semantic |
| Answers | Documents | Direct |
| Privacy | Cloud | Local |
| Cost | Subscription | One-time |
| Speed | Slow | Sub-second |
# Build index
python main.py build-index
# Run interactively
python main.py
# Check config
cat config.py
Thank You!
$ claude mcp add local-rag-mcp \
-- python -m otcore.mcp_server <graph>