second-brain-mcp
Self-maintaining knowledge vault: figure-level search, auto-wikilinks, and sleep-based memory compression.
Documentation
second-brain MCP Server
A self-maintaining personal knowledge base for AI agents β a plain-Markdown vault, powered by MCP.
π English Β· ηΉι«δΈζ
A local knowledge base your AI agent can read, write, and maintain on its own. Save a paper or note with one command β second-brain converts it to Markdown, OCRs every figure, embeds it for semantic search, and auto-links it to related notes. Notes you stop reading compress themselves over time, so recall stays cheap as the vault grows.
Everything is plain Markdown β sync via Google Drive / iCloud / git, switch agents anytime, zero lock-in.
Highlights
- One command saves anything β
save_article(url_or_pdf)fetches, converts to Markdown, OCRs figures (Claude Vision), embeds, and auto-links. - Figure-level search β
search_figures("UMAP melanocyte")returns the exact panel across your whole library. - Self-organizing β new notes auto-link to related ones; frequently-read notes extract reusable rules.
- Memory that forgets like a brain β Ebbinghaus ranking; stale notes auto-compress (60β90% fewer tokens).
- Session continuity β
get_context()reloads goals + top notes + rules at the start of every session. - Pluggable backend β DuckDB (default, offline) or Postgres + pgvector (central, multi-machine). Self-hosted embeddings optional; BM25 fallback when offline.
Quick Start (Claude Code)
pip install mcp-second-brain
playwright install chromium
claude mcp add --scope user second-brain \
--env SECOND_BRAIN_PATH=~/second-brain \
-- python -m mcp_second_brain
The vault directory and templates are created on first run. Then tell your agent init_vault to verify.
β οΈ PyPI currently lags the source tree. For the newest build β plus Claude Desktop, Windows, and multi-machine / central-server setups β see NEW_MACHINE_SETUP.md.
Core Tools
| Tool | What it does |
|---|---|
get_context | Session start β goals + top-ranked notes + auto-rules |
save_article | URL / PDF β Markdown + figures + embeddings |
search_notes / search_figures | Hybrid BM25 + semantic search (note text / figure content) |
new_note / update_note / append_to_note | Create & edit notes (auto-filed, auto-indexed, auto-linked) |
vault_sleep | Compress old, low-activity notes |
get_agent_instructions | Serve the full filing SOP (AGENTS.md) to remote agents |
Full tool reference (30+ tools) lives in AGENTS.md.
How It Works
Any source (paper Β· PDF Β· web Β· note)
β save_article Β· new_note
βΌ
Markdown vault βββΊ index (DuckDB, or Postgres + pgvector)
00-inbox/ β’ BM25 + semantic search
10-projects/ β’ figure OCR + vision descriptions
20-areas/ β’ auto-wikilinks between related notes
30-resources/ β’ Ebbinghaus ranking β weekly auto-compression
decisions/ memory/
β
βΌ
Your AI agent queries it β search_notes Β· search_figures Β· get_context
The vault is the source of truth; the index is rebuildable anytime (sync_index). Filing conventions live in one operating manual β AGENTS.md β served to any agent via get_agent_instructions(), so every agent files things the same way without being re-taught.
Vault Structure
vault/
βββ 00-inbox/ Unprocessed captures
βββ 10-projects/ Active projects
βββ 20-areas/ Ongoing research / coding domains
βββ 30-resources/ Papers & articles (save_article writes here)
βββ 40-archive/ Auto-compressed originals
βββ decisions/ Architecture Decision Records
βββ memory/ goals.md Β· rules.md (injected every session)
βββ templates/ Note templates
Documentation
- AGENTS.md β filing SOP, naming conventions, full tool reference (single source of truth)
- NEW_MACHINE_SETUP.md β source install, self-hosting, multi-machine central server, API keys
- CONTEXT.md β domain model / ubiquitous language
Design Notes
Inspired by biological memory: the Ebbinghaus forgetting curve (access_count / ln(age_days)) for ranking, and sleep-dependent consolidation (weekly LLM compression of low-access notes). Built with MarkItDown Β· DuckDB Β· pgvector Β· FastMCP Β· Playwright Β· Claude API.
License
MIT Β© 2026 Chan Chi Ru. See LICENSE.