kg_query
Query the SPO knowledge graph: "what does X relate to?", "what was true about X when?". Returns temporal entity-relationship triples with validity windows. Accepts entity name (resolved via searchEntities) or canonical ID in vault:type:slug form. Triples are populated by the decision-extractor hook
How to use it
kg_query is exposed by the ClawMem MCP server. Add the server to your MCP client (Claude Desktop, Cursor, Windsurf and others), and the kg_query tool becomes available to the model automatically. See the full listing for setup details and every tool this server provides.
Install ClawMem
npm install -g clawmemOther tools in ClawMem (31)
Sync Beads issues from Dolt backend (bd CLI) into memory: syncs the full backlog (no 50-issue cap), creates docs, bridges all dep types to memoryrelations, surfaces bd ≥1.1.0 claim leases, runs A-MEM enrichment
Build temporal and/or semantic graphs from document corpus
Read recent diary entries. Filter by agent name.
Write a diary entry. Use for recording important events, decisions, or observations in environments without hook support. Stored as searchable memories.
Trace decision chains: "what led to X", "how we got from A to B". Follow up intentsearch with this tool on a top result to walk the full causal chain. Traverses causes / causedby / both up to N hops with depth-annotated reasoning.
USE THIS for "what else relates to X", "show me similar docs". Finds k-NN vector neighbors — discovers connections beyond keyword overlap that search/query cannot find.
Retrieve single document by path or docid
Detailed stats: types, staleness, access counts, sessions
USE THIS for "why did we decide X", "what caused Y", "who worked on Z". Classifies intent (WHY/WHEN/ENTITY/WHAT), traverses causal + semantic graph edges. Returns decision chains that query() cannot find.
Restore documents that were auto-archived by lifecycle policies. Filter by query, collection, or restore all
Document lifecycle statistics: active, archived, forgotten, pinned, snoozed counts and policy summary
Run lifecycle policies: archive stale docs past retention threshold. Archives only — never deletes. Defaults to dryrun (preview only)
Show configured vault names and paths. Empty in single-vault mode.
Show how a document's A-MEM metadata evolved over time
Search → deactivate closest match (with audit trail). Weak matches return a disambiguation list instead of acting (v0.23.0)
Pin a memory: lifecycle retention + priority among relevance-equivalent results (+0.3 composite boost on hook/query surfaces; exact-tie precedence on the raw routes — vector + search non-recency). USE PROACTIVELY when: user states a persistent constraint, makes an architecture decision, or corrects
Ranking diagnostic (v0.36.0): real-pipeline composite breakdown per result — weights, recency, confidence blend, quality/length/frequency/canonical multipliers, signed pinΔ, co-activation — plus raw-vs-composite rank shifts; demoted raw winners stay visible. FTS-only candidates; read-only.
Preferred entry point. Auto-classifies query and routes to optimal backend (query, intentsearch, sessionlog, findsimilar, or queryplan). Use instead of manually choosing a search tool.
Temporarily hide a memory from context surfacing until a date. USE PROACTIVELY when <vault-context> repeatedly surfaces irrelevant content — snooze for 30 days instead of ignoring it.
Lifecycle + ranking-metadata aggregates per collection (v0.36.0): origin×active cross-tabs, pinned, accrual, deactivation reasons, and access/confidence/quality/effective-age distributions (mean/median/min/max over active rows). Deeper than indexstats; includes system collections.
Retrieve multiple docs by glob or comma-separated list
Current static + dynamic user profile
Full hybrid pipeline (BM25 + vector + rerank) — general-purpose when query type is unclear. WRONG for "why" questions (use intentsearch) or cross-session queries (use sessionlog). Prefer memoryretrieve for auto-routing. Intent hint, strong-signal bypass, chunk dedup, candidateLimit, MMR diversity, c
USE THIS for complex multi-topic queries ("tell me about X and also Y", "compare A with B"). Decomposes into parallel typed clauses (bm25/vector/graph), executes each, merges via RRF. query() searches as one blob — this tool splits topics and routes each optimally.
Trigger vault re-scan
BM25 keyword search — for exact terms, config names, error codes, filenames. v0.24.0: non-recency queries rank by the RAW BM25 transform (scoreBasis: "fts-bm25"; judged keyword eval MRR 0.848 vs composite 0.415; metadata breaks exact ties only; minScore filters raw, no default); recency-intent queri
USE THIS for "last time", "yesterday", "what happened", "what did we do". Returns session history with handoffs and file changes. DO NOT use query() for cross-session questions — this tool has session-specific data that search cannot find.
Index health with content type distribution
Show the temporal neighborhood around a document — what was created/modified before and after it. Progressive disclosure: search → timeline (context) → get (full content). Supports same-collection scoping and session correlation.
Index markdown from a directory into a named vault. Restricted-path validation rejects sensitive directories.
Vector semantic search — for conceptual/fuzzy matching when exact keywords are unknown. v0.22.0: non-recency queries rank by RAW cosine (scoreBasis: "vector-cosine"; metadata breaks exact ties only; minScore filters raw with no default); recency-intent queries keep composite. Collection filter suppo