Python client for kb0 — the knowledge base layer for AI agents (MCP, markdown, git).
Project description
kb0 (Python client)
Native Python client for kb0 — the knowledge base layer for AI agents. Markdown-first, git-backed, MCP-native.
This package hides the MCP plumbing and gives you a clean async VaultClient.
pip install kb0-mcp
The PyPI package is
kb0-mcp; you stillimport kb0in code.Requires the kb0 server. This is a client — it spawns the
kb0binary as a subprocess. Install it once with Node:npm install -g kb0-mcp, thenkb0 init my-vault.
Quickstart
import asyncio
from kb0 import VaultClient
async def main():
async with VaultClient(vault="./my-vault", agent="my-bot") as kb:
# write a note (author, id, timestamps set by the server)
res = await kb.write(
"notes/auth.md",
title="Auth: we chose JWT",
content="Short-lived access + refresh tokens. See [[notes/security.md]].",
tags=["security"],
)
print("created", res["path"], "hash", res["hash"])
# search (hybrid by default)
hits = await kb.search("authentication design")
for r in hits["results"]:
print(r["score"], r["title"], r["path"])
# read + update with optimistic locking
note = await kb.read("notes/auth.md")
await kb.update(
"notes/auth.md",
content=note["content"] + "\n\nUpdate: rotating keys monthly.",
expected_hash=note["hash"],
)
asyncio.run(main())
Configuration
VaultClient passes everything through to kb0 serve:
VaultClient(
vault="./my-vault", # vault directory
agent="my-bot", # agent identity (provenance + ACL)
openai_api_key="sk-...", # optional — enables semantic search
strict=False, # require .vault-policy.yaml if True
command="kb0", # override the binary path if needed
env={"KB0_EMBEDDING_MODEL": "text-embedding-3-large"},
)
API
All methods are async and return plain dicts (the tool's structured output).
| Method | kb0 tool |
|---|---|
await kb.write(path, *, title, content, status="draft", tags=None) |
vault.write |
await kb.read(path) |
vault.read |
await kb.update(path, *, content, expected_hash, title=None, status=None, tags=None) |
vault.update |
await kb.delete(path) |
vault.delete |
await kb.search(query, *, mode="hybrid", ranking="rrf", limit=10, filters=None) |
vault.search |
await kb.list(*, prefix=None, tag=None, status=None, limit=50) |
vault.list |
await kb.recent(limit=10) |
vault.recent |
await kb.backlinks(path) |
vault.backlinks |
await kb.links(path) |
vault.links |
await kb.status() |
vault.status |
Errors
Failures raise typed exceptions you can catch:
from kb0 import KbConflictError, KbACLDeniedError, KbNotFoundError
try:
await kb.update("notes/x.md", content="...", expected_hash=stale_hash)
except KbConflictError:
note = await kb.read("notes/x.md") # re-read, get the current hash, retry
KbError is the base class; KbNotFoundError, KbConflictError,
KbValidationError, and KbACLDeniedError are its subclasses.
Why a subprocess?
kb0 is an MCP server. The Python client launches kb0 serve over stdio and speaks
MCP to it — the same protocol Claude Desktop uses. Your vault stays a local folder
of markdown under git; this client is just an ergonomic way for Python agents to
talk to it. See the main repo for the
architecture.
License
Apache 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kb0_mcp-0.1.0.tar.gz.
File metadata
- Download URL: kb0_mcp-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e4f8f3c52b7089c3f268c64334e7cf31b06b14a412a24a30137beac2545c00c
|
|
| MD5 |
1cb813464a31a4c9979647f937a35f86
|
|
| BLAKE2b-256 |
2e64cacfd60fe6cc7b44a24d6c3c18c186ccf9a3ba12e33972a668b7145275fb
|
File details
Details for the file kb0_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kb0_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cceac3a483058e1656b9b6137bac4241dda446ee7ad6ff2d12326443a8002049
|
|
| MD5 |
e2013c1ecc2f62063d2190e5b54c53b9
|
|
| BLAKE2b-256 |
32d04c707068dccad0bb1e48c8860a825498e874bf18c57cb1db918228673b94
|