second-brain
Indexes an Obsidian-style markdown vault locally with embeddings, exposing tools to semantically search notes, list indexed notes, fetch a specific note's content, and trigger reindexing so relevant vault context can be retrieved on demand.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
AI Second Brain
A private, local-first context system for Claude. Markdown notes (Obsidian-style vault) are chunked, embedded with a local Ollama model, and stored in PostgreSQL + pgvector. Claude retrieves relevant context through MCP instead of you re-explaining in every chat.
This is a working, real-time system: one long-lived BrainService owns a pooled DB
connection, cached query embeddings, a debounced embedded watcher, and an SSE event
stream. Notes you change on disk are searchable within ~0.3s without a manual reindex.
One-command setup
.\setup.ps1 # Windows: checks prerequisites, generates .env, installs deps,
# starts pgvector, pulls the model, indexes notes, tests
.\start.ps1 # serve on 127.0.0.1:8012 with the live watcher
.\doctor.ps1 # health check./setup.sh # macOS / Linux
./start.sh
./doctor.shSetup is safe to re-run and never overwrites your key. See TESTER_GUIDE.md for a guided walkthrough.
Related MCP server: pando
Architecture
markdown vault (Obsidian)
| watchdog, debounced 300ms, per-file
v
BrainService <----- MCP stdio (Claude Desktop)
| | \ <----- FastAPI HTTP :8012
| | \ /search /notes /health /events(SSE)
| | \
| | +-- query embedding LRU cache (256 keys, 5 min TTL)
| +-------- stat + content-hash gates (skip unchanged files)
v
Ollama (nomic-embed-text)
v
PostgreSQL + pgvector (HNSW cosine index, pooled connections)Efficiency design
Concern | How it's handled |
Change detection |
|
Same content, new timestamp | SHA-256 gate — metadata refreshed, no re-embedding |
Changed file | Only that file is re-chunked, embedded in one batch call, replaced |
Repeated queries | Embedding cached in an LRU (256 keys, 5-min TTL) — zero Ollama calls on hits |
Concurrent requests |
|
Cache invalidation | Query cache cleared automatically when any note is indexed/deleted |
Full rescans | Only at startup; the watcher calls |
Availability | Watcher runs in a daemon thread embedded in the service — no second process needed |
Quick start
python -m pip install -r requirements.txt
docker compose up -d # pgvector on localhost:5435
ollama pull nomic-embed-text
python -m second_brain.cli init-db # create schema, detect embedding dimension
python -m second_brain.cli index # initial reconciliation
python -m second_brain.cli search "what is lead-radar?"
python -m second_brain.cli status # watcher, counts, cache size, errors
# Real-time service (watcher starts automatically with the server)
python -m second_brain.cli serve # HTTP API + SSE on 127.0.0.1:8012
python -m second_brain.cli watch # watcher-only mode
python -m second_brain.cli mcp # MCP stdio (also starts watcher)Point SB_VAULT at your own vault. All processing stays local — no cloud API keys or
external embedding provider. The LOCAL_AI_API_KEY in .env is a random local token,
not a cloud credential.
HTTP API
Endpoint | Purpose |
| Status, watcher state, note/chunk counts, cache size, last error |
| Semantic search |
| Indexed note list |
| Force full reconciliation |
| Server-Sent Events — pushes an event the moment a note is indexed/deleted |
Example event:
data: {"version":3,"type":"index","path":"projects/new-note.md","status":"indexed","chunks":2}Claude Desktop configuration
{
"mcpServers": {
"second-brain": {
"command": "python",
"args": ["-m", "second_brain.cli", "mcp"],
"cwd": "C:\\path\\to\\your\\cloned\\ai-second-brain",
"env": {
"SB_VAULT": "C:\\path\\to\\your\\obsidian\\vault"
}
}
}
}Tools: search_notes, list_notes, get_note, reindex, status.
Note: if you run both the HTTP server and the MCP server at once, each starts its own watcher. This is safe — the stat/content-hash gates make them idempotent, so only one actually embeds a given change.
Authentication
The service binds to 127.0.0.1. For defence in depth, set LOCAL_AI_API_KEY to a
shared secret:
export LOCAL_AI_API_KEY="your-random-key"With the key set, /search, /notes, /reindex, and /events require
Authorization: Bearer <key>. /health stays open for monitoring. The companion
Local LLM Stack reads the same variable and forwards it automatically.
Without the key, the API runs open (local-dev mode) — fine for a single machine, not for anything reachable from another host.
Tests
python -m pytest -q # 18 tests, no DB/Ollama neededTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Notes and memory assistant: one Markdown vault that Claude, ChatGPT and any MCP client can share.
Persistent memory layer for AI tools. Save and recall notes across Claude and other MCP clients.
MCP-native notes and memory for ChatGPT, Claude, and other AI tools.
Search, read, and write your Apple Notes from ChatGPT/Claude via a local Mac agent + MCP relay.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides Claude with read, search, and write access to an Obsidian vault through MCP tools.-
- AlicenseNot gradedqualityBmaintenanceEnables Claude to search, read, write, and manage a local markdown vault through 8 tools, turning your notes into an AI-accessible knowledge base.3 npmAGPL 3.0
- AlicenseNot gradedqualityCmaintenanceEnables Claude to read, search, and analyze your entire knowledge vault locally via MCP tools like search, drafting, and linting.101 npm7MIT
- AlicenseAqualityCmaintenanceEnables semantic search and reading of Obsidian Markdown notes through read-only MCP tools, allowing Claude to retrieve relevant passages from a local vault.3MIT