SecondBrain
You can use this server to search, read, capture, update, review, and maintain a shared local SecondBrain memory vault via MCP tools.
Search notes and history with hybrid keyword/semantic retrieval, filters, and context budget (
memory_search).Read a note or historical catalog entry (
memory_get).Traverse ontology relations around a note (
memory_related).Capture durable memory and append dated sections to existing notes (
memory_capture,memory_update).Manage an isolated candidate review queue: create, list, get, approve, reject, expire (
memory_candidate_*).View recent per-tool session logs and check index/harvester status (
memory_recent,memory_status).Rebuild the local index, audit memory quality, and run retrieval evaluation (
memory_rebuild,memory_audit,memory_eval).
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., "@SecondBrain search my memory for the decision on API auth"
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.
SecondBrain
One shared, local-first memory for every AI coding agent you use.
Codex forgets what Claude Code learned. Cursor starts from zero on a project Antigravity has worked on for weeks. Each tool keeps its own history in its own private store, so you re-explain the same context over and over.
SecondBrain fixes that. Your memory is a plain Markdown vault plus a tiny MCP server. Every MCP-capable agent reads and writes the same notes, so context follows you across tools and machines.
Codex ─┐
Claude Code ─┤
Cursor ─┼──▶ SecondBrain MCP ──▶ ~/SecondBrain (Markdown + local index)
Antigravity ─┘ (memory_search, AI_CONTEXT/ 10_Projects/ 30_Knowledge/
your agent ─┘ memory_capture, ...) 40_Decisions/ 50_Conversations/ ...Local-first. Human-readable Markdown on your disk. No account required.
Zero heavy deps. Core tools use only the Python standard library. Semantic search is optional and runs locally via Ollama.
Shared by protocol. Any agent that speaks MCP joins automatically.
Governed. A curated ontology plus
auditandevalcommands keep a long-lived memory from rotting.
Jump to: Why · Install · Tools · How it works · Why it's worth a star · Privacy · Layout
Why this exists
AI coding agents are getting genuinely useful, but their memory is siloed:
Switch from one agent to another and you lose all accumulated context.
The same preferences, decisions, and project state get re-typed constantly.
There is no single place you own and can read, edit, and back up.
SecondBrain makes memory a file format + a protocol instead of a feature locked inside one app. See docs/comparison.md for how this differs from hosted memory services like Mem0 and Zep.
Related MCP server: Jarvis Markdown MCP
5-minute install
Latest GitHub version / another Mac: follow the macOS install and upgrade guide (한국어). It installs v0.2.0 from source; PyPI/npm may still carry an older release.
1. Install
pip install secondbrain-memory(Optional) local semantic search:
# https://ollama.com — then:
ollama pull bge-m3If you skip Ollama, set retrieval.semantic.enabled: false in your config and
SecondBrain runs keyword-only.
2. Create your vault
secondbrain init ~/SecondBrain
export SECONDBRAIN_CONFIG="$HOME/.config/secondbrain/secondbrain.yaml"
secondbrain indexThis scaffolds the vault (with example notes you can delete) and writes a config
to ~/.config/secondbrain/secondbrain.yaml.
3. Connect your agents
# macOS / Linux
python3 install/install_unix.py
# Windows (PowerShell)
powershell -ExecutionPolicy Bypass -File install\install_windows.ps1On macOS the harvester auto-schedules via a LaunchAgent; on Linux it uses a
systemd --user timer if systemctl is available. Both are optional and
controlled by automatic_capture.enabled in your config.
Run the installer from a clone of this repository, using the same Python environment that holds the package. The explicit config above prevents the repository’s demo vault from overriding your personal vault.
The installer registers the MCP server with each agent in your config and drops a shared-memory rule into each agent's global instructions. Restart your AI apps.
Prefer to wire one agent by hand? Point any MCP client at:
{
"mcpServers": {
"secondbrain": {
"command": "python3",
"args": ["-m", "secondbrain.mcp_server"],
"env": { "SECONDBRAIN_CONFIG": "/absolute/path/to/secondbrain.yaml" }
}
}
}Or launch it with npx secondbrain-memory (the npm package is a thin launcher
for the Python server).
4. Verify
secondbrain health
secondbrain search "hybrid search" --top 3What your agents can do
The MCP server exposes sixteen tools:
Tool | Purpose |
| Hybrid keyword + semantic search over notes and history |
| Read a note or a historical catalog entry |
| Traverse 1-2 ontology hops around a note |
| Save durable user/decision/project/knowledge/inbox memory |
| Append a dated section to an existing note |
| Add an idempotent item to the isolated review queue |
| List candidates by status, level, scope, or source |
| Read one candidate and its provenance |
| Preview or hash-lock an approval into existing Markdown |
| Reject a candidate without changing Markdown |
| Expire a candidate without changing Markdown |
| Recent per-tool session logs |
| Index and harvester status |
| Rebuild the index |
| Flag stale/duplicate/conflicting/unresolved memory |
| Report retrieval recall@k and MRR |
The same actions are available on the CLI: secondbrain search|index|audit|eval| harvest|backup|health|config.
How it works
Vault (source of truth). Markdown notes under a PARA-style layout. Notes carry lightweight frontmatter (
type,status, relations).Index (derived, disposable). SQLite FTS5 for keywords + optional local embeddings, fused with reciprocal rank fusion. Delete it any time; rebuild with
secondbrain index.Memory lifecycle. Optional L0-L3/status/scope metadata enables explicit filtering without changing unfiltered ranking. External memories enter a disposable SQLite review queue and require preview plus a target hash before they can append provenance-marked canonical Markdown. See docs/memory-lifecycle.md.
Ontology. A small relation vocabulary connects canonical notes; search results get a light boost from directly linked notes.
Harvester. Optionally scans your local agent histories, including configured Codex account homes, redacts secrets, and builds a searchable, summary-only catalog — never full transcripts. Large Codex logs are streamed and overlapping refreshes are locked out.
Runtime health. Checks actual scheduler registration and index/harvest freshness when automatic capture is enabled; an old success receipt is insufficient.
Config. One
secondbrain.yamldrives everything: pointvault_rootanywhere and the whole toolchain follows.
Why it is worth a star — three differentiators
Cross-agent by default. Memory lives in files + MCP, so Codex, Claude Code, Cursor, and Antigravity share one brain. Hosted memory services center on an SDK/backend your app calls; here, sharing is the starting point.
Local-first and inspectable. The whole memory is Markdown you can
git diff, grep, and edit. Embeddings run on your machine. No service to run, no data leaving your laptop.Governed, measurable memory. A curated ontology plus
audit(health) andeval(recall@k / MRR) treat memory quality as something you can verify — not just an ever-growing store.
Full detail: docs/comparison.md.
Screenshots & demo
Scripts to reproduce the README media live in docs/screenshots.md.
Privacy & safety
Ordinary personal info is stored only if you opt in (
privacy.ordinary_personal_information: allowed).The MCP server and harvester refuse to store values that look like passwords, API keys, tokens, or private keys.
Backups are AES-256 encrypted (
secondbrain backup).The MCP server refuses to read or write outside your configured vault.
Repository layout
secondbrain-oss/
├── secondbrain.yaml # config (points at ./vault by default)
├── src/secondbrain/ # config-driven Python package
│ ├── config.py # the one place paths are resolved
│ ├── memory_index.py # FTS5 + embeddings + ontology
│ ├── memory_candidates.py # isolated SQLite review queue
│ ├── memory_search.py memory_audit.py retrieval_eval.py
│ ├── harvest.py catalog.py backup.py health_check.py
│ ├── mcp_server.py # stdio MCP server (secondbrain-mcp)
│ ├── cli.py # the `secondbrain` command
│ └── template_vault/ # packaged copy used by `secondbrain init`
├── vault/ # the reference/demo vault (same as template)
├── install/ # install_unix.py (macOS + Linux), install_windows.ps1, adapters
├── bin/secondbrain-mcp.js # npx launcher
└── docs/ # comparison, screenshot scriptContributing
Issues and PRs welcome. Keep the core dependency-free, keep personal data out of
the repo, and run secondbrain eval before changing retrieval.
License
MIT.
Maintainer self-check: no personal data leaked
Run through this before every publish or release. This repository is a template; it must contain zero real personal or private information.
Automated scan (portable, no non-ASCII literals in the command itself)
# 1. ASCII personal tokens and absolute home paths. Expect NO matches.
grep -rInE "your-name|/Users/[a-z]|C:\\\\Users\\\\" \
--exclude-dir=.git --exclude-dir=node_modules --exclude-dir='*.egg-info' . \
|| echo "clean: no personal tokens"
# 2. Any CJK / non-Latin text (catches leaked non-English personal data).
# Reports files with runs of Hangul/Han/Hiragana/Katakana. Review each hit;
# Unicode-range regexes, synthetic tests, and the Korean macOS guide are expected.
python3 - <<'PY'
import os, re
pat = re.compile(r"[\uac00-\ud7a3\u3040-\u30ff\u4e00-\u9fff]{2,}")
for dp, dn, fn in os.walk("."):
dn[:] = [d for d in dn if d not in {".git", "node_modules"} and not d.endswith(".egg-info")]
for f in fn:
p = os.path.join(dp, f)
try:
for i, line in enumerate(open(p, encoding="utf-8"), 1):
if pat.search(line):
print(f"{p}:{i}: {line.strip()[:100]}")
except Exception:
pass
PYReplace your-name with your actual name/handle when running this locally.
Manual checklist
Does any file contain a real name (mine or anyone else's)?
Does any file contain a real project, client, employer, or school name?
Any CVE numbers, vulnerability research, or security-target details?
Any absolute home paths (
/Users/<me>,C:\Users\<me>) or machine names?Any real emails, phone numbers, student/employee IDs, or birthdays?
Any API keys, tokens, passwords, cookies, or private keys (even fake-looking)?
Are all example notes clearly fictional (Widget Store, Homelab, etc.)?
Do config files point at generic paths (
./vault,~/SecondBrain)?Are
vault/50_Conversations,00_Inbox,60_Imports,90_Archiveempty except for templates/.gitkeep, and ignored by.gitignore?Do screenshots/GIFs show only the demo vault, no personal windows?
If any box is unchecked, do not publish until it is resolved.
Available Tools
16 toolsmemory_auditB
Audit canonical memory for stale active notes, duplicate aliases, identity conflicts, unresolved ontology links, open questions, and source provenance.
Inputs: write_report.
memory_candidate_approveA
Preview approval by default; apply only to an existing Markdown target with an explicit matching SHA-256.
Inputs: candidate_id (required), apply, target_path, review_reason, +1 more.
memory_candidate_createC
Create an idempotent review candidate without changing canonical Markdown.
Inputs: scope (required), content (required), confidence (required), source_ref (required), +12 more.
memory_candidate_expireC
Expire a candidate without changing canonical Markdown.
Inputs: candidate_id (required), review_reason.
memory_candidate_getC
Get one memory candidate by ID.
Inputs: candidate_id (required).
memory_candidate_listC
List the isolated candidate review queue; candidates never appear in memory_search.
Inputs: limit, scope, status, source_kind, +1 more.
memory_candidate_rejectC
Reject a candidate without changing canonical Markdown.
Inputs: candidate_id (required), review_reason.
memory_captureA
Append durable user, decision, project, knowledge, or inbox memory. Ordinary personal information is allowed; credentials are rejected.
Inputs: title (required), content (required), tags, category.
memory_evalB
Run the SecondBrain retrieval regression suite and report recall@k and mean reciprocal rank.
Inputs: top, write_report.
memory_getB
Read a SecondBrain note or retrieve a historical catalog entry such as H0372.
Inputs: reference (required), max_chars.
memory_rebuildB
Rebuild the local keyword and semantic index after substantial note changes.
Inputs: embeddings.
memory_recentC
Return recent per-tool session memory logs.
Inputs: top.
memory_searchB
Search the user's shared SecondBrain with hybrid keyword and local semantic retrieval before substantive tasks.
Inputs: query (required), top, scope, audience, +5 more.
memory_statusA
Check SecondBrain index and automatic harvester status.
Inputs: no named parameters.
memory_updateC
Safely append a dated section to an existing Markdown note in SecondBrain.
Inputs: path (required), content (required), heading.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 16 tools
Each tool targets a distinct action/resource: search vs. get vs. recent logs, and a clean memory_candidate_* sub-namespace (get/list/create/approve/reject/expire) that is explicitly isolated from canonical memory. The three write paths (capture, update, candidate_create) are clearly differentiated by descriptions. No two tools appear interchangeable.
All 16 tools use a uniform memory_ prefix in snake_case with a predictable verb_noun structure (memory_get, memory_search, memory_capture, memory_update). The memory_candidate_* lifecycle is a consistent nested naming sub-pattern rather than a deviation.
16 tools is at the upper edge of comfortable, driven by a full five-tool candidate-review lifecycle. For a knowledge base with retrieval, audit, eval, and index management, each tool earns its place, though the surface is slightly heavy.
The surface covers the full lifecycle: creation (capture/create), read (get/search/related/recent), update (update, approve), review governance (candidate list/approve/reject/expire), plus audit, eval, rebuild, and status. Append-only design intentionally omits canonical delete, so no meaningful dead ends remain.
Maintenance
Related MCP Connectors
One memory, every AI. A shared, user-owned markdown memory your AI clients read and write over MCP.
Hosted MCP memory for coding agents: persistent across sessions, editable markdown, team sharing.
An MCP memory server. One memory your agents share — across models, devices and apps.
Shared memory for your AI tools: tasks, notes and context every tool can read and write over MCP.
Related MCP Servers
- AlicenseAqualityCmaintenanceA self-hosted MCP server that gives AI agents shared, long-term memory over a git-backed folder of markdown, enabling persistent knowledge search, read, and write without a database.1628 npm20MIT
- AlicenseBqualityDmaintenanceLocal-first memory server for AI coding agents that stores work sessions, tasks, and durable memories in Markdown files, exposed through MCP tools for session management and memory retrieval.1011 npm1MIT
- AlicenseAqualityBmaintenanceMCP server for persistent, cross-session, local-first memory for AI agents, storing memories as Markdown files with SQLite indexing for hybrid search.24Apache 2.0
- FlicenseNot gradedqualityDmaintenanceA local-first MCP server that manages developer memory for coding agents, enabling shared project context, permissions, and audit trails across different agents.1-