
NervaPack
io.github.ramdhavepreetam由 GitHub 帳號 ramdhavepreetam 發布v0.5.8更新於 Oct 24, 2026
Offline codebase knowledge graph: 91% token reduction vs naive RAG, plus cross-session agent memory.
概覽
離線程式碼庫知識圖譜 MCP 伺服器,以聚焦且節省 token 的脈絡回答程式碼問題,並提供跨工作階段的代理記憶。
- 可以做什麼
- 查詢已索引的程式碼庫:向量檢索加上 K 跳圖形遍歷,回傳聚焦的 Markdown 脈絡區塊與 token 節省數據
- 檢視圖譜狀態:節點與邊數量、語言分布、未同步檔案提醒,並瀏覽已索引的類別、函式、匯入與文件
- 影響分析:反向相依查詢,找出相依於某個實體的內容
- 管理代理記憶:開啟與結束工作階段,儲存事實、決策、流程與偏好,在 token 預算內召回,並取得實體檔案、決策理由與時間軸
- 維護記憶:確認或反駁條目、遺忘或清除節點、列出與清空工作階段、切換命名空間、批次匯入,以及標記來源檔案已變更的記憶
- 連結記憶與程式碼:找出涉及某個檔案或程式碼行的記憶,以及某條記憶涉及的程式碼位置
- 適用情境
- 適合在本地 git 儲存庫中反覆工作的情境:希望程式碼問題根據精簡的結構化脈絡回答,而不是把整份檔案塞進去;或希望決策與慣例能跨對話工作階段保留,不必每次重新貼上脈絡。
- 執行需求
- 以 Python 套件形式透過 stdio 在本機執行(需 Python 3.10+),以 uvx 啟動;專案必須是 git 儲存庫。需先以 ingest 指令建立圖譜。選用的文件與程式碼語意綁定需要 LLM:預設為本機 Ollama,雲端則需 ANTHROPIC_API_KEY 或 OPENAI_API_KEY 環境變數。首次執行會下載約 30 MB 的 ONNX 嵌入模型。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 NervaPack,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
NervaPack
[PyPI version] [Python Versions] [License: MIT] [Token Reduction] [Verified] [MCP Registry]
NervaPack is a privacy-first, offline knowledge graph for your codebase. It solves two fundamental problems with standard Vector RAG:
- Token waste — chunk-based RAG retrieves blobs of text that may only tangentially relate to your query, bloating your context window.
- Privacy risk — sending code to cloud embedding APIs leaks your proprietary logic.
NervaPack runs 100% on your machine. It uses tree-sitter to parse your codebase into a deterministic Abstract Syntax Tree graph, then uses a local Ollama model to draw hard semantic edges between your documentation and your code. Queries traverse this graph with a K-Hop BFS, returning a hyper-targeted, token-efficient context window — no cloud required.
Verified Performance
91.2% Average Token Reduction — independently verified on real-world codebases.
Cost Savings: $181–$724 per developer per year (GPT-4o to Claude Sonnet)
📊 View Full Benchmarks · 🧪 Messy Code Performance
Code quality impact: 90–99% reduction on clean code, 50–75% on legacy/messy code. Even poorly structured codebases benefit significantly.
Why NervaPack vs. standard Vector RAG
Prerequisites
- Python 3.10+
- Git — your project must be a git repository (
git initif not)
(Optional for semantic code-doc binding) — an LLM provider. Structural graph indexing and basic queries work out-of-the-box with zero configuration and no cloud connection.
Installation
On first run, ChromaDB downloads an ONNX embedding model (~30 MB) to
~/.cache/chroma/. This is a one-time download.
Quick Start
Command Reference
nervapack ingest [PATH] — Build the graph
Scans PATH (default: .) and builds the full knowledge graph.
What happens:
- Walks the directory tree with tree-sitter, skipping
dist/,build/,node_modules/,venv/,site/,.tox/, and dozens of other build directories automatically. - Parses source files into exact AST nodes: classes, functions, imports.
- Chunks all
.mdfiles by header hierarchy. - Embeds every entity into a local ChromaDB vector store (ONNX by default, Ollama optional).
- Optionally binds doc chunks to code nodes via an LLM, adding
EXPLAINSedges. - Saves the graph once to
.nervapack/graph.graphml.
Re-ingesting is safe — upsert is used throughout, so running ingest twice does not duplicate data.
Supported languages (bundled): Python, JavaScript, JSX, TypeScript, TSX
Additional languages:
Exclude directories — create .nervapackignore in your project root (gitignore syntax):
nervapack query PROMPT — Query the graph
Retrieves focused context for a natural-language prompt and prints a token savings dashboard.
What happens:
- Intent detection — "what breaks if I change X" routes to impact analysis (reverse BFS); exact symbol names bypass vector search.
- ChromaDB returns the top-3 most semantically similar nodes.
- Those nodes seed a K-Hop BFS through the NetworkX graph (default: 1 hop, both directions).
- Adjacent nodes — including any markdown docs via
EXPLAINSedges and memory notes viaTOUCHESedges — are collected. - A focused Markdown context block is printed, ready to paste into an LLM prompt.
- Token efficiency panel shows savings vs. naive "dump the whole file" RAG.
Example output:
nervapack sync [PATH] — Incremental update
Updates only the files that changed since the last ingest. Uses GitPython to diff the working tree.
A full ingest on a large project can take minutes. sync turns that into a 2–5 second surgical update per file. Re-parses changed files, batch-upserts new vectors, and saves the graph once at the end.
nervapack clean [OPTIONS] — Remove ingested data
Wipe graph data and start fresh. Use this when you have duplicate vectors, ingested the wrong directory, or need to reduce disk usage.
Never deleted by clean: memory.db — your agent memory is always safe.
Typical workflow after a bad ingest:
nervapack enrich [PATH] — Add semantic edges
Runs LLM doc-to-code binding on an already-ingested graph. Use this if you:
- Ran
ingestwithout an LLM and want to addEXPLAINSedges now. - Added new documentation and want to bind it without a full re-ingest.
nervapack status [--detailed] — Graph health
Health score (0–100) factors in documentation coverage, node connectivity, graph density, and edge diversity. A structural-only graph typically scores 30–40; after enrich it rises to 70–90.
nervapack visualize [OPTIONS] — Interactive HTML graph
Produces a standalone HTML file with no external dependencies — drag, zoom, search, find shortest paths between nodes.
nervapack explore TARGET [--hops N] — Focused subgraph
Extract and visualize the N-hop neighbourhood of a specific file, class, or function.
nervapack dependencies [FILE] — Import dependency analysis
Analyze file-level import chains, detect circular dependencies, and visualize the dependency graph.
nervapack hotspots [OPTIONS] — Change frequency analysis
Show which files change most often in git history — prime targets for documentation and review.
nervapack history [OPTIONS] — Query history
nervapack serve [--port N] — Web dashboard
Requires nervapack[dashboard]. Shows graph overview, language distribution, analytics, query history trends, and an interactive graph explorer.
nervapack doctor — Environment check
Verifies Python version, tree-sitter grammars, embedding backend, Ollama connectivity, and MCP config. Run this after installation or when troubleshooting.
Storage Layout
Everything lives in .nervapack/ inside your project root:
Add .nervapack/ to .gitignore to keep it out of version control.
Disk usage guide:
chroma_db/— typically 10–100 MB depending on project size. Runnervapack clean --vectors && nervapack ingest .if it grows unexpectedly.graph.graphml— typically 0.5–5 MB.memory.db— grows with agent usage; rarely exceeds a few MB.
MCP Integration (Claude Code, Cursor, Windsurf)
NervaPack ships two MCP servers in the same package. Drop this .mcp.json in your project root:
Knowledge Graph MCP tools (nervapack-mcp)
Agent Memory MCP tools (nervapack-memory-mcp) — 17 tools
CLAUDE.md template
Add to your CLAUDE.md to wire NervaPack into every Claude Code session:
Architecture
Key source modules:
nervapack.memory — Agent Memory
Stop re-pasting project context into every new chat.
Token efficiency:
CLI:
Data model: 8 node kinds, 7 edge kinds, bi-temporal (valid_from/valid_until), never hard-deletes by default.
Privacy
NervaPack is 100% offline by default:
- Embeddings use ChromaDB's built-in ONNX model (runs on CPU, no cloud).
- LLM calls (when using Ollama) go to
localhost:11434only. - All graph and vector data lives in
.nervapack/inside your project. - No telemetry, no analytics, no network calls at runtime.
Only if you explicitly pass --llm claude or --llm openai does any code leave your machine.
Contributing
- Fork the repo and create a branch.
- Run tests:
python3 -m pytest tests/memory/ -q - Run docs check:
python3 -m mkdocs build --strict - Open a pull request against
master.
Bug reports and feature requests: issue tracker.
License
MIT — see LICENSE.
來源:README.md,提交 a3a0548
工具
0版本歷史
1- v0.5.8最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分