knowledge-rag 3.6.2 → 3.8.0
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.
- package/README.md +75 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
](https://pypi.org/project/knowledge-rag/)
|
|
6
|
+
[](https://www.npmjs.com/package/knowledge-rag)
|
|
7
|
+
[](https://pepy.tech/projects/knowledge-rag)
|
|
6
8
|

|
|
7
9
|

|
|
8
10
|

|
|
@@ -10,7 +12,6 @@
|
|
|
10
12
|
[](https://github.com/lyonzin/knowledge-rag/actions/workflows/ci.yml)
|
|
11
13
|
[](https://github.com/lyonzin/knowledge-rag/actions/workflows/security.yml)
|
|
12
14
|
[](https://glama.ai/mcp/servers/lyonzin/knowledge-rag)
|
|
13
|
-
[](https://pypi.org/project/knowledge-rag/)
|
|
14
15
|
|
|
15
16
|
### Your docs, your machine, zero cloud. Claude Code searches them natively.
|
|
16
17
|
|
|
@@ -32,11 +33,21 @@ pip install knowledge-rag → restart Claude Code → search_knowledge("your que
|
|
|
32
33
|
|
|
33
34
|
---
|
|
34
35
|
|
|
35
|
-
## What's New in v3.
|
|
36
|
+
## What's New in v3.8.0
|
|
37
|
+
|
|
38
|
+
### Lazy-Loaded Embeddings — Cheaper Idle Processes
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
The FastEmbed ONNX model (~200MB resident) now loads on the **first query**, not at startup. Idle `knowledge-rag` processes are now genuinely cheap. Why this matters: MCP stdio is one-process-per-client by protocol — multiple Claude Code windows, Claude Desktop + IDE simultaneously, or review/approval flows that open extra connections all spawn their own processes. Before v3.8.0, every one of them paid the full embedding-model cost up front. Now only processes that actually serve queries load the model. Public API is unchanged.
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
### Opt-In Single-Instance Guard
|
|
43
|
+
|
|
44
|
+
For users who measured their setup and want a hard cap of one server per `data_dir`:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
export KNOWLEDGE_RAG_SINGLE_INSTANCE=1
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A second instance exits immediately with code 75. **OFF by default** so multi-client MCP usage continues to work unchanged. Stale-PID recovery + SIGINT/SIGTERM cleanup wired correctly. Full guide in [docs/single-instance.md](docs/single-instance.md). Sample MCP config in [examples/mcp-config-single-instance.json](examples/mcp-config-single-instance.json).
|
|
40
51
|
|
|
41
52
|
### 5 Ways to Install
|
|
42
53
|
|
|
@@ -52,6 +63,7 @@ All methods produce the same MCP server. See [Installation](#installation) for f
|
|
|
52
63
|
|
|
53
64
|
### Recent Highlights
|
|
54
65
|
|
|
66
|
+
- **v3.8.0** — Lazy-load embeddings, opt-in single-instance guard, version sync across PyPI/NPM/Docker
|
|
55
67
|
- **v3.6.0** — Multi-language code parsing (C/C++/JS/TS/XML), NPM wrapper, Docker image, automated release pipeline
|
|
56
68
|
- **v3.5.2** — CUDA DLL auto-discovery from pip packages, graceful GPU→CPU fallback, explicit CPU provider (no CUDA noise when `gpu: false`), BASE_DIR resolution fix for editable installs
|
|
57
69
|
- **v3.5.1** — Remove Python `<3.13` upper bound — 3.13 and 3.14 now supported
|
|
@@ -771,7 +783,7 @@ models:
|
|
|
771
783
|
dimensions: 384
|
|
772
784
|
gpu: false # Set true + pip install knowledge-rag[gpu]
|
|
773
785
|
reranker:
|
|
774
|
-
enabled: true #
|
|
786
|
+
enabled: true # Falls back to RRF if model is unavailable
|
|
775
787
|
model: "Xenova/ms-marco-MiniLM-L-6-v2"
|
|
776
788
|
top_k_multiplier: 3 # Candidates fetched before reranking
|
|
777
789
|
|
|
@@ -858,6 +870,8 @@ For `.md` files, chunking splits at `##` and `###` header boundaries first. Sect
|
|
|
858
870
|
| `models.reranker.model` | `Xenova/ms-marco-MiniLM-L-6-v2` | Reranker model |
|
|
859
871
|
| `models.reranker.top_k_multiplier` | 3 | Fetch N*multiplier candidates for reranking |
|
|
860
872
|
|
|
873
|
+
If the reranker model is not available locally and the machine cannot download it, search now falls back to the RRF order from hybrid semantic+BM25 retrieval. This keeps `search_knowledge` available offline, but result ordering may be less precise for ambiguous queries until the reranker model is cached.
|
|
874
|
+
|
|
861
875
|
**Embedding model options** (fastest → most accurate):
|
|
862
876
|
- `BAAI/bge-small-en-v1.5` — 384D, ~33MB (default)
|
|
863
877
|
- `BAAI/bge-base-en-v1.5` — 768D, ~130MB
|
|
@@ -988,6 +1002,31 @@ rm -rf models_cache
|
|
|
988
1002
|
# Then restart the MCP server
|
|
989
1003
|
```
|
|
990
1004
|
|
|
1005
|
+
### Reranker model download fails
|
|
1006
|
+
|
|
1007
|
+
The reranker is lazy-loaded on the first query. If the model is not cached and the machine is offline, search continues without reranking and uses the RRF order from hybrid retrieval. To keep reranking enabled offline, run one query while online or pre-populate `models_cache/` on the target machine.
|
|
1008
|
+
|
|
1009
|
+
You can still disable reranking explicitly in `config.yaml`:
|
|
1010
|
+
|
|
1011
|
+
```yaml
|
|
1012
|
+
models:
|
|
1013
|
+
reranker:
|
|
1014
|
+
enabled: false
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
Disabling reranking reduces memory use and avoids first-query model loading. The tradeoff is lower ranking precision, especially when several chunks match the same terms but only one is the best answer.
|
|
1018
|
+
|
|
1019
|
+
### ChromaDB index crashes on startup
|
|
1020
|
+
|
|
1021
|
+
Native ChromaDB failures can terminate Python before normal exception handling runs. Startup now probes ChromaDB in a child process before initializing the MCP server. If the probe crashes, the active `chroma_db/` and `index_metadata.json` are moved to `data/backups/auto-repair-*`, and the next startup can rebuild a clean index.
|
|
1022
|
+
|
|
1023
|
+
The same guarded behavior is available through either console script:
|
|
1024
|
+
|
|
1025
|
+
```bash
|
|
1026
|
+
knowledge-rag
|
|
1027
|
+
knowledge-rag-guarded
|
|
1028
|
+
```
|
|
1029
|
+
|
|
991
1030
|
### Index is empty
|
|
992
1031
|
|
|
993
1032
|
```bash
|
|
@@ -1018,16 +1057,44 @@ pip install --upgrade knowledge-rag
|
|
|
1018
1057
|
|
|
1019
1058
|
### Slow first query
|
|
1020
1059
|
|
|
1021
|
-
The cross-encoder reranker model is lazy-loaded on the first query. This adds a one-time ~2-3 second delay for model download and loading. Subsequent queries are fast.
|
|
1060
|
+
The cross-encoder reranker model is lazy-loaded on the first query. This adds a one-time ~2-3 second delay for model download and loading. Subsequent queries are fast. If the model cannot be loaded, search falls back to RRF ordering and does not retry loading the reranker until the server restarts.
|
|
1022
1061
|
|
|
1023
1062
|
### Memory usage
|
|
1024
1063
|
|
|
1025
|
-
With ~200 documents, expect ~300-500MB RAM. The embedding model (~
|
|
1064
|
+
With ~200 documents, expect ~300-500MB RAM. The embedding model (~200MB ONNX runtime resident, lazy-loaded on first query since v3.8.0) and reranker (~25MB, lazy-loaded) are loaded into memory only when actually used. For very large knowledge bases (1000+ documents), consider enabling GPU acceleration and using exclude patterns to limit index scope.
|
|
1065
|
+
|
|
1066
|
+
### Multiple MCP clients spawn duplicate servers
|
|
1067
|
+
|
|
1068
|
+
MCP stdio is one process per client by protocol — multiple Claude Code windows, Claude Desktop + IDE, etc. each spawn their own `knowledge-rag` process. Since v3.8.0 idle processes are cheap (no embedding model loaded until first query). If you've measured and want a hard cap of one server per data directory, opt in:
|
|
1069
|
+
|
|
1070
|
+
```bash
|
|
1071
|
+
export KNOWLEDGE_RAG_SINGLE_INSTANCE=1
|
|
1072
|
+
```
|
|
1073
|
+
|
|
1074
|
+
A second instance exits immediately with code 75. Default is OFF (multi-client friendly). Full guide: [docs/single-instance.md](docs/single-instance.md). Sample MCP config: [examples/mcp-config-single-instance.json](examples/mcp-config-single-instance.json).
|
|
1026
1075
|
|
|
1027
1076
|
---
|
|
1028
1077
|
|
|
1029
1078
|
## Changelog
|
|
1030
1079
|
|
|
1080
|
+
### v3.8.0 (2026-05-10)
|
|
1081
|
+
|
|
1082
|
+
- **NEW**: Lazy-load FastEmbed embedding model (~200MB ONNX runtime). Loads on first query instead of startup — idle `knowledge-rag` processes are now cheap, which matters when MCP stdio clients spawn parallel server processes (multiple Claude Code windows, Claude Desktop + IDE, etc.). Public API unchanged. (#32)
|
|
1083
|
+
- **NEW**: Opt-in single-instance guard via `KNOWLEDGE_RAG_SINGLE_INSTANCE=1` env var. **OFF by default** — multi-client MCP usage continues to work unchanged. When enabled, a second server process for the same `data_dir` exits with code 75 (`EX_TEMPFAIL`). Includes stale-PID recovery and SIGINT/SIGTERM handlers. See [docs/single-instance.md](docs/single-instance.md). (#33, original concept by @Hohlas in #31)
|
|
1084
|
+
- **NEW**: `examples/mcp-config-single-instance.json` — sample MCP client config for the opt-in guard.
|
|
1085
|
+
- **DOCS**: New `docs/single-instance.md` — when to use, when NOT to use, troubleshooting, full activation reference.
|
|
1086
|
+
- **DOCS**: README troubleshooting section for "Multiple MCP clients spawn duplicate servers" + memory-usage note for lazy embeddings.
|
|
1087
|
+
- **CHORE**: Sync version across `pyproject.toml`, `mcp_server/__init__.py`, and `npm/package.json` (was drifting since v3.5.x).
|
|
1088
|
+
- **CHORE**: pytest `tmp_path_retention_count=1` to avoid Windows atexit cleanup race in CI.
|
|
1089
|
+
- **ROADMAP**: Tracked v4.0 shared-service architecture (one daemon, many thin MCP clients) as the long-term fix for multi-process resource duplication. (#34)
|
|
1090
|
+
|
|
1091
|
+
### Unreleased
|
|
1092
|
+
|
|
1093
|
+
- **FIX**: Startup preflight probes ChromaDB in a child process and moves crashing persistent indexes to `data/backups/auto-repair-*` before MCP initialization.
|
|
1094
|
+
- **FIX**: Reranker load failures now fall back to RRF ordering instead of failing `search_knowledge` on offline machines.
|
|
1095
|
+
- **FIX**: Virtualenv project-root detection now handles Python symlinks that resolve to the system interpreter.
|
|
1096
|
+
- **NEW**: `knowledge-rag-guarded` console script kept as an explicit guarded startup alias.
|
|
1097
|
+
|
|
1031
1098
|
### v3.6.2 (2026-04-23)
|
|
1032
1099
|
|
|
1033
1100
|
- **INFRA**: NPM provenance attestation (SLSA supply chain security), full README on npm page
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knowledge-rag",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Local RAG System for Claude Code — Hybrid search + Cross-encoder Reranking + 12 MCP Tools + 20 Format Parsers. Zero external servers.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"knowledge-rag": "./bin/cli.js"
|