SecondBrain
The SecondBrain MCP server provides a set of tools that let AI agents interact with a shared, local-first Markdown memory vault, enabling persistent context across tasks. With it, you can:
Search and retrieve: Use
memory_searchfor hybrid keyword and semantic search, andmemory_getto read specific notes or history entries (e.g.,H0372).Explore relationships: Traverse ontology links via
memory_related(up to two hops), optionally filterable by relation type.Capture and update: Append durable memories with
memory_capture(categories: user, decision, project, knowledge, inbox) and add dated sections to existing notes withmemory_update.Monitor and maintain: Check index and harvester health with
memory_status, view recent session logs viamemory_recent, and rebuild the search index usingmemory_rebuild(with optional embedding regeneration).Ensure quality: Audit the vault for issues like staleness or duplicates using
memory_audit, and evaluate retrieval performance (recall@k, MRR) withmemory_eval.
Click on "Install 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., "@SecondBrainsearch 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: mem-persistence
5-minute install
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
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.
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 ten 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 |
| 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.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, redacts secrets, and builds a searchable, summary-only catalog — never full transcripts.
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_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;
# only Unicode-range regex boundaries in *.py 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.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityCmaintenanceA self-hosted MCP server that provides AI assistants with a shared, persistent SQLite-backed memory for storing and retrieving project context, decisions, and discoveries. It enables cross-session continuity and team-wide knowledge sharing to keep AI coding tools aligned and informed.Last updated3MIT
- Alicense-qualityBmaintenancePersistent memory MCP server that stores and retrieves memories in Markdown files, enabling shared context across multiple AI agents with hybrid search and deduplication.Last updatedMIT
- AlicenseAqualityAmaintenanceA 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.Last updated16549MIT
- AlicenseBqualityBmaintenanceLocal-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.Last updated10271MIT
Related MCP Connectors
User-owned memory for AI agents, Copilot, Claude, IDEs, CLIs, and chat apps over remote MCP.
Person-owned, portable AI memory as a remote MCP server, readable and writable by any MCP client.
Cloud-hosted MCP server for durable AI memory
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/no-carve-only-pizza/secondbrain-oss'
If you have feedback or need assistance with the MCP directory API, please join our Discord server