Multi-knowledge-base RAG system with MCP integration
Project description
Ragnest
Multi-knowledge-base RAG system with MCP integration for Claude Code.
Create multiple knowledge bases, each with its own embedding model, chunk settings, and vector backend. Search them from Claude Code via 27 MCP tools.
Installation
pip install ragnest
Prerequisites
- Python 3.12+
- PostgreSQL with pgvector extension
- Ollama for local embeddings
Quick Start
1. Start PostgreSQL with pgvector
# Using the included Docker Compose
git clone https://github.com/november-pain/ragnest.git
cd ragnest
docker compose up -d
Or use any PostgreSQL 15+ instance with pgvector installed.
2. Configure
cp config.example.yaml config.yaml
Edit config.yaml:
database:
host: localhost
port: 5433
name: ragnest
ollama:
base_url: http://localhost:11434
Create .env with database credentials:
RAGNEST_DATABASE__USER=ragnest
RAGNEST_DATABASE__PASSWORD=yourpassword
3. Install Ollama and pull an embedding model
brew install ollama && brew services start ollama
ollama pull bge-m3
4. Add to Claude Code
claude mcp add ragnest -- uvx ragnest
Database and schema are auto-initialized when the MCP server starts.
Usage
Initialize a knowledge base from a folder
init_kb("my_docs", "/path/to/docs", "bge-m3", file_patterns="*.py,*.md")
Creates the KB, sets a watch path with file filtering, and queues files for embedding.
Run the worker
ragnest-worker --scan --kb my_docs
The worker processes the queue: reads files, chunks text, generates embeddings via Ollama, and stores vectors in PostgreSQL.
Search
search_kb("my_docs", "how does authentication work", top_k=5)
search_all_kbs("deployment process", top_k_per_kb=3)
Returns ranked results with source filenames, scores, and text chunks.
Architecture
Claude Code ──MCP──▶ MCP Server (27 tools)
│
┌──────────┼──────────┐
▼ ▼
SQLite Vector Backend
(local state) (pgvector)
│ ▲
└──────▶ Worker ──────┘
│
Ollama
(embeddings)
Two-layer storage:
| Layer | Engine | Stores | Purpose |
|---|---|---|---|
| State | SQLite | KBs, documents, batches, queue, watch paths | Local, zero-config, works offline |
| Vectors | PostgreSQL + pgvector | Chunks with embeddings + inline metadata | Portable, queryable by external systems |
MCP Tools
| Category | Tools |
|---|---|
| Search | search_kb, search_all_kbs, get_similar_documents |
| KB Management | list_kbs, create_kb, update_kb, delete_kb, init_kb |
| Watch Paths | add_watch_path, remove_watch_path, list_watch_paths, pause_watch_path, resume_watch_path |
| Ingestion | add_file, add_directory, add_text |
| Batches | batch_status, list_batches, undo_batch, worker_status, trigger_scan |
| Documents | list_documents, delete_document |
| System | db_status, list_models, system_info |
| Export | export_knowledge_base |
Features
- Multiple knowledge bases — each with its own embedding model, dimensions, and chunk settings
- Per-KB backend routing — route different KBs to different PostgreSQL databases
- External KB support — connect to remote vector stores in read-only or read-write mode
- Watch paths with file filtering — glob patterns like
*.py,*.mdto control what gets indexed - Batch tracking — view progress, retry failures, undo entire batches
- Resilient worker — per-file commits, SIGINT/SIGTERM handling, resume on restart
- Content deduplication — SHA-256 hashing skips unchanged files
- Cross-KB search — search all knowledge bases in one call
- Export — Parquet or JSON with model metadata sidecar
Configuration
Basic
# config.yaml
database:
host: localhost
port: 5433
name: ragnest
ollama:
base_url: http://localhost:11434
defaults:
chunk_size: 1000
chunk_overlap: 200
# .env
RAGNEST_DATABASE__USER=ragnest
RAGNEST_DATABASE__PASSWORD=yourpassword
Multiple backends
databases:
local:
host: localhost
port: 5433
name: ragnest
cloud:
host: xyz.supabase.co
port: 5432
name: postgres
Then specify backend="cloud" when creating a KB.
Worker
ragnest-worker --scan # Scan watch paths + process queue
ragnest-worker --scan --kb my_docs # Specific KB only
ragnest-worker --retry # Retry failed files
ragnest-worker --scan --dry-run # Preview what would be queued
Deploy files for launchd and systemd are included for scheduled runs.
Development
git clone https://github.com/november-pain/ragnest.git
cd ragnest
pip install -e ".[dev]"
make lint # ruff check + format
make typecheck # mypy + basedpyright (strict)
make test # pytest (113 tests)
Project Structure
src/ragnest/
├── app.py # Application container + wiring
├── config.py # Pydantic Settings + YAML
├── exceptions.py # Exception hierarchy
├── models/ # Pydantic domain + DB row models
├── db/
│ ├── backends/ # PostgreSQL, SQLite implementations
│ ├── repositories/ # 6 data access repositories
│ ├── schema.py # Vector DDL + index management
│ └── sqlite_schema.py # Local state DDL
├── services/ # Business logic (7 services)
├── mcp/
│ ├── server.py # FastMCP app factory
│ └── tools/ # 8 tool modules (27 tools)
└── cli/ # Worker + DB setup entrypoints
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ragnest-0.1.3.tar.gz.
File metadata
- Download URL: ragnest-0.1.3.tar.gz
- Upload date:
- Size: 56.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5004d4164e0a74a340e5d9f8a7ec07b2c2c56a2a44693727d6df2638a71b566
|
|
| MD5 |
d89c48cb2454db1bd7ccd551d4ef3b56
|
|
| BLAKE2b-256 |
e9ef9b7b839aa9419b71f16e8d04fb49adfa5b82f4b572fc41d4b4320ebdf86e
|
Provenance
The following attestation bundles were made for ragnest-0.1.3.tar.gz:
Publisher:
release.yml on november-pain/ragnest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ragnest-0.1.3.tar.gz -
Subject digest:
e5004d4164e0a74a340e5d9f8a7ec07b2c2c56a2a44693727d6df2638a71b566 - Sigstore transparency entry: 1155366411
- Sigstore integration time:
-
Permalink:
november-pain/ragnest@c98ebaf4746e5e0176ff80cea2e77c9d546627b0 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/november-pain
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c98ebaf4746e5e0176ff80cea2e77c9d546627b0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ragnest-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ragnest-0.1.3-py3-none-any.whl
- Upload date:
- Size: 67.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb025bbb25ba96ab54cb8c31fd553008d144603bf119f214fa48d5eee795ca5f
|
|
| MD5 |
a7c1ec1be928785b4dcf3cf0294430ff
|
|
| BLAKE2b-256 |
02e515fd60c222cf5e1fbc677fc19d4e99554d740d540ca85d2cf1c7353e14ae
|
Provenance
The following attestation bundles were made for ragnest-0.1.3-py3-none-any.whl:
Publisher:
release.yml on november-pain/ragnest
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ragnest-0.1.3-py3-none-any.whl -
Subject digest:
bb025bbb25ba96ab54cb8c31fd553008d144603bf119f214fa48d5eee795ca5f - Sigstore transparency entry: 1155366414
- Sigstore integration time:
-
Permalink:
november-pain/ragnest@c98ebaf4746e5e0176ff80cea2e77c9d546627b0 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/november-pain
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c98ebaf4746e5e0176ff80cea2e77c9d546627b0 -
Trigger Event:
push
-
Statement type: