brainlayer
Persistent memory MCP for AI agents — SQLite, knowledge graph, 13-tool Python MCP + 17-tool BrainBar surface with ToolAnnotations
Install / Use
claude mcp add EtanHey -- npx -y github:EtanHey/brainlayerIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
AI & Machine LearningSupported Platforms
Our assessment of brainlayer
brainlayer scores 84/100 on our quality scale, 613th of 956 AI & Machine Learning skills we index.
Its MCP Server is 22 KB long, well organised into 19 sections with 12 code examples: a thorough specification that gives an agent plenty to work with.
It has 10 GitHub stars, so there is little community track record yet; judge it on its content.
Maintenance, license and trust
- The repository was last updated today, so brainlayer is actively maintained.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 97/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands.
Automated pattern scan on 2026-11-27. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
brainlayer compared with similar skills
All 4 of these similar skills score higher than brainlayer; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| brainlayer (this skill)by EtanHey | 84 | 10 | today | MCP Server |
| claude-memby thedotmack | 100 | 120.2k | today | CLAUDE.md |
| Agent-Reachby Panniantong | 100 | 115.4k | 3d ago | CLAUDE.md |
| archifyby tt-a1i | 100 | 101.0k | today | CLAUDE.md |
| Understand-Anythingby Egonex-AI | 100 | 94.7k | 3d ago | CLAUDE.md |
Frequently asked questions
- How do I install brainlayer?
- Run
claude mcp add EtanHey -- npx -y github:EtanHey/brainlayer. The install tabs above show the steps for each supported agent. - Which AI agents does brainlayer work with?
- It is written for Claude Code and Claude Desktop, as a MCP Server file. Other agents that read the same format can often use it too.
- Is brainlayer safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. It is Apache-2.0-licensed and scores 97/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is brainlayer still maintained?
- The repository was last updated today, so brainlayer is actively maintained.
Skill content
View source on GitHubBrainLayer
Your AI has amnesia. BrainLayer fixes that.
Every architecture decision, every debugging session, every preference you've expressed — gone between sessions. You repeat yourself constantly. Your agents rediscover bugs they already fixed, and re-make choices the team already reasoned through.
BrainLayer gives any MCP-compatible AI agent persistent memory across conversations — and gives a whole fleet of agents a shared organizational memory: what one agent learns (a fix, a decision, what eroded and why) becomes experience the others inherit before they repeat the mistake. One SQLite file. No cloud. No Docker. Just pip install.
"What approach did I use for auth last month?" → brain_search
"Remember this decision for later" → brain_store
"What was I working on yesterday?" → brain_recall
"Ingest this meeting transcript" → brain_digest
"What do we know about this person?" → brain_get_person
Quick Start
pip install brainlayer
MCP examples require the Homebrew BrainLayer bridge. On Intel, replace
/opt/homebrew/opt/brainlayer with /usr/local/opt/brainlayer.
Add to your MCP config (~/.claude.json for Claude Code):
{
"mcpServers": {
"brainlayer": {
"command": "/opt/homebrew/opt/brainlayer/bin/brainlayer-mcp-stdio-bridge"
}
}
}
That's it. Your agent now remembers everything. BrainBar must be running and
owning /tmp/brainbar.sock; brainlayer-mcp-stdio-bridge ships with the package,
reconnects if BrainBar restarts, and uses an absolute path. Raw
socat wiring, {"command": "socat", "args": ["STDIO", "UNIX-CONNECT:/tmp/brainbar.sock"]}
exits on BrainBar restart and leaves persistent clients disconnected. Use brainlayer setup --migrate-mcp
to back up and upgrade owned legacy configs.
See docs/mcp-config.md.
Cursor (MCP settings):
{
"mcpServers": {
"brainlayer": {
"command": "/opt/homebrew/opt/brainlayer/bin/brainlayer-mcp-stdio-bridge"
}
}
}
Zed (settings.json):
{
"context_servers": {
"brainlayer": {
"command": { "path": "/opt/homebrew/opt/brainlayer/bin/brainlayer-mcp-stdio-bridge", "args": [] }
}
}
}
VS Code (.vscode/mcp.json):
{
"servers": {
"brainlayer": {
"command": "/opt/homebrew/opt/brainlayer/bin/brainlayer-mcp-stdio-bridge"
}
}
}
</details>
MCP Tools (16)
The agent-facing MCP server is BrainBar on /tmp/brainbar.sock. It defines 16 tools, and
every definition carries ToolAnnotations
so agents know which calls are safe to run without confirmation.
Sessions boot into a core palette of 5. By default tools/list returns brain_search,
brain_store, brain_recall, brain_expand, and expand_palette — with short descriptions, to
keep the boot payload small. Call expand_palette (or set BRAINLAYER_MCP_PROFILE=full on the
server) to get all 16 with their full descriptions. Calling a gated tool before expanding returns
an error that tells you to expand.
| Tool | Type | Core | What it does |
|------|------|:----:|-------------|
| brain_search | read | ● | Semantic + keyword hybrid search across all memories. Lifecycle-aware, MMR-deduped. |
| brain_store | write | ● | Persist decisions, corrections, bug causes, learnings. Auto-importance scoring. |
| brain_recall | read | ● | Session-level context — current work, recent sessions, one session's detail, or stats. |
| brain_expand | read | ● | Open one search result in full, with the chunks around it. |
| brain_entity | read | | Look up a person, project, company, or tool in the knowledge graph and its relations. |
| brain_get_person | read | | One person's profile, relations, and linked memories in a single call. |
| brain_tags | read | | List tags in use with counts; filter by substring. |
| brain_digest | write | | Digest a large raw block (transcript, doc, article) into a searchable chunk and connect its entities into the KG. |
| brain_update | write | | Change an existing chunk's importance or tags. Does not edit content. |
| brain_subscribe | write | | Subscribe an agent to live notifications for given tags. |
| brain_unsubscribe | write | | Remove some or all of an agent's tag subscriptions. |
| brain_ack | write | | Acknowledge that an agent processed messages up to a chunk rowid. |
| brain_backup_vacuum_into | write | | Write a SQLite backup snapshot (VACUUM INTO) to a target path. |
| brain_maintenance_rebuild_trigram | write | | Operator-triggered rebuild of the trigram FTS table in lock-aware batches. |
| brain_supersede | destructive | | Replace an old memory with a newer one and hide the old. Safety gate on personal data. |
| brain_archive | destructive | | Hide a chunk from default search, recoverably. |
brain_store outcomes
brain_store answers with an explicit outcome word, so an agent never has to guess whether a write
landed (#725):
STORED,DUPLICATE,MERGED,DEFERRED— all four are success. Do not re-store. (DEFERREDmeans the write is queued and will be persisted.)REJECTED,ERROR— nothing was stored. These return nostatusfield and nochunk_id;REJECTEDmeans the request itself cannot succeed as sent,ERRORis worth one retry.
Once a row is committed, the handler can no longer answer REJECTED or ERROR — a durable write
is never reported as "nothing was stored".
Tool descriptions on the wire
The rules for agents using BrainLayer live in the tool descriptions, so tools/list never drops a
description to fit a transport limit (#727). When
a response would exceed the frame budget, compaction runs as a ladder: first annotations and
inputSchema prose are dropped, and only if that still does not fit are descriptions shortened to
the largest budget that does — each marked …[truncated], with a
result._meta["brainlayer/descriptionsTruncated"] notice naming every affected tool. Descriptions
are never removed outright; if even the floor does not fit, the response ships over the limit with
its contract intact and logs why. The shipped palettes are covered by a test that fails if a newly
added tool ever pushes them into truncation.
Legacy brainlayer_* names (brainlayer_search, brainlayer_store, brainlayer_recall, and 11
more) are still accepted by the Python library handlers under src/brainlayer/mcp/. They are not
served by BrainBar, which is the agent transport — new wiring should use the brain_* names.
Architecture
graph LR
A["Claude Code / Cursor / Zed"] -->|MCP| B["BrainLayer<br/>16 tools"]
B --> C["Hybrid Search<br/>vector + FTS5"]
C --> D["SQLite + sqlite-vec<br/>single .db file"]
B --> KG["Knowledge Graph<br/>entities + relations"]
KG --> D
E["JSONL conversations"] --> W["Real-time Watcher<br/>≥30s poll interval"]
W --> D
I["BrainBar UI<br/>NSStatusItem + NSPopover"] -->|UDS /tmp/brainbar.sock| BB["BrainBarDaemon<br/>MCP + brain bus"]
BB -->|MCP socket protocol| B
Memory indexing, search, and the local knowledge graph run on-device. Axiom telemetry and Drive backups remain optional network integrations.
| Layer | Implementation |
|-------|---------------|
| Storage | SQLite + sqlite-vec, WAL mode, single .db file |
| Embeddings | bge-large-en-v1.5 (1024 dims, CPU/MPS) |
| Search | Vector similarity + FTS5, merged with Reciprocal Rank Fusion |
| Watcher | Real-time JSONL indexing (≥30s poll interval), 4-layer content filters, offset-persistent |
| Knowledge Graph | Entities, relations, co-occurrence extraction, person lookup |
Why BrainLayer?
| | BrainLayer | Mem0 | Zep/Graphiti | Letta |
|---|:---:|:---:|:---:|:---:|
| MCP tools | 16 | 1 | 1 | 0 |
| Local-first | SQLite | Cloud-first | Cloud-only | Docker+PG |
| Zero infra | pip install | API key | API key | Docker |
| Real-time indexing | ≥30s poll interval | No | No | No |
| Knowledge lifecycle | Supersede/archive | Auto-dedup | No | No |
| Open source | Apache 2.0 | Apache 2.0 | Source-available | Apache 2.0 |
BrainBar — macOS Companion
Optional native Swift menu bar companion split into two launchd-managed processes:
flowchart LR
UI["BrainBar<br/>LSUIElement UI"] -->|"watch-brain-bus + commands<br/>/tmp/brainbar.sock"| D["BrainBarDaemon<br/>headless MCP server"]
D -->|"single writer queue + reads"| DB["SQLite WAL<br/>~/.local/share/brainlayer/brainlayer.db"]
D -->|"helper subprocess IPC"| H["Hybrid search helper"]
BrainBarDaemon owns the MCP server, /tmp/brainbar.sock, the single-writer path, the watch-brain-bus stream, and helper subprocess lifecycle. BrainBar owns only the NSStatusItem, transient NSPopover, SwiftUI surfaces, hotkey routing, and a reconnecting socket subscriber. Killing the UI does not stop the daemon socket.
bash brain-bar/build-app.sh # Build, sign, install LaunchAgent
The build script builds both BrainBar and BrainBarDaemon, embeds both binaries in BrainBar.app, then installs com.brainlayer.brainbar.plist and com.brainlayer.brainbar-daemon.plist with ProcessType=Interactive. It refuses non-canonical checkouts and dirty trees by default (#265) and stamps each bundle with GitCommit, GitDescribe, and BuildTimeUTC in Info.plist (#264) so a stale install is diagnosable in seconds.
Writer Arbitration
Background producers run with BRAINLAYER_ARBITRATED=1 and append writes to ~/.brainlayer/queue/; com.brainlayer.drain.plist drains that queue every 500ms as the single writer. Trigram FTS maintenance is explicit via brainlayer repair-fts and the weekly com.brainlayer.repair-fts.plist, not synchronous startup work. See docs/arbitration.md.
Recent Hardening (2026-04-15 → 2026-05-17)
Historical two-week stability sprint. Every line below traces to a merged PR. Enrichment work listed here is retired; history: CHANGELOG.
Search recall & dedup
- FTS recall hardened across Python, Swift BrainBar, and the watcher pipeline (#263).
- Lexical defense dictionary exports for fragile-token recovery (#262).
- MMR post-retrieval dedup on
brain_search(#242). - Legacy unique
content_hashindex dropped — was blocking re-enrichment writes (#245). - Swift
brain_storequeue fallback so BrainBar can persist when the daemon is mid-restart (#261).
BrainBar reliability & UX
- MenuBarExtra(.window) rewrite with live-state sparklines and full-width hero (#248).
Truncated for display — read the full file on GitHub.
Related Skills
claude-mem
120.2kPersistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
Agent-Reach
115.4kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
archify
101.0kTurn any idea, plan, or codebase into an interactive diagram or one-page answer: 10 diagram types, Architecture Diagnosis, Story video and PR walkthroughs. An Agent Skill for Claude Code, Codex, Cursor and more.
Understand-Anything
94.7kGraphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
