kb-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@kb-server search my vault for notes about the Goodhart's law article, then summarize them"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
kb-tools
Tooling for a personal LLM wiki in the pattern Andrej Karpathy described: a folder of plain markdown that a coding agent reads, writes and keeps current, browsed in Obsidian. This package puts a graph, a search index, guarded writes and an MCP server over such a vault, and runs an autonomous ingestion loop that files new sources by itself behind a fail-closed merge gate.
There is no RAG here, no embeddings and no vector store, by decision rather than omission. Retrieval is lexical and in memory: term frequency with a title boost and a one-hop walk along wikilinks. The pattern is knowledge compiled into pages an agent can read whole, not chunks retrieved by similarity.
My own vault is private: it holds third-party papers I cannot redistribute and personal notes. It consumes this package pinned to a release tag. examples/vault/ is a small slice of it so you can run everything below.
The vault it expects
raw/is the evidence layer: immutable source material. Nothing in the tooling can write here; the guard is in code, not convention.wiki/is the compiled layer: synthesised pages, each citing the sources it was written from. Agents maintain it; a human reads it.index.mdis the map the agent routes questions through;log.mdis append-only history.
templates/kb-schema.md is the schema an agent follows to maintain a vault like this, and docs/CONTEXT.md is the glossary.
Related MCP server: obsidian-mcp-context
Quick start
python3 -m venv .venv && .venv/bin/pip install -e .
.venv/bin/kb --root examples/vault verify # graph + citation audit
.venv/bin/kb --root examples/vault search "goodhart"
.venv/bin/kb --root examples/vault read wiki/concept-software-engineering-laws
.venv/bin/python -m unittest discover -s tests -t . # runs against a temporary fixture vaultOr install it into another project: pip install git+https://github.com/philippe-ths/kb-tools@v1.0.0.
The root falls back to KNOWLEDGE_BASE_ROOT. Add --json before the subcommand for machine-readable output.
The MCP server
kb-server --root /path/to/vault exposes ten tools over stdio to Claude Code, Codex or Claude Desktop. kb install --host claude (or codex) prints the host config; --write --yes applies it.
Tool | Does |
| lexical search over |
| one page with its outgoing links and backlinks |
| a bundle of pages for a question |
| the catalogue: categories, counts, orphans, broken links |
| graph hygiene report |
| graph plus citation audit |
| unified diff per operation and before/after verification, over an in-memory overlay; writes nothing |
| commit a change set through the guarded writers, then re-verify on disk |
| the recorded search history |
| record a gap or a subject worth researching, for a research process to read later; nothing is researched now |
| the recorded research suggestions |
| re-read the vault after an outside change |
A change set is JSON: write_page under a flat wiki/, write_index, add_index_entry (one catalog line into an existing category, leaving the rest of index.md untouched), or append_log. Those are the only writes that exist. raw/ cannot be written, log.md can only be appended, and a path that escapes the vault is refused.
Autonomous ingestion
kb --root <vault> auto-ingest, scheduled weekly through launchd (kb install --host launchd):
Find pending sources: any
raw/*.mdno wiki page cites, minus the vault's.kb-ingest-ignore.Branch from the remote base into a
kb-maintenance/worktree, so the human's checkout is never touched.For each source, a writer agent (Claude CLI, headless) synthesises a cited page and commits it together with the source it cites.
An independent reviewer agent reads the diff adversarially and returns a structured JSON verdict.
A deterministic merge gate decides. It merges only when validation passes, verification shows zero warnings and zero new warnings, the diff touches only
wiki/,index.md,log.mdandraw/, the worktree is clean after the commit, and the reviewer raised no blocking objection. Anything else leaves the pull request open for the human.
Both agents run under a hard-coded allowlist of the kb_* tools and nothing else: no Bash, no Write, no Edit. The git, gh and agent calls sit behind injectable seams, so the gate's logic is unit-tested without a model in the loop. If the vault has a validation script at .ai-policy/scripts/run-validation.sh it runs as part of the gate; otherwise validation is recorded as skipped.
Layout
Module | Responsibility |
| root resolution, file discovery, reads, and the guarded writers |
| wikilink parsing and target resolution |
|
|
| in-memory graph: links, backlinks, broken links, orphans |
| lexical search index |
| change-set model and write-rule guards |
| graph and citation audit, before/after deltas |
| maintenance runs, worktree planning, PR reports |
| pending-source detection, the ingestion orchestrator and merge gate, the Claude CLI runner |
| MCP host config and launchd snippets |
|
|
| the CLI and the MCP server, both thin adapters over |
The core is standard-library Python 3.10+; only the MCP server needs the mcp SDK.
Decisions
0001: a local MCP knowledge base with propose/apply writes.
0002: autonomous ingestion with a guarded auto-merge.
0003: this package split out of the private vault.
License
MIT. The example vault's content is included for demonstration.
Auto-ingest agents
Each claude call auto-ingest makes is sealed: its own system prompt (the role plus the vault's kb-schema.md), only the knowledge-base MCP server, no built-in tools, settings, skills or CLAUDE.md, run from an empty directory. Ingest runs on claude-sonnet-5-5 at medium effort; the one review per run on claude-opus-5-5 at high effort. Override with KB_INGEST_MODEL, KB_INGEST_EFFORT, KB_REVIEW_MODEL, KB_REVIEW_EFFORT. Each result in the run report carries the call's usage (cost, turns, tokens).
Available Tools
12 toolskb_apply_changesA
Commit a change set to disk, then re-verify.
Same change shape as kb_propose_changes. Writes go through the guarded vault writers: raw/ is never written and log.md is append-only. Returns the applied operations and the post-apply verification.
Inputs: changes (required).
kb_build_contextB
Assemble a navigable starting set for a query.
Returns the top matching pages with snippets plus their immediate graph neighbours, to decide what to read next.
Inputs: query (required), limit.
kb_fetch_queriesA
Read back recorded queries (kb_search / kb_build_context calls).
Returns the most recent limit entries oldest-first, each
{ts, tool, query, limit, results}, with count being how many were
returned. Use it to see what has actually been asked of the wiki.
Inputs: limit.
kb_fetch_suggestionsA
Read back recorded research suggestions (kb_suggest_research calls).
Returns the most recent limit entries oldest-first, each
{id, ts, kind, subject, topic, reason, by}, with count being how many
were returned.
Inputs: limit.
kb_graph_summaryC
Graph statistics and the index.md category structure.
Inputs: no named parameters.
kb_hygieneC
Broken links, missing-page targets, and orphan pages.
Inputs: no named parameters.
kb_propose_changesA
Preview a change set without writing.
Each change is {op:'write_page', page_id, text} | {op:'write_index', text} | {op:'add_index_entry', category, entry} | {op:'append_log', text}. Prefer add_index_entry for a new page: it adds one catalog line without reading or rewriting index.md. Returns a unified diff and create/update/append action per operation, plus verification before and after the change as it would land (with the warning delta). Nothing is written.
Inputs: changes (required).
kb_read_pageB
Read one page by id (e.g. 'wiki/overview').
Returns its markdown text, resolved outgoing links, and backlinks.
Inputs: page_id (required).
kb_reloadB
Rebuild the in-memory graph and search index from disk.
Inputs: no named parameters.
kb_searchB
Lexical full-text search over index.md and wiki pages.
Returns ranked results with page id, title, score, matched terms, and a prose snippet.
Inputs: query (required), limit.
kb_suggest_researchA
Tell the owner's research process about a gap in the knowledge base.
Call this when the knowledge base could not answer something your work
needed (kind "gap"), or when a subject the owner's work keeps touching
should be in the knowledge base (kind "subject"). One suggestion per gap.
Phrase subject as one plain sentence saying what is not yet known.
topic is optional (e.g. "AI Engineering", "Running and cardio"); reason
and by (who you are, e.g. "claude-code in repo X") are optional too.
Suggestions are read by a research process later; nothing is researched
now. Do not include secrets or personal data about third parties.
Returns {recorded, id, entry}, or {recorded: false, error} if rejected.
Inputs: subject (required), by, kind, topic, +1 more.
kb_verifyB
Phase-1 audit: graph stats, graph hygiene, and citation hygiene.
Citation hygiene reports uncited wiki pages, source pages with no raw evidence, and broken raw/ citations.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools target clearly distinct operations (search, read, propose/apply changes, fetch queries/suggestions), and the propose/apply and fetch_queries/fetch_suggestions pairs are explicitly differentiated. However, kb_verify overlaps with the combined functionality of kb_graph_summary and kb_hygiene, so an agent may hesitate over which audit-style tool to call first.
Every tool uses the same kb_ prefix followed by a verb_noun or verb_noun_phrase pattern in snake_case (kb_search, kb_read_page, kb_propose_changes, kb_fetch_queries). There are no mixed conventions or stray camelCase names, making the set highly predictable.
With 12 tools, the set is well within a reasonable range for a knowledge-base server and each tool covers a distinct phase of the workflow (search, read, inspect, verify, propose, apply, record, reload). No tool appears redundant or purely filler.
The surface covers search, read, graph inspection, hygiene/citation audits, guarded write flows, query/suggestion recording, and index reload, which is close to full lifecycle coverage for a safe KB. A minor gap is the absence of a direct 'list all pages' or 'get raw index' tool, though kb_graph_summary and kb_search provide workarounds.
Maintenance
Related MCP Connectors
Serve a folder of Markdown notes as an MCP server: hybrid search, reading, and sourced answers.
Hosted MCP server for Obsidian Sync vaults: read, search, edit notes. Not affiliated with Obsidian.
Agent-native MCP server over the public saagarpatel.dev corpus. Read-only, stateless.
Read-only MCP server exposing a user ORANO library to their own AI agent.
Related MCP Servers
- AlicenseCqualityCmaintenanceRead-only MCP server for querying a running Obsidian vault from agentic runtimes, exposing safe Obsidian CLI commands.551MIT
- FlicenseBqualityCmaintenanceParses an Obsidian vault and exposes structured context (notes, blocks, tasks, headings) through MCP tools, enabling AI clients to query and reason over local markdown notes.19-
- FlicenseNot gradedqualityCmaintenanceExposes a local Obsidian vault as a stateless MCP server, letting AI coding agents search, read, browse, and edit notes in real time.-
- AlicenseNot gradedqualityBmaintenanceEnables LLM clients to read, search, and write to a local Obsidian vault over MCP, with full-text search, vault analytics, health scoring, and policy-enforced file operations.1MIT