py_mnn_kb

Local vector knowledge base with GraphRAG retrieval (vector + BM25 + knowledge graph). Use this skill when the user mentions: "查知识库", "加入知识库", "记住这个", "save to KB", "add to knowledge base", "query knowledge base", "记录一下", or similar intent to store or retrieve private knowledge.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "py_mnn_kb" with this command: npx skills add er6y/py-mnn-kb

py_mnn_kb — MNN Knowledge Base Skill

Local GraphRAG knowledge base backed by SQLite + MNN embeddings. Fully compatible with Android OfflineAI RAG database format.


Setup

1. Install dependencies

pip install -r requirements.txt

2. Configure

cp config.example.json config.json
# Edit config.json: set llm_api.api_key, optionally change default_name

Key fields in config.json:

FieldDefaultDescription
knowledge_base.default_namedefaultKB used when --kb is omitted
knowledge_base.storage_dirassets/knowledge_basesWhere DB files are stored
llm_api.api_key(required for query+LLM)OpenAI-compatible API key
graph_ner.custom_dict_pathassets/example_terms.jsonDomain terminology for NER

3. First run (auto-downloads embedding model)

python scripts/py_mnn_kb.py status

On first use, Qwen3-Embedding-0.6B-MNN-int4 (~400 MB) is auto-downloaded into assets/.


Tools

kb_build — Build / append knowledge base from files

Indexes a directory of documents. Runs in background; returns immediately. Check progress with kb_status.

Parameters:

NameTypeRequiredDescription
dir_pathstringyesDirectory path to index (recursive)
kb_namestringnoKB name (default: value of default_name in config.json)

Returns: { status, command, kb_name, pid, files, message }

Supported formats: .txt .md .pdf .docx .pptx .xlsx .csv .html .json .jsonl

CLI:

python scripts/py_mnn_kb.py build ./my_docs/ --kb my_kb
python scripts/py_mnn_kb.py build ./my_docs/          # uses default KB name

Trigger phrases: "加入知识库", "索引这个目录", "build KB", "index these files"


kb_note — Insert a text note directly into the knowledge base

Embeds and stores a free-form text snippet. Synchronous. Refused while build is running.

Parameters:

NameTypeRequiredDescription
textstringyesText content to store
kb_namestringnoKB name (default: default_name)
titlestringnoOptional title, stored as source label

Returns: { status, kb_name, chunks_added, elapsed_sec }

CLI:

python scripts/py_mnn_kb.py note "Q1 roadmap: focus on modules A and B" --kb my_kb
python scripts/py_mnn_kb.py note "$(cat meeting.txt)" --kb my_kb --title "Weekly meeting"

Trigger phrases: "记住这个", "记录一下", "加个笔记", "save this", "remember this"


kb_query — Retrieve relevant chunks (RAG retrieval)

Runs vector + BM25 + GraphRAG fusion and returns the top-N context string. The agent appends this context to its prompt — no LLM call is made inside this tool. Synchronous. Refused while build is running.

Parameters:

NameTypeRequiredDescription
promptstringyesQuery question or keywords
kb_namestringnoKB name (default: default_name)

Returns: Multi-document context string, e.g.:

Document1 [ID:42 source:manual.pdf]:
Deployment has three steps...

Document2 [ID:55 source:notes.md]:
...

CLI:

python scripts/py_mnn_kb.py query "NAND筛选核心流程" --kb my_kb --no-llm
python scripts/py_mnn_kb.py --output json query "产品路线图" --kb my_kb

Agent usage pattern:

context = kb_query("用户的问题", kb_name="my_kb")
# Then: f"Based on the following context:\n{context}\n\nQuestion: {user_question}"

Trigger phrases: "查知识库", "查一下", "知识库里有没有", "search KB"


kb_status — Check build progress or last build result

No KB initialization needed. Always returns instantly.

Parameters:

NameTypeRequiredDescription
kb_namestringno(informational only, does not affect result)

Returns:

  • While building: { status: "building", progress: 0-100, message }
  • After success: { status: "ok", message, stats: { chunks_added, elapsed_sec, ... } }
  • After failure: { status: "error", error }
  • Not yet run: { status: "idle", message }

CLI:

python scripts/py_mnn_kb.py status

Trigger phrases: "构建进度", "build status", "知识库建好了吗"


Workflow Examples

A · User uploads files → auto-index

User: "把这些文档加入知识库"
Agent → save files to temp dir
      → kb_build(dir_path=tmp_dir, kb_name="my_kb")   # returns immediately
      → "已开始后台构建,用 kb_status 检查进度"

B · User dictates a note → insert

User: "记住:STAR2000 低温写性能提升 8%"
Agent → kb_note(text="STAR2000 低温写性能提升 8%", kb_name="my_kb", title="技术发现")
      → "已保存到知识库 my_kb"

C · User asks a question → KB-assisted answer

User: "NAND 筛选核心流程是什么?"
Agent → context = kb_query("NAND 筛选核心流程", kb_name="my_kb")
      → append context to LLM prompt → generate answer

D · Check if build finished before querying

Agent → st = kb_status()
      → if st["status"] == "building": tell user to wait
      → else: proceed with kb_query(...)

Notes

  • kb_build is incremental append — re-running on the same directory adds only new content
  • kb_note and kb_query are blocked (return status: building) while a build is running
  • --output json on any CLI command returns machine-parseable JSON on stdout
  • KB name default is used when --kb is omitted; configure default_name in config.json

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

Agent Memory Local

Local-first memory retrieval for Agent/OpenClaw workspaces. Use when the user asks about prior work, decisions, dates, preferences, root causes, todo history...

Registry SourceRecently Updated
2912Profile unavailable
Security

Privacy Mask

Mask, redact, anonymize and censor sensitive information (PII) in screenshots and images — phone numbers, emails, IDs, API keys, crypto wallets, credit cards...

Registry SourceRecently Updated
4361Profile unavailable
Automation

claw-voice-local

Convert text to offline Telegram voice messages using piper TTS. Use when the agent should speak a response, send audio, or deliver voice notes via Telegram...

Registry SourceRecently Updated
820Profile unavailable
Coding

OpenClaw Memory Stack

Total recall, 90% fewer tokens. The best OpenClaw memory plugin — 5-engine local search, structured fact extraction, smart dedup, cross-agent sharing, and se...

Registry Source
2121Profile unavailable