Persistent graph-structured memory for LLMs in TriliumNext Notes β readable and editable by humans.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Give Claude a memory that survives the session.
A persistent, graph-structured second brain for Claude and any MCP client β built on TriliumNext Notes, served over the Model Context Protocol.
brainllm site Β· How it works Β· Use cases Β· Docs
LLMs forget. Every session starts from zero: who you are, what you're working on, what was decided yesterday, what went wrong last week. BrainLLM fixes that.
BrainLLM is an MCP server that gives an LLM a real, persistent memory β stored in TriliumNext Notes, a mature open-source knowledge base you self-host and own. The model opens each session by loading who you are and what's live, writes durable facts the moment they surface, wires knowledge together as a typed graph, and closes each session with a log, a diary entry, and a database backup. The next session picks up exactly where the last one ended.
It's a single Bun/TypeScript service with two dependencies (the MCP SDK and Zod), speaking to Trilium exclusively through its public ETAPI. Your memory lives in your Trilium instance β inspectable, editable, and portable, never locked inside a vendor's black box.
Anyone running an LLM as a long-running collaborator, not a one-shot Q&A tool β across coding, research, personal knowledge management, or day-to-day operational tracking β who wants that collaborator to actually remember: who you are, what's in flight, what was decided, without you re-explaining it every session. If you're comfortable self-hosting one small service and a Trilium instance, BrainLLM turns "the model forgot everything again" into a solved problem. It works with any MCP-capable client (Claude Desktop, Claude Code, or anything else speaking MCP), not just one product.
BrainLLM began in February 2026 as a personal experiment: could an LLM operate a real, self-hosted second brain reliably enough to be trusted as its own memory β orienting, writing, connecting, and closing sessions without a human doing the filing? Through sustained daily, production use the answer held. The design has settled, the failure modes have been found and fixed, and the project has graduated from experiment to something efficient and stable enough to share β so it's now open source. It still runs the author's own sessions every day; what you're reading is the same code, not a demo. It also still carries the shape of one person's daily use β see Adapting to your environment for exactly what that means and what to change.
The model supplies content. The server owns form.
Placement, naming, labels, deduplication, relation bookkeeping, lifecycle aging, archival, date stamping, HTML sanitization, backups β and structure itself β are all deterministic server policy, never delegated to the LLM. The model never chooses a parent note, never sets a label, never checks for duplicates, never stamps a date. That division is what makes the memory reliable: every guarantee is enforced at the tool layer, not requested via prompt.
template() and held on write: a new thread requires its goal, thread/diary/session entries open with an identification line (which LLM, which environment, which session type), threads carry exactly one Resolution (owned by resolve()), duplicate section headings are detected, and Last updated stamps are server-maintained.graph() renders the whole relation graph (or any note's neighborhood) as a Mermaid flowchart, maintained as a native Trilium note.day() serves the previous session, its change log, everything touched since, and the month's deliverables in a single call.At bootstrap, BrainLLM builds a five-area tree in Trilium. Every note the tools create is typed, labeled, dated, and placed by server policy:
| Note class | Kinds | Behavior |
|---|---|---|
| Singletons | biography, goals, preferences, responsibilities, protocols, selfcorrection (+ each domain's Sources note) | Exactly one maintained note; edited in place; hold current-state truth |
| Dated records | diary, session, log | One per calendar day; every write lands as a timestamped addendum block β chronology is the point |
| Collections | thread, user, information, domain | Titled notes, deduplicated by normalized title within their scope |
A session follows an enforced protocol: start() orients (who you are, live threads, what changed since last time) β the model works, writing durable facts as they surface β session() β addendum() β maintain() β remarks() β diary() β close() commits the log, regenerates the daily change log, and triggers a DB backup. The pre-close gate is enforced in code: close() refuses until every step actually ran, in order β narrating "I did the steps" doesn't count, only tool calls do. The gate is durable, written to the session note rather than held in memory, so it survives a restart mid-session and behaves the same on stdio and HTTP.
Orientation is deliberately cheap. start() returns your singletons as section headings β enough for the model to know what the brain holds β and it pulls the one section that matters. Serving the entire self-model on every session meant a one-line question cost the same as a day's work; start(depth="full") is still there for the sessions that genuinely need it.
Knowledge is a typed graph: a closed vocabulary of 16 relations (extends, contradicts, supports, partOf, supersedes, corrects, β¦), wired by connect() or at creation, traversed by explore() (links / backlinks / neighborhood / shortest path), rendered by graph(), and audited by maintain(deep), which heals duplicate edges and flags what a note application would never think to look for: orphaned notes, stale content, duplicate titles, structural drift inside a note, bodies past the read ceiling, stubs that were labelled and never written, titles carrying a date (which defeats dedup-by-title), threads heavy enough to want consolidating, Sources notes whose verification table was never filled in, and bodies carrying doubly-escaped markup. Most of it is computed from note properties server-side rather than by reading bodies, so the report is complete rather than truncated. Findings can be acknowledged (maintain(ack=[β¦])) so a flag you have judged correct goes quiet until that note's content actually changes β a warning that reappears every run and is correctly ignored every run trains you to skim the list.
Or skip this step. Set TRILIUM_PASSWORD instead of TRILIUM_ETAPI_TOKEN and BrainLLM mints a token itself on first start, caching it beside brainllm.json so restarts reuse it rather than creating a new one each time. This is the easiest path for a container deploy, where there's no terminal to run a setup command in.
To do it explicitly instead, either let init mint one:
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/brainllm)<a href="https://allmcps.com/mcp/brainllm"><img src="https://allmcps.com/api/badge/brainllm?style=directory" alt="Brainllm on AllMCPs" /></a>