Persistent memory and knowledge graph for AI agents
BrainLayer
Persistent memory and knowledge graph for AI agents — 9 MCP tools, real-time indexing hooks, and a native macOS daemon for always-on recall across every conversation.
224,000+ chunks indexed · 1,002 Python + 28 Swift tests · Real-time indexing hooks · 9 MCP tools · BrainBar daemon (209KB) · Zero cloud dependencies
Your AI agent forgets everything between sessions. Every architecture decision, every debugging session, every preference you've expressed — gone. You repeat yourself constantly.
BrainLayer fixes this. It's a local-first memory layer that gives any MCP-compatible AI agent the ability to remember, think, and recall across conversations. Includes BrainBar — a 209KB native macOS daemon that provides always-on memory access.
"What approach did I use for auth last month?" → brain_search
"Show me everything about this file's history" → brain_recall
"What was I working on yesterday?" → brain_recall
"Remember this decision for later" → brain_store
"Ingest this meeting transcript" → brain_digest
"What do we know about this person?" → brain_get_person
"Look up the Domica project entity" → brain_entity
Quick Start
pip install brainlayer
brainlayer init # Interactive setup wizard
brainlayer index # Index your Claude Code conversations
Then add to your editor's MCP config:
Claude Code (~/.claude.json):
{
"mcpServers": {
"brainlayer": {
"command": "brainlayer-mcp"
}
}
}
Other editors (Cursor, Zed, VS Code)
Cursor (MCP settings):
{
"mcpServers": {
"brainlayer": {
"command": "brainlayer-mcp"
}
}
}
Zed (settings.json):
{
"context_servers": {
"brainlayer": {
"command": { "path": "brainlayer-mcp" }
}
}
}
VS Code (.vscode/mcp.json):
{
"servers": {
"brainlayer": {
"command": "brainlayer-mcp"
}
}
}
That's it. Your agent now has persistent memory across every conversation.
Architecture
graph LR
A["Claude Code / Cursor / Zed"] -->|MCP| B["BrainLayer MCP Server9 tools"]
B --> C["Hybrid Searchsemantic + keyword (RRF)"]
C --> D["SQLite + sqlite-vecsingle .db file"]
B --> KG["Knowledge Graphentities + relations"]
KG --> D
E["Claude Code JSONLconversations"] --> F["Pipeline"]
F -->|extract → classify → chunk → embed| D
G["Local LLMOllama / MLX"] -->|enrich| D
H["Real-time Hooks"] -->|live per-message| D
I["BrainBarmacOS daemon"] -->|Unix socket MCP| B
Everything runs locally. No cloud accounts, no API keys, no Docker, no database servers.
| Component | Implementation |
|---|---|
| Storage | SQLite + sqlite-vec (single .db file, WAL mode) |
| Embeddings | bge-large-en-v1.5 via sentence-transformers (1024 dims, runs on CPU/MPS) |
| Search | Hybrid: vector similarity + FTS5 keyword, merged with Reciprocal Rank Fusion |
| Enrichment | Local LLM via Ollama or MLX — 10-field metadata per chunk |
| MCP Server | stdio-based, MCP SDK v1.26+, compatible with any MCP client |
| Clustering | Leiden + UMAP for brain graph visualization (optional) |
| BrainBar | Native macOS daemon (209KB Swift binary) — always-on MCP over Unix socket |
MCP Tools (9)
Core (4)
| Tool | Description |
|---|---|
brain_search |
Semantic search — unified search across query, file_path, chunk_id, filters. |
brain_store |
Persist memories — ideas, decisions, learnings, mistakes. Auto-type/auto-importance. |
brain_recall |
Proactive retrieval — current context, sessions, session summaries. |
brain_tags |
Browse and filter by tag — discover what's in memory without a search query. |
Knowledge Graph (5)
| Tool | Description |
|---|---|
brain_digest |
Ingest raw content — entity extraction, relations, sentiment, action items. |
brain_entity |
Look up entities in the knowledge graph — type, relations, evidence. |
brain_expand |
Expa |
Tools (6)
brain_searchUnified semantic and keyword search across query, file_path, chunk_id, and filters.brain_storePersist memories including ideas, decisions, learnings, and mistakes.brain_recallProactive retrieval of current context, sessions, and session summaries.brain_tagsBrowse and filter memory by tag.brain_digestIngest raw content for entity extraction, relations, sentiment, and action items.brain_entityLook up entities in the knowledge graph including type, relations, and evidence.Configuration
{"mcpServers": {"brainlayer": {"command": "brainlayer-mcp"}}}