local-rag-mcp

local-rag-mcp

A privacy-preserving local RAG system integrated with MCP, enabling natural language queries over ingested documents and a SQLite database through vector search and local database tools.

Category
Visit Server

README

šŸ”’ Privacy-Preserving Local RAG with MCP Integration

A production-grade, fully local Retrieval-Augmented Generation (RAG) system integrated with the Model Context Protocol (MCP). Zero data ever leaves your machine.

Architecture

User CLI  →  Agent Orchestrator  →  MCP Client (stdio)
                                          ↓
                               ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
                               │     MCP Server        │
                               │  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”  │
                               │  │  vector_search  │  │
                               │  │  local_db_query │  │
                               │  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜  │
                               ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                                    ↓           ↓
                               Qdrant DB    SQLite DB
                               (Docker)   (employees)

Tech Stack

Component Technology
LLM Inference Ollama (Llama 3)
Embeddings Ollama (nomic-embed-text, 768d)
Vector Store Qdrant (Docker)
Re-ranking Cross-Encoder (ms-marco-MiniLM-L-6-v2)
MCP Server FastMCP (Python SDK v1.x)
Chunking SemanticChunker (LangChain Experimental)
Config Pydantic Settings
Logging structlog (JSON structured)

Prerequisites

  • Python 3.11+
  • Docker & Docker Compose
  • Ollama installed and running
  • At least 8GB RAM (16GB recommended)

Quick Start

1. Clone & Configure

git clone <repo-url>
cd local-rag-mcp
cp .env.example .env

2. Start Qdrant

docker compose up -d
# Verify: open http://localhost:6333/dashboard

3. Pull Ollama Models

# On Linux/macOS:
bash scripts/pull_models.sh

# On Windows (PowerShell):
ollama pull llama3
ollama pull nomic-embed-text

4. Create Python Environment

python -m venv .venv

# Linux/macOS:
source .venv/bin/activate

# Windows:
.venv\Scripts\activate

pip install -r requirements.txt

5. Seed the SQLite Database

python scripts/seed_database.py

6. Ingest Documents

python main.py
# Inside the REPL:
> /ingest data/documents

7. Run the Agent

python main.py
> What does our documentation say about authentication?
> List all employees in the Engineering department
> How many engineers earn above the department average?

Project Structure

local-rag-mcp/
ā”œā”€ā”€ docker-compose.yml       # Qdrant container
ā”œā”€ā”€ .env.example             # Config template
ā”œā”€ā”€ requirements.txt         # Pinned deps
ā”œā”€ā”€ pyproject.toml           # Project metadata & tool config
│
ā”œā”€ā”€ config/
│   └── settings.py          # Centralized Pydantic config
│
ā”œā”€ā”€ data/
│   ā”œā”€ā”€ documents/           # Drop PDFs/Markdown here
│   └── sqlite/
│       └── employees.db     # Auto-seeded SQLite DB
│
ā”œā”€ā”€ scripts/
│   ā”œā”€ā”€ seed_database.py     # Seeds employee DB
│   └── pull_models.sh       # Ollama model helper
│
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ ingestion/           # PDF/MD loader, semantic chunker, embedder
│   ā”œā”€ā”€ mcp_server/          # FastMCP server + vector_search + local_db_query tools
│   ā”œā”€ā”€ agent/               # Agent loop + HyDE
│   └── utils/               # Structured logging
│
ā”œā”€ā”€ tests/                   # Pytest test suite
└── main.py                  # CLI REPL entry point

CLI Commands

Command Description
/ingest <path> Ingest all PDFs/Markdown from directory
/hyde on|off Toggle HyDE query enhancement
/help Show available commands
/quit Exit the application
Any other text Ask the agent a question

Configuration

All settings are controlled via .env. Key variables:

Variable Default Description
OLLAMA_LLM_MODEL llama3 LLM for generation & tool calling
OLLAMA_EMBEDDING_MODEL nomic-embed-text Embedding model
QDRANT_COLLECTION_NAME rag_documents Qdrant collection name
HYDE_ENABLED true Enable HyDE query enhancement
RERANKER_TOP_K 5 Number of final results after re-ranking

Running Tests

pytest tests/ -v

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured