kb-graph
llms.txt4 starsChanged 2 months agoMITView on GitHub
Portable AI knowledge base with SQLite FTS5, semantic search, Obsidian vault sync, and MCP server interface for multi-agent retrieval and self-learning. A personal knowledge base server that AI agents use to persist memory across sessions. Captures debugging sessions, bug fixes, web articles, YouTube transcripts, and research. Classifies and summarizes content automatically. Provides full-text search, semantic search, and token-efficient context briefings via MCP tools. Integrates with Claude, Codex, Gemini, ChatGPT, and any MCP-compatible client. npm link is optional shorthand for exposing…
- Reads credentials
In this repository2 other files it gives its agents.
- debriefSkill
- kb-workflowSkill
The file
We split this llms.txt into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Verify the installation: node bin/kb.js status
- Very specific: line 96
Import OpenAPI spec from https://your-domain.com/openapi.json.
- Very specific: line 99
Use the REST API at /api/v1/ with X-API-Key header.
≈ “Common” is an estimate: at least 1 in 5 of the 1,484 llms.txt files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
# kb-graph
> Portable AI knowledge base with SQLite FTS5, semantic search, Obsidian vault sync, and MCP server interface for multi-agent retrieval and self-learning.
A personal knowledge base server that AI agents use to persist memory across sessions. Captures debugging sessions, bug fixes, web articles, YouTube transcripts, and research. Classifies and summarizes content automatically. Provides full-text search, semantic search, and token-efficient context briefings via MCP tools. Integrates with Claude, Codex, Gemini, ChatGPT, and any MCP-compatible client.
## Quick Setup
1. Clone `https://github.com/uttambharadwaj/kb-graph.git`
2. Install locked dependencies: `npm ci`
3. Configure state and integrations: `node bin/kb.js setup`
4. Verify the installation: `node bin/kb.js status`
5. (Optional) Start the local dashboard/API: `node bin/kb.js start`
6. (Optional) Set `OBSIDIAN_VAULT_PATH` to enable vault indexing and note writing
7. (Optional) Set API keys for remote access: `KB_API_KEY_CLAUDE`, `KB_API_KEY_OPENAI`, `KB_API_KEY_GEMINI`
`npm link` is optional shorthand for exposing the `kb` executable. This guide
uses `node bin/kb.js ...` so a fresh source install does not depend on that
link.
Registry publication is deferred. Do not claim or use a global package, npx, or
a project-local dependency until README.md links a published package. Keep the
source clone at a stable path because setup persists it in registrations and
hooks. Mutable state, `.env`, and the embedding cache live under
`${KB_DIR:-~/.knowledge-base}` rather than inside the checkout.
## MCP Tools
Each row says when to reach for the tool, not just what it does — an agent chooses from that line and nothing else.
| Tool | When to reach for it |
|------|---------|
| kb_search | FTS5 keyword search. You know roughly what you are looking for. |
| kb_search_smart | Hybrid keyword + semantic search. Conceptual or fuzzy queries. |
| kb_context | Bounded truth packet — live summaries, reviewed current state, raw evidence, superseded history, and unresolved claims. Use BEFORE kb_read. |
| kb_read | Full document by ID. After kb_context says which ones are worth it. |
| kb_list | Enumerate documents by type or tag when you are browsing, not searching. |
| kb_tunnels | Which domains a tag connects to, or the bridge between two — cross-domain exploration. |
| kb_write | Capture your own conclusion, decision, lesson or research so the next session has it. Takes a tier; verified needs a commit, PR or test reference. Its result names live notes on the same ground — resolve a contradiction with kb_supersede instead of leaving both. |
| kb_ingest | Ingest raw text you were handed and do not want to reformat. |
| kb_check_duplicate | Before writing, when you suspect the KB already says this. Pass the exact body. |
| kb_supersede | A note has been meaningfully replaced — retire it from recall, keep it readable. |
| kb_supersede_candidates | A briefing contradicts what you just saw. Suggestions only; changes nothing. |
| kb_classify | Notes sitting unclassified in inbox/ or Clippings/ — after a clipper or a sync. Reads only those two folders. |
| kb_extract | Session end: pull durable facts out of a transcript instead of hand-writing kb_fact_add. |
| kb_promote | A later session confirmed a note — raise its tier, recording what did the confirming. |
| kb_synthesize | A review brief over recent notes, for the "what have we learned lately" pass. |
| kb_fact_add | One durable subject-predicate-object fact, with validity dates. |
| kb_fact_query | Raw fact history plus any reviewed current-state projection for an entity. Historical as_of queries do not project reviewed live state. |
| kb_fact_timeline | The order things happened to an entity. |
| kb_fact_invalidate | End erroneous evidence by exact fact ID while preserving the raw row and provenance. |
| kb_capture_session | End of a debugging or implementation session. Redacts secrets from pasted output; kb_write does not. |
| kb_capture_fix | A bug you verified fixed. Symptom and cause are separate fields, so searching the symptom finds the cause. |
| kb_capture_web | A page you fetched and will want to cite. Keeps the URL as provenance. |
| kb_capture_youtube | A transcript already in hand. Does not fetch the video. |
| kb_wakeup | Session start, when no briefing hook ran (remote or cloud sessions). |
| kb_vault_status | Vault indexing stats: note counts by type and project. |
| kb_safety_check | Before any destroy, delete, drop or force-push — checks the action against past incidents. |
## Extension Points
| File | What to Modify |
|------|----------------|
| src/tools.js | Add new MCP tools. Central registry for all tool definitions. |
| src/ingest.js | Add new content source types. Extend TYPE_MAP and extractors. |
| src/db.js | Database migrations, queries, FTS5 config. Core tables: documents, vault_files, embeddings, facts, retrievals. Search and single-doc reads are metered here — pass a `surface` from src/retrieval.js. |
| src/schema.js | Migration engine. Connecting verifies; only `node bin/kb.js migrate` executes DDL. |
| src/server.js | Express routes, middleware, auth chain. |
| src/mcp-http.js | HTTP MCP transport. Session management, StreamableHTTP. |
| src/mcp.js | Stdio MCP transport. Local agent integration. |
| bin/kb.js | CLI commands. One table drives dispatch, help, and flag validation. |
| src/classify/classifier.js | AI classification pipeline. Uses Claude CLI by default, swappable. |
| src/classify/processor.js | Batch processing of unclassified notes. |
| src/classify/summarizer.js | AI summarization of unsummarized notes. |
| src/embeddings/embed.js | Local embeddings via HuggingFace (Xenova/all-MiniLM-L6-v2). |
| src/embeddings/search.js | Hybrid search combining FTS5 + cosine similarity. |
| src/auth.js | Dashboard auth (bcrypt + session cookies). |
| src/auth-oauth.js | OAuth provider via better-auth for remote MCP access. |
| src/middleware/api-key.js | API key validation middleware. |
| src/capture/ | Capture modules: youtube.js, web.js, terminal.js, x-bookmarks.js. |
| src/vault/indexer.js | Obsidian vault scanner and incremental indexer. |
| src/vault/parser.js | Vault note frontmatter parser. |
| src/safety/review.js | Destructive action review with multi-model consensus. |
| src/promotion/promoter.js | Knowledge promotion from sources to structured notes. |
| src/synthesis/weekly-review.js | Weekly cross-source synthesis generator. |
## Integration Patterns
### Claude Code (local, stdio)
Register with `node bin/kb.js register`. Uses stdio MCP transport. All 26 tools available.
### Claude.ai (remote, HTTP MCP)
Connect via remote MCP at `https://your-domain.com/mcp`. Authenticates with API key or OAuth. Admin-only tools are filtered out.
### ChatGPT (Custom GPT Actions)
Import OpenAPI spec from `https://your-domain.com/openapi.json`. Authenticate with X-API-Key header. REST API at `/api/v1/`.
### Gemini / Codex (HTTP API)
Use the REST API at `/api/v1/` with `X-API-Key` header. Endpoints: `/search`, `/search/smart`, `/context`, `/documents`, `/documents/:id`, `/ingest`, `/capture/session`, `/capture/fix`, `/capture/web`.
### Ollama / Local Models
Replace the Claude CLI classifier in `src/classify/classifier.js` with an Ollama HTTP call. See Recipe 1 in https://github.com/uttambharadwaj/kb-graph/blob/main/EXTENDING.md.
## Environment Variables
| Variable | Default | Purpose |
|----------|---------|---------|
| KB_PASSWORD | -- | Dashboard password (required on first run) |
| KB_HOST | 127.0.0.1 | HTTP bind host; remote binds require an explicit opt-in and a TLS reverse proxy |
| KB_PORT | 3838 | HTTP server port |
| OBSIDIAN_VAULT_PATH | -- | Obsidian vault path for indexing and writes |
| KB_API_KEY_CLAUDE | -- | API key for Claude remote access |
| KB_API_KEY_OPENAI | -- | API key for OpenAI/ChatGPT access |
| KB_API_KEY_GEMINI | -- | API key for Gemini access |
| BETTER_AUTH_SECRET | -- | OAuth token signing secret |
| BETTER_AUTH_URL | https://brain.yourdomain.com | OAuth issuer base URL |
| CLASSIFY_MODEL | claude-haiku-4-5-20251001 | Model for AI classification |
| CLAUDE_PATH | claude | Path to Claude CLI binary |
## Files to Read for Full Context
- https://github.com/uttambharadwaj/kb-graph/blob/main/CODEMAP.md -- Full architecture map with file purposes, exports, and data flows
- https://github.com/uttambharadwaj/kb-graph/blob/main/EXTENDING.md -- Deep customization guide with patterns, recipes, and the intelligence pipeline
- openapi.json -- OpenAPI 3.1 spec for the REST API
- https://github.com/uttambharadwaj/kb-graph/blob/main/kb-server.service.example -- source-install systemd service example
- package.json -- Dependencies and entry points
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

