knowledge-rag 4.2.0__tar.gz → 4.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- knowledge_rag-4.2.0/README.md → knowledge_rag-4.3.0/PKG-INFO +146 -11
- knowledge_rag-4.2.0/PKG-INFO → knowledge_rag-4.3.0/README.md +98 -51
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/__init__.py +1 -1
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/server.py +149 -13
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/pyproject.toml +13 -3
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/.gitignore +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/LICENSE +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/config.example.yaml +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/config.py +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/guarded.py +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/ingestion.py +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/instance_lock.py +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/metrics.py +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/preflight.py +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/mcp_server/ratelimit.py +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/npm/README.md +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/presets/cybersecurity.yaml +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/presets/developer.yaml +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/presets/general.yaml +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/presets/research.yaml +0 -0
- {knowledge_rag-4.2.0 → knowledge_rag-4.3.0}/requirements.txt +0 -0
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: knowledge-rag
|
|
3
|
+
Version: 4.3.0
|
|
4
|
+
Summary: Local RAG System for Claude Code — Hybrid search + Cross-encoder Reranking + 13 MCP Tools + 20 Format Parsers. Zero external servers.
|
|
5
|
+
Project-URL: Homepage, https://github.com/lyonzin/knowledge-rag
|
|
6
|
+
Project-URL: Repository, https://github.com/lyonzin/knowledge-rag
|
|
7
|
+
Project-URL: Issues, https://github.com/lyonzin/knowledge-rag/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/lyonzin/knowledge-rag/releases
|
|
9
|
+
Author-email: "Lyon." <lyonzin@users.noreply.github.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: bm25,chromadb,claude-code,embeddings,fastembed,hybrid-search,knowledge-base,local-ai,mcp,rag,reranking,retrieval-augmented-generation,semantic-search
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
24
|
+
Requires-Dist: chromadb>=1.4.0
|
|
25
|
+
Requires-Dist: fastembed[reranking]>=0.4.0
|
|
26
|
+
Requires-Dist: mcp>=1.6.0
|
|
27
|
+
Requires-Dist: numpy>=1.24.0
|
|
28
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
29
|
+
Requires-Dist: pymupdf>=1.23.0
|
|
30
|
+
Requires-Dist: python-docx>=1.0.0
|
|
31
|
+
Requires-Dist: python-pptx>=1.0.0
|
|
32
|
+
Requires-Dist: pyyaml>=6.0
|
|
33
|
+
Requires-Dist: requests>=2.33.0
|
|
34
|
+
Requires-Dist: watchdog>=4.0.0
|
|
35
|
+
Provides-Extra: gpu
|
|
36
|
+
Requires-Dist: nvidia-cublas-cu12; extra == 'gpu'
|
|
37
|
+
Requires-Dist: nvidia-cuda-runtime-cu12; extra == 'gpu'
|
|
38
|
+
Requires-Dist: nvidia-cudnn-cu12; extra == 'gpu'
|
|
39
|
+
Requires-Dist: nvidia-cufft-cu12; extra == 'gpu'
|
|
40
|
+
Requires-Dist: nvidia-curand-cu12; extra == 'gpu'
|
|
41
|
+
Requires-Dist: nvidia-cusolver-cu12; extra == 'gpu'
|
|
42
|
+
Requires-Dist: nvidia-cusparse-cu12; extra == 'gpu'
|
|
43
|
+
Requires-Dist: nvidia-nvjitlink-cu12; extra == 'gpu'
|
|
44
|
+
Requires-Dist: onnxruntime-gpu>=1.14.0; extra == 'gpu'
|
|
45
|
+
Provides-Extra: server
|
|
46
|
+
Requires-Dist: uvicorn>=0.20.0; extra == 'server'
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
1
49
|
# Knowledge RAG
|
|
2
50
|
|
|
3
51
|
<div align="center">
|
|
@@ -17,7 +65,7 @@
|
|
|
17
65
|
### Your docs, your machine, zero cloud. Claude Code searches them natively.
|
|
18
66
|
|
|
19
67
|
Drop your PDFs, markdown, code, notebooks — **1800+ files, 39K chunks, indexed in under 3 minutes.**<br/>
|
|
20
|
-
Hybrid search (BM25 + semantic vectors + cross-encoder reranking) through
|
|
68
|
+
Hybrid search (BM25 + semantic vectors + cross-encoder reranking) through 13 MCP tools.<br/>
|
|
21
69
|
Everything runs locally via ONNX. No Docker, no Ollama, no API keys, no data leaves your machine.
|
|
22
70
|
|
|
23
71
|
```
|
|
@@ -26,7 +74,7 @@ pip install knowledge-rag → restart Claude Code → search_knowledge("your que
|
|
|
26
74
|
|
|
27
75
|
---
|
|
28
76
|
|
|
29
|
-
**
|
|
77
|
+
**13 MCP Tools** | **Hybrid Search + Reranking** | **20 File Formats** | **Optional NVIDIA GPU** | **100% Local**
|
|
30
78
|
|
|
31
79
|
[What's New](#whats-new-in-v420) | [Supported Formats](#supported-formats) | [Installation](#installation) | [Configuration](#configuration) | [API Reference](#api-reference) | [Architecture](#architecture)
|
|
32
80
|
|
|
@@ -81,7 +129,7 @@ Or via CLI: `knowledge-rag --transport sse`
|
|
|
81
129
|
- **Prometheus metrics**: `/metrics` endpoint on separate port
|
|
82
130
|
- **Bearer auth**: Token validation for SSE/HTTP connections
|
|
83
131
|
|
|
84
|
-
All
|
|
132
|
+
All 13 MCP tools are instrumented with `@rate_limited` and `@instrument` decorators — zero overhead when features are disabled. Default transport remains **stdio** for full backwards compatibility.
|
|
85
133
|
|
|
86
134
|
> **Migration**: Existing users need zero changes. SSE mode is opt-in via `server.transport: "sse"` in config.yaml. See [Configuration](#configuration) for details.
|
|
87
135
|
|
|
@@ -205,7 +253,7 @@ See [Changelog](#changelog) for full history.
|
|
|
205
253
|
| **MMR Diversification** | Maximal Marginal Relevance reduces redundant results |
|
|
206
254
|
| **Persistent Model Cache** | Embedding models cached in `models_cache/` — survives reboots |
|
|
207
255
|
| **Auto-Migration** | Detects embedding dimension mismatch and rebuilds automatically |
|
|
208
|
-
| **
|
|
256
|
+
| **13 MCP Tools** | Full CRUD + search + evaluation via Claude Code |
|
|
209
257
|
|
|
210
258
|
---
|
|
211
259
|
|
|
@@ -217,7 +265,7 @@ See [Changelog](#changelog) for full history.
|
|
|
217
265
|
flowchart TB
|
|
218
266
|
subgraph MCP["MCP SERVER (FastMCP)"]
|
|
219
267
|
direction TB
|
|
220
|
-
TOOLS["
|
|
268
|
+
TOOLS["13 MCP Tools<br/>search | get | add | update | remove<br/>reindex | reindex_status | list | stats | url | similar | evaluate"]
|
|
221
269
|
end
|
|
222
270
|
|
|
223
271
|
subgraph SEARCH["HYBRID SEARCH ENGINE"]
|
|
@@ -392,7 +440,53 @@ flowchart LR
|
|
|
392
440
|
- Claude Code CLI
|
|
393
441
|
- *…or any other MCP client (Claude Desktop, Cursor, VS Code, Antigravity, opencode, Windsurf) — see [Use with other MCP clients](#use-with-other-mcp-clients)*
|
|
394
442
|
- ~200MB disk for model cache (auto-downloaded on first run)
|
|
395
|
-
- *Optional:* NVIDIA GPU + CUDA for accelerated embeddings (
|
|
443
|
+
- *Optional:* NVIDIA GPU + CUDA 12 for accelerated embeddings (see [GPU Acceleration](#gpu-acceleration) below)
|
|
444
|
+
|
|
445
|
+
### GPU Acceleration
|
|
446
|
+
|
|
447
|
+
GPU mode accelerates embedding generation during indexing and search. It requires an NVIDIA GPU with CUDA 12 support. No GPU? No problem — the server runs on CPU by default and GPU is entirely optional.
|
|
448
|
+
|
|
449
|
+
**Requirements:**
|
|
450
|
+
|
|
451
|
+
| Component | Minimum | How to check / get it |
|
|
452
|
+
|-----------|---------|----------------------|
|
|
453
|
+
| NVIDIA GPU (Turing+) | RTX 20xx / 30xx / 40xx / 50xx, or Tesla T4+ | `nvidia-smi` |
|
|
454
|
+
| NVIDIA Driver | ≥ 525 | `nvidia-smi` — [nvidia.com/drivers](https://www.nvidia.com/drivers) |
|
|
455
|
+
| CUDA 12 runtime | Provided by pip packages below | Automatic |
|
|
456
|
+
|
|
457
|
+
**Setup (2 steps):**
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
# 1. Install GPU dependencies (onnxruntime-gpu + all CUDA 12 runtime DLLs)
|
|
461
|
+
pip install knowledge-rag[gpu]
|
|
462
|
+
|
|
463
|
+
# 2. Enable in config.yaml
|
|
464
|
+
# models:
|
|
465
|
+
# embedding:
|
|
466
|
+
# gpu: true
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
The `[gpu]` extra installs `onnxruntime-gpu` plus 7 NVIDIA CUDA 12 packages (`cublas`, `cudnn`, `cuda-runtime`, `cufft`, `cusparse`, `cusolver`, `curand`, `nvjitlink`) so you don't need a full CUDA Toolkit install.
|
|
470
|
+
|
|
471
|
+
**Verify GPU is active:**
|
|
472
|
+
|
|
473
|
+
On server startup, look for the GPU status banner:
|
|
474
|
+
```
|
|
475
|
+
============================================================
|
|
476
|
+
GPU STATUS: ACTIVE
|
|
477
|
+
Provider: CUDAExecutionProvider
|
|
478
|
+
Device: NVIDIA GeForce RTX 3080 Ti
|
|
479
|
+
VRAM: 12.0 GB
|
|
480
|
+
============================================================
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Or programmatically:
|
|
484
|
+
```bash
|
|
485
|
+
python -c "import onnxruntime; print(onnxruntime.get_available_providers())"
|
|
486
|
+
# Should include: 'CUDAExecutionProvider'
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
> **Fallback**: If CUDA is unavailable at runtime (wrong driver, missing DLLs, no GPU), the server falls back to CPU automatically with a `[WARN]` log — it never crashes. The `gpu: true` config is a preference, not a requirement.
|
|
396
490
|
|
|
397
491
|
### Install Methods
|
|
398
492
|
|
|
@@ -663,7 +757,7 @@ search_knowledge("lateral movement strategies", hybrid_alpha=1.0)
|
|
|
663
757
|
|
|
664
758
|
### Indexing
|
|
665
759
|
|
|
666
|
-
Documents are automatically indexed on first startup.
|
|
760
|
+
Documents are automatically indexed on first startup. All reindex operations run **in background** — they return immediately and you poll progress via `get_reindex_status()`:
|
|
667
761
|
|
|
668
762
|
```python
|
|
669
763
|
# Incremental: only re-index changed files (fast)
|
|
@@ -674,6 +768,10 @@ reindex_documents(force=True)
|
|
|
674
768
|
|
|
675
769
|
# Nuclear rebuild: delete everything, re-embed all (use after model change)
|
|
676
770
|
reindex_documents(full_rebuild=True)
|
|
771
|
+
|
|
772
|
+
# Poll progress (lightweight, no full stats computation)
|
|
773
|
+
get_reindex_status()
|
|
774
|
+
# → {"reindex": {"active": true, "percent": 56, "progress": "2090/3734", ...}}
|
|
677
775
|
```
|
|
678
776
|
|
|
679
777
|
### Evaluating Retrieval Quality
|
|
@@ -755,14 +853,39 @@ Retrieve the full content of a specific document.
|
|
|
755
853
|
|
|
756
854
|
#### `reindex_documents`
|
|
757
855
|
|
|
758
|
-
Index or reindex all documents in the knowledge base.
|
|
856
|
+
Index or reindex all documents in the knowledge base. **Runs in background** — returns immediately. Poll progress via `get_reindex_status()`.
|
|
759
857
|
|
|
760
858
|
| Parameter | Type | Default | Description |
|
|
761
859
|
|-----------|------|---------|-------------|
|
|
762
860
|
| `force` | bool | false | Smart reindex: detects changes, rebuilds BM25. Fast. |
|
|
763
861
|
| `full_rebuild` | bool | false | Nuclear rebuild: deletes everything, re-embeds all documents. Use after model change. |
|
|
764
862
|
|
|
765
|
-
**Returns:**
|
|
863
|
+
**Returns:** `{"status": "started", "operation": "..."}` immediately. If already running, returns `{"status": "already_running", "progress": "1200/3734"}`.
|
|
864
|
+
|
|
865
|
+
---
|
|
866
|
+
|
|
867
|
+
#### `get_reindex_status`
|
|
868
|
+
|
|
869
|
+
Get the current status of a background reindex operation. Lightweight — does not compute full index statistics.
|
|
870
|
+
|
|
871
|
+
**Returns (active):**
|
|
872
|
+
```json
|
|
873
|
+
{
|
|
874
|
+
"status": "success",
|
|
875
|
+
"reindex": {
|
|
876
|
+
"active": true,
|
|
877
|
+
"operation": "nuclear_rebuild",
|
|
878
|
+
"progress": "1200/3734",
|
|
879
|
+
"percent": 32,
|
|
880
|
+
"indexed": 1200,
|
|
881
|
+
"skipped": 0,
|
|
882
|
+
"errors": 0,
|
|
883
|
+
"started_at": "2026-06-17T18:29:49"
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
**Returns (idle):** `{"status": "success", "reindex": {"active": false}}`
|
|
766
889
|
|
|
767
890
|
---
|
|
768
891
|
|
|
@@ -1071,7 +1194,7 @@ For `.md` files, chunking splits at `##` and `###` header boundaries first. Sect
|
|
|
1071
1194
|
|-------|---------|-------------|
|
|
1072
1195
|
| `models.embedding.model` | `BAAI/bge-small-en-v1.5` | Embedding model (ONNX, runs locally) |
|
|
1073
1196
|
| `models.embedding.dimensions` | 384 | Vector dimensions (must match model) |
|
|
1074
|
-
| `models.embedding.gpu` | false | Enable CUDA GPU acceleration.
|
|
1197
|
+
| `models.embedding.gpu` | false | Enable CUDA GPU acceleration. See [GPU Acceleration](#gpu-acceleration) for full setup |
|
|
1075
1198
|
| `models.reranker.enabled` | true | Enable cross-encoder reranking |
|
|
1076
1199
|
| `models.reranker.model` | `Xenova/ms-marco-MiniLM-L-6-v2` | Reranker model |
|
|
1077
1200
|
| `models.reranker.top_k_multiplier` | 3 | Fetch N*multiplier candidates for reranking |
|
|
@@ -1331,7 +1454,7 @@ Common issues:
|
|
|
1331
1454
|
- **NEW**: ChromaDB WAL mode enabled automatically in SSE/HTTP mode for concurrent read performance.
|
|
1332
1455
|
- **NEW**: Optional rate limiting — sliding-window counter, configurable RPM and burst, disabled by default.
|
|
1333
1456
|
- **NEW**: Optional Prometheus metrics endpoint — tool call counts, latency histograms, separate port, disabled by default.
|
|
1334
|
-
- **NEW**: All
|
|
1457
|
+
- **NEW**: All 13 MCP tools instrumented with `@rate_limited` and `@instrument` decorators (zero-cost when disabled).
|
|
1335
1458
|
- **NEW**: `--transport` CLI override for Docker/systemd deployments.
|
|
1336
1459
|
- **NEW**: `pip install knowledge-rag[server]` optional dependency for SSE/HTTP (uvicorn).
|
|
1337
1460
|
- **CHANGED**: SSE/HTTP mode auto-enables single-instance lock (port collision prevention).
|
|
@@ -1391,6 +1514,18 @@ Common issues:
|
|
|
1391
1514
|
|
|
1392
1515
|
### Unreleased
|
|
1393
1516
|
|
|
1517
|
+
### v4.3.0 (2026-06-17) — Async Reindex, GPU CUDA 12, 13th MCP Tool
|
|
1518
|
+
|
|
1519
|
+
- **NEW**: `get_reindex_status` MCP tool — lightweight reindex progress polling without computing full index stats. Returns active/idle status, percent, processed/total, errors, and last result.
|
|
1520
|
+
- **NEW**: `reindex_documents` now runs in background via daemon thread — returns immediately with `{"status": "started"}`. Eliminates MCP timeout on large document sets (5K+ files). Concurrent calls return `already_running` with current progress.
|
|
1521
|
+
- **NEW**: GPU acceleration with full CUDA 12 support — `onnxruntime-gpu` + 7 NVIDIA pip packages (`cublas`, `cudnn`, `cuda-runtime`, `cufft`, `cusparse`, `cusolver`, `curand`, `nvjitlink`). Server auto-detects GPU on startup with 4-step verification (providers, DLLs, nvidia-smi, session creation). Falls back to CPU gracefully.
|
|
1522
|
+
- **NEW**: `_setup_cuda_dll_paths()` adds NVIDIA pip package DLL directories to `PATH` automatically on Windows — onnxruntime finds CUDA 12 DLLs without a full CUDA Toolkit install.
|
|
1523
|
+
- **DEPS**: `[gpu]` extra expanded from 3 to 8 packages (added `cufft`, `cusparse`, `cusolver`, `curand`, `nvjitlink`).
|
|
1524
|
+
- **FIX**: GPU status reporting now uses actual ONNX session creation test instead of just checking `get_available_providers()` — prevents false "GPU ACTIVE" when CUDA DLLs are missing.
|
|
1525
|
+
- **DOCS**: GPU Acceleration section rewritten with complete requirements table, setup steps, verification instructions, and fallback behavior.
|
|
1526
|
+
- **DOCS**: Tool reference updated — `reindex_documents` async behavior documented, `get_reindex_status` reference added.
|
|
1527
|
+
- **TEST**: Backwards-compat baseline updated for 13 MCP tools.
|
|
1528
|
+
|
|
1394
1529
|
### v4.2.0 (2026-06-17) — Search Performance & Output Quality
|
|
1395
1530
|
|
|
1396
1531
|
- **PERF**: Custom inverted-index BM25 replaces `rank-bm25` full-corpus scan — 128× faster keyword search on 50K+ chunk corpora. Only documents containing query terms are scored via posting lists.
|
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: knowledge-rag
|
|
3
|
-
Version: 4.2.0
|
|
4
|
-
Summary: Local RAG System for Claude Code — Hybrid search + Cross-encoder Reranking + 12 MCP Tools + 20 Format Parsers. Zero external servers.
|
|
5
|
-
Project-URL: Homepage, https://github.com/lyonzin/knowledge-rag
|
|
6
|
-
Project-URL: Repository, https://github.com/lyonzin/knowledge-rag
|
|
7
|
-
Project-URL: Issues, https://github.com/lyonzin/knowledge-rag/issues
|
|
8
|
-
Project-URL: Changelog, https://github.com/lyonzin/knowledge-rag/releases
|
|
9
|
-
Author-email: "Lyon." <lyonzin@users.noreply.github.com>
|
|
10
|
-
License: MIT
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Keywords: bm25,chromadb,claude-code,embeddings,fastembed,hybrid-search,knowledge-base,local-ai,mcp,rag,reranking,retrieval-augmented-generation,semantic-search
|
|
13
|
-
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: Intended Audience :: Science/Research
|
|
16
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
-
Classifier: Operating System :: OS Independent
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
-
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
-
Classifier: Topic :: Text Processing :: Indexing
|
|
22
|
-
Requires-Python: >=3.11
|
|
23
|
-
Requires-Dist: beautifulsoup4>=4.12.0
|
|
24
|
-
Requires-Dist: chromadb>=1.4.0
|
|
25
|
-
Requires-Dist: fastembed[reranking]>=0.4.0
|
|
26
|
-
Requires-Dist: mcp>=1.6.0
|
|
27
|
-
Requires-Dist: numpy>=1.24.0
|
|
28
|
-
Requires-Dist: openpyxl>=3.1.0
|
|
29
|
-
Requires-Dist: pymupdf>=1.23.0
|
|
30
|
-
Requires-Dist: python-docx>=1.0.0
|
|
31
|
-
Requires-Dist: python-pptx>=1.0.0
|
|
32
|
-
Requires-Dist: pyyaml>=6.0
|
|
33
|
-
Requires-Dist: requests>=2.33.0
|
|
34
|
-
Requires-Dist: watchdog>=4.0.0
|
|
35
|
-
Provides-Extra: gpu
|
|
36
|
-
Requires-Dist: onnxruntime-gpu>=1.14.0; extra == 'gpu'
|
|
37
|
-
Provides-Extra: server
|
|
38
|
-
Requires-Dist: uvicorn>=0.20.0; extra == 'server'
|
|
39
|
-
Description-Content-Type: text/markdown
|
|
40
|
-
|
|
41
1
|
# Knowledge RAG
|
|
42
2
|
|
|
43
3
|
<div align="center">
|
|
@@ -57,7 +17,7 @@ Description-Content-Type: text/markdown
|
|
|
57
17
|
### Your docs, your machine, zero cloud. Claude Code searches them natively.
|
|
58
18
|
|
|
59
19
|
Drop your PDFs, markdown, code, notebooks — **1800+ files, 39K chunks, indexed in under 3 minutes.**<br/>
|
|
60
|
-
Hybrid search (BM25 + semantic vectors + cross-encoder reranking) through
|
|
20
|
+
Hybrid search (BM25 + semantic vectors + cross-encoder reranking) through 13 MCP tools.<br/>
|
|
61
21
|
Everything runs locally via ONNX. No Docker, no Ollama, no API keys, no data leaves your machine.
|
|
62
22
|
|
|
63
23
|
```
|
|
@@ -66,7 +26,7 @@ pip install knowledge-rag → restart Claude Code → search_knowledge("your que
|
|
|
66
26
|
|
|
67
27
|
---
|
|
68
28
|
|
|
69
|
-
**
|
|
29
|
+
**13 MCP Tools** | **Hybrid Search + Reranking** | **20 File Formats** | **Optional NVIDIA GPU** | **100% Local**
|
|
70
30
|
|
|
71
31
|
[What's New](#whats-new-in-v420) | [Supported Formats](#supported-formats) | [Installation](#installation) | [Configuration](#configuration) | [API Reference](#api-reference) | [Architecture](#architecture)
|
|
72
32
|
|
|
@@ -121,7 +81,7 @@ Or via CLI: `knowledge-rag --transport sse`
|
|
|
121
81
|
- **Prometheus metrics**: `/metrics` endpoint on separate port
|
|
122
82
|
- **Bearer auth**: Token validation for SSE/HTTP connections
|
|
123
83
|
|
|
124
|
-
All
|
|
84
|
+
All 13 MCP tools are instrumented with `@rate_limited` and `@instrument` decorators — zero overhead when features are disabled. Default transport remains **stdio** for full backwards compatibility.
|
|
125
85
|
|
|
126
86
|
> **Migration**: Existing users need zero changes. SSE mode is opt-in via `server.transport: "sse"` in config.yaml. See [Configuration](#configuration) for details.
|
|
127
87
|
|
|
@@ -245,7 +205,7 @@ See [Changelog](#changelog) for full history.
|
|
|
245
205
|
| **MMR Diversification** | Maximal Marginal Relevance reduces redundant results |
|
|
246
206
|
| **Persistent Model Cache** | Embedding models cached in `models_cache/` — survives reboots |
|
|
247
207
|
| **Auto-Migration** | Detects embedding dimension mismatch and rebuilds automatically |
|
|
248
|
-
| **
|
|
208
|
+
| **13 MCP Tools** | Full CRUD + search + evaluation via Claude Code |
|
|
249
209
|
|
|
250
210
|
---
|
|
251
211
|
|
|
@@ -257,7 +217,7 @@ See [Changelog](#changelog) for full history.
|
|
|
257
217
|
flowchart TB
|
|
258
218
|
subgraph MCP["MCP SERVER (FastMCP)"]
|
|
259
219
|
direction TB
|
|
260
|
-
TOOLS["
|
|
220
|
+
TOOLS["13 MCP Tools<br/>search | get | add | update | remove<br/>reindex | reindex_status | list | stats | url | similar | evaluate"]
|
|
261
221
|
end
|
|
262
222
|
|
|
263
223
|
subgraph SEARCH["HYBRID SEARCH ENGINE"]
|
|
@@ -432,7 +392,53 @@ flowchart LR
|
|
|
432
392
|
- Claude Code CLI
|
|
433
393
|
- *…or any other MCP client (Claude Desktop, Cursor, VS Code, Antigravity, opencode, Windsurf) — see [Use with other MCP clients](#use-with-other-mcp-clients)*
|
|
434
394
|
- ~200MB disk for model cache (auto-downloaded on first run)
|
|
435
|
-
- *Optional:* NVIDIA GPU + CUDA for accelerated embeddings (
|
|
395
|
+
- *Optional:* NVIDIA GPU + CUDA 12 for accelerated embeddings (see [GPU Acceleration](#gpu-acceleration) below)
|
|
396
|
+
|
|
397
|
+
### GPU Acceleration
|
|
398
|
+
|
|
399
|
+
GPU mode accelerates embedding generation during indexing and search. It requires an NVIDIA GPU with CUDA 12 support. No GPU? No problem — the server runs on CPU by default and GPU is entirely optional.
|
|
400
|
+
|
|
401
|
+
**Requirements:**
|
|
402
|
+
|
|
403
|
+
| Component | Minimum | How to check / get it |
|
|
404
|
+
|-----------|---------|----------------------|
|
|
405
|
+
| NVIDIA GPU (Turing+) | RTX 20xx / 30xx / 40xx / 50xx, or Tesla T4+ | `nvidia-smi` |
|
|
406
|
+
| NVIDIA Driver | ≥ 525 | `nvidia-smi` — [nvidia.com/drivers](https://www.nvidia.com/drivers) |
|
|
407
|
+
| CUDA 12 runtime | Provided by pip packages below | Automatic |
|
|
408
|
+
|
|
409
|
+
**Setup (2 steps):**
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# 1. Install GPU dependencies (onnxruntime-gpu + all CUDA 12 runtime DLLs)
|
|
413
|
+
pip install knowledge-rag[gpu]
|
|
414
|
+
|
|
415
|
+
# 2. Enable in config.yaml
|
|
416
|
+
# models:
|
|
417
|
+
# embedding:
|
|
418
|
+
# gpu: true
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
The `[gpu]` extra installs `onnxruntime-gpu` plus 7 NVIDIA CUDA 12 packages (`cublas`, `cudnn`, `cuda-runtime`, `cufft`, `cusparse`, `cusolver`, `curand`, `nvjitlink`) so you don't need a full CUDA Toolkit install.
|
|
422
|
+
|
|
423
|
+
**Verify GPU is active:**
|
|
424
|
+
|
|
425
|
+
On server startup, look for the GPU status banner:
|
|
426
|
+
```
|
|
427
|
+
============================================================
|
|
428
|
+
GPU STATUS: ACTIVE
|
|
429
|
+
Provider: CUDAExecutionProvider
|
|
430
|
+
Device: NVIDIA GeForce RTX 3080 Ti
|
|
431
|
+
VRAM: 12.0 GB
|
|
432
|
+
============================================================
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Or programmatically:
|
|
436
|
+
```bash
|
|
437
|
+
python -c "import onnxruntime; print(onnxruntime.get_available_providers())"
|
|
438
|
+
# Should include: 'CUDAExecutionProvider'
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
> **Fallback**: If CUDA is unavailable at runtime (wrong driver, missing DLLs, no GPU), the server falls back to CPU automatically with a `[WARN]` log — it never crashes. The `gpu: true` config is a preference, not a requirement.
|
|
436
442
|
|
|
437
443
|
### Install Methods
|
|
438
444
|
|
|
@@ -703,7 +709,7 @@ search_knowledge("lateral movement strategies", hybrid_alpha=1.0)
|
|
|
703
709
|
|
|
704
710
|
### Indexing
|
|
705
711
|
|
|
706
|
-
Documents are automatically indexed on first startup.
|
|
712
|
+
Documents are automatically indexed on first startup. All reindex operations run **in background** — they return immediately and you poll progress via `get_reindex_status()`:
|
|
707
713
|
|
|
708
714
|
```python
|
|
709
715
|
# Incremental: only re-index changed files (fast)
|
|
@@ -714,6 +720,10 @@ reindex_documents(force=True)
|
|
|
714
720
|
|
|
715
721
|
# Nuclear rebuild: delete everything, re-embed all (use after model change)
|
|
716
722
|
reindex_documents(full_rebuild=True)
|
|
723
|
+
|
|
724
|
+
# Poll progress (lightweight, no full stats computation)
|
|
725
|
+
get_reindex_status()
|
|
726
|
+
# → {"reindex": {"active": true, "percent": 56, "progress": "2090/3734", ...}}
|
|
717
727
|
```
|
|
718
728
|
|
|
719
729
|
### Evaluating Retrieval Quality
|
|
@@ -795,14 +805,39 @@ Retrieve the full content of a specific document.
|
|
|
795
805
|
|
|
796
806
|
#### `reindex_documents`
|
|
797
807
|
|
|
798
|
-
Index or reindex all documents in the knowledge base.
|
|
808
|
+
Index or reindex all documents in the knowledge base. **Runs in background** — returns immediately. Poll progress via `get_reindex_status()`.
|
|
799
809
|
|
|
800
810
|
| Parameter | Type | Default | Description |
|
|
801
811
|
|-----------|------|---------|-------------|
|
|
802
812
|
| `force` | bool | false | Smart reindex: detects changes, rebuilds BM25. Fast. |
|
|
803
813
|
| `full_rebuild` | bool | false | Nuclear rebuild: deletes everything, re-embeds all documents. Use after model change. |
|
|
804
814
|
|
|
805
|
-
**Returns:**
|
|
815
|
+
**Returns:** `{"status": "started", "operation": "..."}` immediately. If already running, returns `{"status": "already_running", "progress": "1200/3734"}`.
|
|
816
|
+
|
|
817
|
+
---
|
|
818
|
+
|
|
819
|
+
#### `get_reindex_status`
|
|
820
|
+
|
|
821
|
+
Get the current status of a background reindex operation. Lightweight — does not compute full index statistics.
|
|
822
|
+
|
|
823
|
+
**Returns (active):**
|
|
824
|
+
```json
|
|
825
|
+
{
|
|
826
|
+
"status": "success",
|
|
827
|
+
"reindex": {
|
|
828
|
+
"active": true,
|
|
829
|
+
"operation": "nuclear_rebuild",
|
|
830
|
+
"progress": "1200/3734",
|
|
831
|
+
"percent": 32,
|
|
832
|
+
"indexed": 1200,
|
|
833
|
+
"skipped": 0,
|
|
834
|
+
"errors": 0,
|
|
835
|
+
"started_at": "2026-06-17T18:29:49"
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
```
|
|
839
|
+
|
|
840
|
+
**Returns (idle):** `{"status": "success", "reindex": {"active": false}}`
|
|
806
841
|
|
|
807
842
|
---
|
|
808
843
|
|
|
@@ -1111,7 +1146,7 @@ For `.md` files, chunking splits at `##` and `###` header boundaries first. Sect
|
|
|
1111
1146
|
|-------|---------|-------------|
|
|
1112
1147
|
| `models.embedding.model` | `BAAI/bge-small-en-v1.5` | Embedding model (ONNX, runs locally) |
|
|
1113
1148
|
| `models.embedding.dimensions` | 384 | Vector dimensions (must match model) |
|
|
1114
|
-
| `models.embedding.gpu` | false | Enable CUDA GPU acceleration.
|
|
1149
|
+
| `models.embedding.gpu` | false | Enable CUDA GPU acceleration. See [GPU Acceleration](#gpu-acceleration) for full setup |
|
|
1115
1150
|
| `models.reranker.enabled` | true | Enable cross-encoder reranking |
|
|
1116
1151
|
| `models.reranker.model` | `Xenova/ms-marco-MiniLM-L-6-v2` | Reranker model |
|
|
1117
1152
|
| `models.reranker.top_k_multiplier` | 3 | Fetch N*multiplier candidates for reranking |
|
|
@@ -1371,7 +1406,7 @@ Common issues:
|
|
|
1371
1406
|
- **NEW**: ChromaDB WAL mode enabled automatically in SSE/HTTP mode for concurrent read performance.
|
|
1372
1407
|
- **NEW**: Optional rate limiting — sliding-window counter, configurable RPM and burst, disabled by default.
|
|
1373
1408
|
- **NEW**: Optional Prometheus metrics endpoint — tool call counts, latency histograms, separate port, disabled by default.
|
|
1374
|
-
- **NEW**: All
|
|
1409
|
+
- **NEW**: All 13 MCP tools instrumented with `@rate_limited` and `@instrument` decorators (zero-cost when disabled).
|
|
1375
1410
|
- **NEW**: `--transport` CLI override for Docker/systemd deployments.
|
|
1376
1411
|
- **NEW**: `pip install knowledge-rag[server]` optional dependency for SSE/HTTP (uvicorn).
|
|
1377
1412
|
- **CHANGED**: SSE/HTTP mode auto-enables single-instance lock (port collision prevention).
|
|
@@ -1431,6 +1466,18 @@ Common issues:
|
|
|
1431
1466
|
|
|
1432
1467
|
### Unreleased
|
|
1433
1468
|
|
|
1469
|
+
### v4.3.0 (2026-06-17) — Async Reindex, GPU CUDA 12, 13th MCP Tool
|
|
1470
|
+
|
|
1471
|
+
- **NEW**: `get_reindex_status` MCP tool — lightweight reindex progress polling without computing full index stats. Returns active/idle status, percent, processed/total, errors, and last result.
|
|
1472
|
+
- **NEW**: `reindex_documents` now runs in background via daemon thread — returns immediately with `{"status": "started"}`. Eliminates MCP timeout on large document sets (5K+ files). Concurrent calls return `already_running` with current progress.
|
|
1473
|
+
- **NEW**: GPU acceleration with full CUDA 12 support — `onnxruntime-gpu` + 7 NVIDIA pip packages (`cublas`, `cudnn`, `cuda-runtime`, `cufft`, `cusparse`, `cusolver`, `curand`, `nvjitlink`). Server auto-detects GPU on startup with 4-step verification (providers, DLLs, nvidia-smi, session creation). Falls back to CPU gracefully.
|
|
1474
|
+
- **NEW**: `_setup_cuda_dll_paths()` adds NVIDIA pip package DLL directories to `PATH` automatically on Windows — onnxruntime finds CUDA 12 DLLs without a full CUDA Toolkit install.
|
|
1475
|
+
- **DEPS**: `[gpu]` extra expanded from 3 to 8 packages (added `cufft`, `cusparse`, `cusolver`, `curand`, `nvjitlink`).
|
|
1476
|
+
- **FIX**: GPU status reporting now uses actual ONNX session creation test instead of just checking `get_available_providers()` — prevents false "GPU ACTIVE" when CUDA DLLs are missing.
|
|
1477
|
+
- **DOCS**: GPU Acceleration section rewritten with complete requirements table, setup steps, verification instructions, and fallback behavior.
|
|
1478
|
+
- **DOCS**: Tool reference updated — `reindex_documents` async behavior documented, `get_reindex_status` reference added.
|
|
1479
|
+
- **TEST**: Backwards-compat baseline updated for 13 MCP tools.
|
|
1480
|
+
|
|
1434
1481
|
### v4.2.0 (2026-06-17) — Search Performance & Output Quality
|
|
1435
1482
|
|
|
1436
1483
|
- **PERF**: Custom inverted-index BM25 replaces `rank-bm25` full-corpus scan — 128× faster keyword search on 50K+ chunk corpora. Only documents containing query terms are scored via posting lists.
|
|
@@ -986,6 +986,9 @@ class KnowledgeOrchestrator:
|
|
|
986
986
|
# Migration: deferred — checked in main() after full init
|
|
987
987
|
self._needs_rebuild = False
|
|
988
988
|
|
|
989
|
+
# Background reindex progress (polled via get_index_stats)
|
|
990
|
+
self._reindex_progress: Dict[str, Any] = {"active": False}
|
|
991
|
+
|
|
989
992
|
def _safe_get_collection(self):
|
|
990
993
|
"""
|
|
991
994
|
Get or create ChromaDB collection with auto-recovery.
|
|
@@ -1134,6 +1137,7 @@ class KnowledgeOrchestrator:
|
|
|
1134
1137
|
|
|
1135
1138
|
documents = self.parser.parse_directory()
|
|
1136
1139
|
stats["total_files"] = len(documents)
|
|
1140
|
+
self._reindex_progress["total_files"] = stats["total_files"]
|
|
1137
1141
|
if stats["total_files"] > 100:
|
|
1138
1142
|
print(f"[INDEX] Scanning {stats['total_files']} documents...")
|
|
1139
1143
|
|
|
@@ -1226,6 +1230,15 @@ class KnowledgeOrchestrator:
|
|
|
1226
1230
|
stats["errors"] += 1
|
|
1227
1231
|
print(f"[ERROR] Failed to index {doc.source}: {e}")
|
|
1228
1232
|
|
|
1233
|
+
self._reindex_progress.update(
|
|
1234
|
+
{
|
|
1235
|
+
"processed": idx + 1,
|
|
1236
|
+
"indexed": stats["indexed"],
|
|
1237
|
+
"skipped": stats["skipped"],
|
|
1238
|
+
"errors": stats["errors"],
|
|
1239
|
+
}
|
|
1240
|
+
)
|
|
1241
|
+
|
|
1229
1242
|
if stats["total_files"] > 100 and (idx + 1) % _progress_interval == 0:
|
|
1230
1243
|
pct = int((idx + 1) / stats["total_files"] * 100)
|
|
1231
1244
|
print(
|
|
@@ -1308,6 +1321,43 @@ class KnowledgeOrchestrator:
|
|
|
1308
1321
|
|
|
1309
1322
|
return 0
|
|
1310
1323
|
|
|
1324
|
+
def start_reindex_background(self, mode: str) -> Dict[str, Any]:
|
|
1325
|
+
"""Start reindex in a background thread. Returns immediately."""
|
|
1326
|
+
if self._reindex_progress.get("active"):
|
|
1327
|
+
return {"status": "already_running", "progress": dict(self._reindex_progress)}
|
|
1328
|
+
|
|
1329
|
+
self._reindex_progress = {
|
|
1330
|
+
"active": True,
|
|
1331
|
+
"operation": mode,
|
|
1332
|
+
"total_files": 0,
|
|
1333
|
+
"processed": 0,
|
|
1334
|
+
"indexed": 0,
|
|
1335
|
+
"skipped": 0,
|
|
1336
|
+
"errors": 0,
|
|
1337
|
+
"started_at": datetime.now().isoformat(),
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
target = {
|
|
1341
|
+
"incremental": lambda: self.index_all(force=False),
|
|
1342
|
+
"smart_reindex": self.reindex_all,
|
|
1343
|
+
"nuclear_rebuild": self.nuclear_rebuild,
|
|
1344
|
+
}[mode]
|
|
1345
|
+
|
|
1346
|
+
thread = threading.Thread(target=self._run_reindex, args=(target,), daemon=True)
|
|
1347
|
+
thread.start()
|
|
1348
|
+
return {"status": "started", "operation": mode}
|
|
1349
|
+
|
|
1350
|
+
def _run_reindex(self, target: Any) -> None:
|
|
1351
|
+
"""Background thread runner for reindex operations."""
|
|
1352
|
+
try:
|
|
1353
|
+
result = target()
|
|
1354
|
+
self._reindex_progress["result"] = result
|
|
1355
|
+
except Exception as e:
|
|
1356
|
+
self._reindex_progress["error"] = str(e)
|
|
1357
|
+
print(f"[ERROR] Background reindex failed: {e}")
|
|
1358
|
+
finally:
|
|
1359
|
+
self._reindex_progress["active"] = False
|
|
1360
|
+
|
|
1311
1361
|
def reindex_all(self) -> Dict[str, Any]:
|
|
1312
1362
|
"""Smart reindex: incremental detection + BM25 rebuild + orphan cleanup."""
|
|
1313
1363
|
import shutil
|
|
@@ -2043,8 +2093,8 @@ class KnowledgeOrchestrator:
|
|
|
2043
2093
|
return docs
|
|
2044
2094
|
|
|
2045
2095
|
def get_stats(self) -> Dict[str, Any]:
|
|
2046
|
-
"""Get index statistics"""
|
|
2047
|
-
|
|
2096
|
+
"""Get index statistics including background reindex progress."""
|
|
2097
|
+
stats = {
|
|
2048
2098
|
"total_documents": len(self._indexed_docs),
|
|
2049
2099
|
"total_chunks": self.collection.count(),
|
|
2050
2100
|
"categories": self.list_categories(),
|
|
@@ -2057,6 +2107,48 @@ class KnowledgeOrchestrator:
|
|
|
2057
2107
|
"query_cache": self.query_cache.stats(),
|
|
2058
2108
|
}
|
|
2059
2109
|
|
|
2110
|
+
progress = self._reindex_progress
|
|
2111
|
+
if progress.get("active"):
|
|
2112
|
+
total = max(1, progress.get("total_files", 1))
|
|
2113
|
+
processed = progress.get("processed", 0)
|
|
2114
|
+
stats["reindex"] = {
|
|
2115
|
+
"active": True,
|
|
2116
|
+
"operation": progress.get("operation"),
|
|
2117
|
+
"progress": f"{processed}/{progress.get('total_files', 0)}",
|
|
2118
|
+
"percent": round(processed / total * 100),
|
|
2119
|
+
"indexed": progress.get("indexed", 0),
|
|
2120
|
+
"errors": progress.get("errors", 0),
|
|
2121
|
+
"started_at": progress.get("started_at"),
|
|
2122
|
+
}
|
|
2123
|
+
else:
|
|
2124
|
+
stats["reindex"] = {"active": False}
|
|
2125
|
+
|
|
2126
|
+
return stats
|
|
2127
|
+
|
|
2128
|
+
def get_reindex_status(self) -> Dict[str, Any]:
|
|
2129
|
+
"""Get background reindex progress without computing full index stats."""
|
|
2130
|
+
progress = self._reindex_progress
|
|
2131
|
+
if progress.get("active"):
|
|
2132
|
+
total = max(1, progress.get("total_files", 1))
|
|
2133
|
+
processed = progress.get("processed", 0)
|
|
2134
|
+
return {
|
|
2135
|
+
"active": True,
|
|
2136
|
+
"operation": progress.get("operation"),
|
|
2137
|
+
"progress": f"{processed}/{progress.get('total_files', 0)}",
|
|
2138
|
+
"percent": round(processed / total * 100),
|
|
2139
|
+
"indexed": progress.get("indexed", 0),
|
|
2140
|
+
"skipped": progress.get("skipped", 0),
|
|
2141
|
+
"errors": progress.get("errors", 0),
|
|
2142
|
+
"started_at": progress.get("started_at"),
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
result: Dict[str, Any] = {"active": False}
|
|
2146
|
+
if "result" in progress:
|
|
2147
|
+
result["last_result"] = progress["result"]
|
|
2148
|
+
if "error" in progress:
|
|
2149
|
+
result["last_error"] = progress["error"]
|
|
2150
|
+
return result
|
|
2151
|
+
|
|
2060
2152
|
def _load_metadata(self) -> Dict[str, Dict]:
|
|
2061
2153
|
"""Load index metadata from disk"""
|
|
2062
2154
|
if self._metadata_file.exists():
|
|
@@ -2258,16 +2350,17 @@ def reindex_documents(force: bool = False, full_rebuild: bool = False) -> str:
|
|
|
2258
2350
|
"""
|
|
2259
2351
|
Index or reindex all documents in the knowledge base.
|
|
2260
2352
|
|
|
2261
|
-
|
|
2353
|
+
Runs in background — returns immediately. Use get_reindex_status() to monitor progress.
|
|
2262
2354
|
|
|
2263
2355
|
Args:
|
|
2264
|
-
force: If True, smart reindex (detects changed files + rebuilds BM25 index).
|
|
2265
|
-
|
|
2356
|
+
force: If True, smart reindex (detects changed files + rebuilds BM25 index).
|
|
2357
|
+
Use after manually editing files on disk outside of add_document().
|
|
2266
2358
|
full_rebuild: If True, nuclear rebuild — deletes all vectors and re-embeds everything
|
|
2267
2359
|
from scratch. Use only if the embedding model changed or the index is corrupted.
|
|
2268
2360
|
|
|
2269
2361
|
Returns:
|
|
2270
|
-
JSON string with
|
|
2362
|
+
JSON string with operation status. Poll get_reindex_status() for reindex.active,
|
|
2363
|
+
reindex.progress, and reindex.percent until reindex.active becomes false.
|
|
2271
2364
|
|
|
2272
2365
|
Usage: Normal workflow does not require this — add_document(), update_document(), and
|
|
2273
2366
|
add_from_url() all auto-index on call. Use force=True only after direct filesystem edits.
|
|
@@ -2277,16 +2370,59 @@ def reindex_documents(force: bool = False, full_rebuild: bool = False) -> str:
|
|
|
2277
2370
|
orchestrator = get_orchestrator()
|
|
2278
2371
|
|
|
2279
2372
|
if full_rebuild:
|
|
2280
|
-
|
|
2281
|
-
operation = "nuclear_rebuild"
|
|
2373
|
+
mode = "nuclear_rebuild"
|
|
2282
2374
|
elif force:
|
|
2283
|
-
|
|
2284
|
-
operation = "smart_reindex"
|
|
2375
|
+
mode = "smart_reindex"
|
|
2285
2376
|
else:
|
|
2286
|
-
|
|
2287
|
-
operation = "incremental_index"
|
|
2377
|
+
mode = "incremental"
|
|
2288
2378
|
|
|
2289
|
-
|
|
2379
|
+
result = orchestrator.start_reindex_background(mode)
|
|
2380
|
+
|
|
2381
|
+
if result["status"] == "already_running":
|
|
2382
|
+
progress = result["progress"]
|
|
2383
|
+
return json.dumps(
|
|
2384
|
+
{
|
|
2385
|
+
"status": "already_running",
|
|
2386
|
+
"progress": f"{progress.get('processed', 0)}/{progress.get('total_files', 0)}",
|
|
2387
|
+
"operation": progress.get("operation"),
|
|
2388
|
+
"hint": "Use get_reindex_status() to check progress",
|
|
2389
|
+
},
|
|
2390
|
+
indent=2,
|
|
2391
|
+
ensure_ascii=False,
|
|
2392
|
+
)
|
|
2393
|
+
|
|
2394
|
+
return json.dumps(
|
|
2395
|
+
{
|
|
2396
|
+
"status": "started",
|
|
2397
|
+
"operation": mode,
|
|
2398
|
+
"message": "Reindex running in background. Use get_reindex_status() to monitor progress.",
|
|
2399
|
+
},
|
|
2400
|
+
indent=2,
|
|
2401
|
+
ensure_ascii=False,
|
|
2402
|
+
)
|
|
2403
|
+
|
|
2404
|
+
|
|
2405
|
+
@mcp.tool()
|
|
2406
|
+
@rate_limited
|
|
2407
|
+
@instrument("get_reindex_status")
|
|
2408
|
+
def get_reindex_status() -> str:
|
|
2409
|
+
"""
|
|
2410
|
+
Get the current status of a background reindex operation.
|
|
2411
|
+
|
|
2412
|
+
Lightweight — does not compute full index statistics. Use this to poll progress
|
|
2413
|
+
after calling reindex_documents().
|
|
2414
|
+
|
|
2415
|
+
Returns:
|
|
2416
|
+
JSON string with reindex status. When active: operation name, progress (processed/total),
|
|
2417
|
+
percent complete, indexed/skipped/errors counts, and start time. When inactive: active=false,
|
|
2418
|
+
plus last_result or last_error from the most recent completed reindex.
|
|
2419
|
+
|
|
2420
|
+
Usage: Call repeatedly after reindex_documents() to monitor progress. When reindex.active
|
|
2421
|
+
becomes false, the operation is complete. Use get_index_stats() for full index health metrics.
|
|
2422
|
+
"""
|
|
2423
|
+
orchestrator = get_orchestrator()
|
|
2424
|
+
status = orchestrator.get_reindex_status()
|
|
2425
|
+
return json.dumps({"status": "success", "reindex": status}, indent=2)
|
|
2290
2426
|
|
|
2291
2427
|
|
|
2292
2428
|
@mcp.tool()
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "knowledge-rag"
|
|
7
|
-
version = "4.
|
|
8
|
-
description = "Local RAG System for Claude Code — Hybrid search + Cross-encoder Reranking +
|
|
7
|
+
version = "4.3.0"
|
|
8
|
+
description = "Local RAG System for Claude Code — Hybrid search + Cross-encoder Reranking + 13 MCP Tools + 20 Format Parsers. Zero external servers."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
11
11
|
requires-python = ">=3.11"
|
|
@@ -44,7 +44,17 @@ dependencies = [
|
|
|
44
44
|
]
|
|
45
45
|
|
|
46
46
|
[project.optional-dependencies]
|
|
47
|
-
gpu = [
|
|
47
|
+
gpu = [
|
|
48
|
+
"onnxruntime-gpu>=1.14.0",
|
|
49
|
+
"nvidia-cublas-cu12",
|
|
50
|
+
"nvidia-cudnn-cu12",
|
|
51
|
+
"nvidia-cuda-runtime-cu12",
|
|
52
|
+
"nvidia-cufft-cu12",
|
|
53
|
+
"nvidia-cusparse-cu12",
|
|
54
|
+
"nvidia-cusolver-cu12",
|
|
55
|
+
"nvidia-curand-cu12",
|
|
56
|
+
"nvidia-nvjitlink-cu12",
|
|
57
|
+
]
|
|
48
58
|
server = ["uvicorn>=0.20.0"]
|
|
49
59
|
|
|
50
60
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|