About Knowledge Rag
Knowledge Rag is an MCP server published by lyonzin in the RAG category: local RAG server for Claude Code, Cursor and other MCP clients: hybrid BM25 + vector search with cross-encoder reranking on by default, 13 MCP tools, 33 file types including code, re-indexing on file changes. One Python process with embedded ChromaDB and FastEmbed ONNX: no Docker, database server or API key; offline after the first model download. Conduid read 13 tools from its source: add_document, add_from_url, evaluate_retrieval, get_document, get_index_stats, get_reindex_status and 7 more. It is published to PyPI as knowledge-rag and runs with uvx.
The repository has 308 stars and 51 forks, is licensed MIT, and its last commit was on 28 Nov 2026. The latest release is v5.1.0 (14 Nov 2026): Minor release. Nothing breaking on upgrade, and existing indexes need no reindex. Most of it answers six reports from one large installation (a whole drive as documents_… It follows v5.0.1 (6 Nov 2026), and the 5 most recent releases go back to v4.11.0 (4 Oct 2026). It passes 4 of the 5 static checks Conduid ran on the repository; it does not pass Dependencies pinned. Its topics include bm25, chromadb, fastembed, knowledge-base, local-ai and privacy.
Install
uvx knowledge-ragpip install knowledge-raggit clone https://github.com/lyonzin/knowledge-ragTools (13)
add_documentSaves text as a file under `documents/` and indexes it| Parameter | Type | Description |
|---|---|---|
| category | string | Category stored with the document (default: general). Any name is accepted, but search_knowledge() filters only by configured categories (category_mappings values, keyword_routes keys, general), and update_document() or re-indexing the file detects it again from the path through category_mappings. list_categories() shows the categories in use. |
| content * | string | Full text content of the document (markdown supported) |
| filepath * | string | Relative path within documents directory (e.g., "security/new-technique.md"). The subdirectory should match the category. |
add_from_urlFetches an http(s) page, strips the HTML, saves it as Markdown with a provenance marker and indexes it| Parameter | Type | Description |
|---|---|---|
| category | string | Category stored with the document and the folder it is saved in; default: general. Being part of the path, it must stay inside documents_dir: a value such as ../outside returns a "Filepath rejected" error. Any other name is accepted, but search_knowledge() filters only by configured categories (category_mappings values, keyword_routes keys, general), and update_document() or re-indexing the file detects it again from the path through category_mappings. list_categories() shows the categories in use. |
| title | string | Optional document title. Auto-detected from the page's <title> tag if omitted. |
| url * | string | Full URL to fetch (https:// required). The page must be publicly accessible. |
evaluate_retrievalReports MRR@5 and Recall@5 for your own query → expected file pairs| Parameter | Type | Description |
|---|---|---|
| test_cases * | string | JSON string array of test cases. Each item requires "query" (search string) and "expected_filepath" (path of the document that should appear in top-5 results). Example: [{"query": "suid exploit", "expected_filepath": "security/suid.md"}] |
get_documentReturns the full content of one indexed file| Parameter | Type | Description |
|---|---|---|
| filepath * | string | Relative path to the document within the documents directory (e.g., "security/technique.md"). Must be an indexed file — use search_knowledge() to find the filepath by topic first, or browse list_documents(), which returns one page at a time (see its offset). |
get_index_statsDocument and chunk counts, embedding model, BM25 status, cache hit rate, watcher status, HNSW self-recall probeget_reindex_statusReports the progress of a background reindexlist_categoriesLists categories, derived from folder paths, with document countslist_documentsLists indexed documents, 100 per page by default (up to 200 with `limit`), paged with `offset`| Parameter | Type | Description |
|---|---|---|
| category | string | Optional category filter, matched exactly against each document's category; an empty string, like omitting it, lists every document, and a category without documents returns an empty page (total 0). Call list_categories() to see the categories that hold documents. |
| limit | integer | Maximum number of documents to return (default: 100, max: 200). |
| offset | integer | Number of matching documents to skip (default: 0). For the next page, call again with offset + count until offset reaches total. |
reindex_documentsIncremental by default; `force` re-embeds every file, `full_rebuild` builds and swaps a staging collection; runs in the background| Parameter | Type | Description |
|---|---|---|
| force | boolean | |
| full_rebuild | boolean | |
| resume | boolean |
remove_documentRemoves a document's chunks from the index, and optionally the file| Parameter | Type | Description |
|---|---|---|
| delete_file | boolean | If True, permanently deletes the file from disk in addition to removing from the index (default: False). |
| filepath * | string | Path to the document file. Must be an indexed document — list_documents() lists indexed paths, one page at a time. |
search_knowledgeHybrid BM25 + vector search with cross-encoder reranking; filters by category, folders (`include_folders`, `exclude_folders`) and `min_score`| Parameter | Type | Description |
|---|---|---|
| category | string | Optional category filter. Accepts the categories the server is configured with (category_mappings values and keyword_routes keys) plus general; an empty string, like omitting it, searches every category, and any other value returns an error that lists the valid ones. Call list_categories() first to see which categories hold documents and how many. |
| exclude_folders | array | Optional recursive directory exclusions, applied before candidate selection. Exclusions override inclusions. Paths use / or \\, have exact component boundaries, and cannot be absolute, contain '..', or resolve outside documents_dir. Maximum 32 each. |
| hybrid_alpha | number | Balance between semantic and keyword search. 0.0 = keyword-only (best for exact technical terms like CVE IDs or tool names), 0.3 = balanced default, 1.0 = semantic-only (best for conceptual or natural-language queries). While the keyword index is not built (a reindex, a document write or the lexical index migration holds the index, or its build failed), a keyword-only search returns an error that says why, with a suggestion, instead of reporting no results. |
| include_folders | array | Optional list of directories relative to documents_dir, recursively included before candidate selection (e.g. ["manuals/product-a", "runbooks"]). Omit for all folders. |
| max_results | integer | Maximum number of results (default: 5, capped by search.max_results). |
| min_score | number | Minimum score (0.0–1.0) a result needs to be returned; default 0.0 returns all results. Scores are min-max normalized per query over its candidates: the best scores 1.0 and the weakest 0.0, while a single candidate or candidates that all tie score 1.0. On the hybrid path (results labeled hybrid, semantic or keyword) the candidates are the returned results, so any min_score above 0 drops at least the weakest one unless all tie; fts5 results are BM25 scores normalized over up to max(3 * max_results, 20) hits, so even the weakest returned one can score well above 0.0. It is not an absolute relevance bar. |
| query * | string | Search query text (1–3 keywords recommended; phrase queries also work) |
| search_method | string | Dispatch selector (v4.8.2+). One of ``"auto"`` (router picks FTS5 fast-path for lexical queries when enabled, hybrid otherwise), ``"hybrid"`` (force hybrid path — kill switch for suspected router misclassification), or ``"fts5"`` (force FTS5 fast-path — debug/testing; errors out when the feature is disabled or the index is not ready). Default ``"auto"`` preserves pre-v4.8.2 behavior byte-for-byte when the fast-path is disabled in config. |
| snippet_mode | boolean | When true (default), truncates content to ~500 characters from the start of the matching chunk, at a natural break point, and adds a content_length field with the full size. Use get_document() to fetch full content when needed. Set to false to return the full content, which can include adjacent chunks; match_offset, when present, is where the match starts. |
search_similarFinds documents similar to an indexed file| Parameter | Type | Description |
|---|---|---|
| filepath * | string | Path to the reference document (must already be indexed — list_documents() lists indexed paths, one page at a time). E.g., "security/technique.md" |
| max_results | integer | Number of similar documents to return (default: 5, max: 20) |
update_documentReplaces a document's content and re-indexes it| Parameter | Type | Description |
|---|---|---|
| content * | string | New full-text content to replace the existing content entirely |
| filepath * | string | Full or relative path to the document file. Must be an already-indexed file — list_documents() lists indexed paths, one page at a time. |
Security checks
- ✓README presentThe repository's README runs to about 7.5K words.
- ✓License declaredThe repository declares the MIT license.
- ✓Tests presentA test suite exists in the repository.
- !Dependencies pinnedNo lockfile. Installs can pull different code over time.
- ✓No dynamic code executionScanned 25 source files and found no eval, dynamic Function or shell execution.
1 check has not been run yet.
Releases
README
The repository's README runs to about 7.5K words, fetched 12 days ago. The original in the repository is authoritative.
Read full README