brainMD
brain.md
A local-first second brain for you β and for your AI agents.

What you get
π Β Obsidian-compatible markdown | Wikilinks, embeds, callouts, math, mermaid, tasks, frontmatter, aliases. Open your existing Obsidian vault β it just works. |
β‘ Β Live editor + preview | CodeMirror 6 with cursor-anchored scroll sync, autosave, instant tooltips, command palette, quick switcher. |
π Β Semantic search built in | Per-vault LanceDB vector store. Notes are chunked, embedded and indexed on every save. No external service to set up. |
π€ Β Pluggable embedders | Default: |
π°οΈ Β MCP server (streamable HTTP) | 16 tools + 2 resources mounted on the same port. Claude Desktop, Claude Code, Cursor and any MCP-compliant agent can read, search, query and write your notes. |
π Β Per-folder agent permissions | Right-click a folder β set |
π Β Optional password auth | argon2id, bearer tokens, 24-hour TTL β gates both HTTP API and MCP. Off by default, on with one click. |
π Β Git autocommit | Every save lands in git. Full history, diff, restore, manual checkpoints. The vault is a real git repo on disk. |
π Β No vendor lock-in | Your vault is a folder of |
πΈ Β Zero API keys required | Out of the box it runs fully offline. Cloud embedders are an opt-in, not a default. |
Why brain.md
LLMs are only as smart as the context you give them. brain.md turns your notes into that context β without dragging them into someone else's cloud, without locking them inside a proprietary format, and without asking you to plumb a vector database yourself.
You write markdown. brain.md gives you:
a polished editor + live preview with the full Obsidian-flavor dialect (wikilinks, embeds, callouts, math, mermaid, highlights, tasks, frontmatter, aliases),
a per-vault LanceDB vector store with a local
bge-small-en-v1.5embedder by default β switch to Ollama, LM Studio, OpenAI, or anything else with a/v1/embeddingsendpoint with one toggle,an MCP server (streamable HTTP) mounted on the same port, so Claude Desktop (or any MCP client) can read, search and write your notes safely β with per-folder read/write permissions for the agent surface,
optional password auth and git autocommit / restore for the whole vault.
Everything runs on your machine. The vault is a plain folder of .md
files you can open in any editor at any time.
How it compares
Obsidian | Logseq | Notion | brain.md | |
License | Proprietary | AGPL-3.0 | Proprietary | AGPL-3.0 |
Local-first vault on disk | β | β | β (cloud) | β |
Plain | β | β (block model) | β | β |
Built-in MCP server | β (3rd-party plugin) | β | β | β β 16 tools |
Vector RAG built-in | β (paid plugin) | β | β (cloud only) | β β LanceDB, local |
Per-folder agent permissions | n/a | n/a | n/a | β |
Single binary, no Electron | β (Electron) | β (Electron) | n/a | |
Works fully offline (incl. embeddings) | β (no AI) | β (no AI) | β | β β Xenova ONNX |
brain.md is not trying to replace Obsidian's plugin ecosystem or Notion's databases. It's narrower on purpose: a markdown vault designed from day one as a memory layer for AI agents over the Model Context Protocol.
Table of contents
β‘ Quick start
One line. No clone, no Bun, no Node β the installer detects your OS +
arch, downloads the matching prebuilt binary from the latest GitHub
release, drops it in ~/.local/bin (or %USERPROFILE%\.brain.md\bin
on Windows), and verifies it runs.
macOS / Linux
curl -fsSL https://raw.githubusercontent.com/mi4uu/brain.md/main/install.sh | bashWindows (PowerShell)
powershell -c "irm https://raw.githubusercontent.com/mi4uu/brain.md/main/install.ps1 | iex"Then:
brainmd # serve on :3000, vault at $HOME/.local/share/brain.md/vault
open http://localhost:3000Open http://localhost:3000. First run creates your vault at the
XDG default ($HOME/.local/share/brain.md/vault on macOS / Linux,
the equivalent on Windows).
To enable semantic search and the MCP similar_notes tool, open
Settings β AI / RAG and flip the switch. Default embedder is
bge-small-en-v1.5 running locally via Xenova ONNX (one-time ~133 MB
model download, then fully offline).
Want a tour? Point brain.md at the demo vault that ships with the repo:
brainmd --vault-dir ./example/vaultEvery screenshot below was taken against
example/vault/.
π¦ Install
Option A β install script (recommended, see Quick start)
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/mi4uu/brain.md/main/install.sh | bash
# Windows
powershell -c "irm https://raw.githubusercontent.com/mi4uu/brain.md/main/install.ps1 | iex"The script picks the right asset for your OS and CPU, writes it to
~/.local/bin/brain (or %USERPROFILE%\.brain.md\bin\brain.exe),
chmod's it, and verifies it boots. Pin a version with
BRAIN_VERSION=v0.1.0, change the install dir with BRAIN_INSTALL=β¦.
Option B β download the binary manually
Every release ships a single-file executable per platform with
the web UI embedded inside it. No Bun runtime, no Node.js, no
git clone, no bun install β just download, mark executable, run.
Grab the file for your machine from the latest release: π github.com/mi4uu/brain.md/releases/latest
Platform | Architecture | Asset |
π Β macOS β Apple Silicon |
| |
π Β macOS β Intel |
| |
π§ Β Linux |
| |
π§ Β Linux |
| |
πͺ Β Windows |
|
One-liner β macOS / Linux
# macOS Apple Silicon β swap the URL suffix for your platform from the table above
curl -L -o brainmd \
https://github.com/mi4uu/brain.md/releases/latest/download/brain-md-darwin-arm64
chmod +x brainmd
./brainmd # β serves on http://localhost:3000# Optional: drop it on your $PATH so you can run `brainmd` anywhere
sudo mv brainmd /usr/local/bin/brainmd
brainmd --help # see all flags
brainmd --port 4000 # custom port
brainmd --vault-dir ~/notes/my-vault # custom vault locationOne-liner β Windows (PowerShell)
iwr https://github.com/mi4uu/brain.md/releases/latest/download/brain-md-windows-x64.exe `
-OutFile brainmd.exe
.\brainmd.exe # β serves on http://localhost:3000
.\brainmd.exe --help # all flagsFirst run: brain.md creates an empty vault at the XDG default (
$HOME/.local/share/brain.md/vaulton macOS/Linux, the equivalent on Windows) and serves the editor at http://localhost:3000. Want to try the demo vault first? Downloadexample/vault/and pass it withbrain --vault-dir ./vault.
Untagged commits also produce binaries β they live as build artifacts on the Actions page with 30-day retention.
Option C β from source
git clone https://github.com/mi4uu/brain.md.git
cd brain.md
bun install
bun run start # runs the production server on :3000For development:
bun run dev:server # backend on :3000
bun run dev:web # vite on :5173 (with /api proxy)If you run bun run start from a fresh source checkout (no compiled
binary, no web/dist), the server downloads the matching web bundle
from the GitHub release into
$XDG_CACHE_HOME/brain.md/web/<version>/ on first request and serves
from there. To always work offline, run bun --cwd web run build
once.
Requires Bun β₯ 1.3. brain.md uses
Bun.password(built-in argon2id) so you don't need a native crypto build.
π₯οΈ The interface
Editor + preview
Two synchronised panes powered by CodeMirror 6 and a unified / remark / rehype rendering pipeline. The active block in the preview stays anchored to the cursor in the editor; a thin SVG connector marks the link between them.

The right rail collects Bookmarks Β· Vault Β· Tags Β· Outline Β·
Backlinks Β· Related. Each section is collapsible and remembers its
state per device (localStorage). The Tags panel splits into
In this note and Other tags the moment you open a note. The
Related panel powers itself from the RAG index β same engine the
agents use β and after every save brain.md quietly suggests up to three
tags borrowed from your closest semantic neighbours.
Markdown that actually does things
Callouts

Math (KaTeX)

Mermaid diagrams

Syntax-highlighted code

Command palette + quick switcher
βP / Ctrl+P β search across titles and bodies
βO / Ctrl+O β fuzzy quick switcher
Both are powered by cmdk inside a Radix Dialog.

Tasks across the vault
Every - [ ] and - [x] in your notes is collected into a single
view, with filters for open / done / all and a click-through to the
source line.

π€ AI for agents
This is what makes brain.md more than another markdown editor.
π Semantic search (RAG)
When a note is saved, brain.md chunks it (β€ 512 tokens, ~64-token
overlap, paragraph-aligned, frontmatter excluded), embeds each chunk,
and upserts the vectors into a per-vault LanceDB table at
<VAULT>/.brain/lance/.
Provider | Model | dim | Local? | API key |
Xenova (default) |
| 384 | β | β |
Ollama | e.g. | 768 | β | β |
LM Studio | any served GGUF embedder | varies | β | β |
OpenAI |
| 1536 | β | β |
Running the prebuilt binary? The Xenova local embedder pulls in
onnxruntime-node, which loads a platform-specific native library (libonnxruntime.so/.dll/.dylib) at runtime.bun --compiledoes not bundle that, so the embedder will throwlibonnxruntime.so.X: cannot open shared object fileon first use. The smoothest fix: run Ollama locally and switch the provider in Settings β AI / RAG to OpenAI-compatible,baseURL = http://localhost:11434/v1,model = nomic-embed-text(ollama pull nomic-embed-textfirst),dim = 768. Local Xenova works out of the box when you run from source (bun run dev).

REST surface:
Method | Path | What |
GET |
| Top-k semantic hits with snippet + line range |
GET |
| Notes semantically close to a given path |
POST |
| Pack top chunks into a token-budgeted markdown block |
GET |
| Notes with no backlinks AND low semantic neighbours |
GET |
| Topic clusters across recently modified notes |
GET |
| Provider, model, dim, chunks, |
POST |
| Walks the vault and rebuilds the index |
POST |
| Dry-run an embedder config without saving |
Related notes, in the sidebar
The same engine the agents use also powers a Related panel in the sidebar. Open any note β the panel lists semantically close neighbours with score, line range and a snippet preview. Click jumps you there.

Tag suggestions on save
After every save, brain.md quietly looks at the closest neighbours'
frontmatter tags and suggests up to three you haven't used yet.
One click drops the tag into your frontmatter.

π°οΈ MCP server
brain.md mounts a Model Context Protocol server on the same Elysia
app at POST /mcp. Transport is the 2024-11-05 streamable HTTP
variant in stateless JSON-response mode β one POST returns the
full JSON-RPC response in a single round trip, no SSE stream, a fresh
McpServer + transport per request. Sounds wasteful, but it's the
only mode that survives clients that open and close a transport per
tool call (Claude Desktop and LM Studio both do this).

Tools (16):
Tool | Folder perm | What it does |
| none | Full-text vault search |
| none | Semantic RAG (top-k chunks) |
|
| Note body + mtime |
|
| Filtered vault tree |
|
| Inbound wikilinks |
| none | Tag β count map |
| none | Aggregate tasks (filter: open/done/all) |
|
| Create or overwrite a note |
|
| Append a paragraph (blank-line separator) |
|
| Notes semantically close to a given path (excludes self) |
|
| Semantic search across task lines (filter: open/done/all) |
|
| Cluster a note's chunks into topical groups (cosine β₯ threshold) |
|
| Pack top-relevant chunks into a markdown context block (token cap) |
|
| Notes with 0 backlinks AND low semantic neighbour density |
|
| Topic clusters across notes modified in a recent window (e.g. 7d) |
|
| Cosine sim + unified diff + shared headings between two notes |
Resources (2):
vault://treeβ JSON{folders, notes}filtered by read permsvault://note/<path>β markdown body
Drop this into ~/Library/Application Support/Claude/claude_desktop_config.json
(macOS) or the equivalent on your OS:
{
"mcpServers": {
"brain.md": {
"type": "streamable-http",
"url": "http://localhost:3000/mcp"
}
}
}That's it β restart Claude Desktop and you'll see the tools appear. Full reference: docs/mcp.md.
π Per-folder permissions
Right-click any folder β MCP permissionsβ¦ to set explicit
{read, write} flags. Resolution walks the parent chain to root;
nearest explicit override wins; default is read + write.

This is how you keep Journal/Private/ out of agent reach without
locking down the whole vault.
π Optional password auth
Default: no auth. Set a password in Settings β Security to switch
on bearer-token authentication for both the HTTP API and the MCP
endpoints. Password is hashed with argon2id (Bun's built-in
Bun.password, no native crypto build needed); tokens live in memory
with a 24-hour TTL.

MCP config when auth is enabled
The plain-text MCP example earlier in the README assumes no auth.
When you turn auth on, every request to /mcp needs an
Authorization: Bearer <token> header. Most MCP clients have a
field for it:
Claude Desktop / Claude Code / Cursor (claude_desktop_config.json):
{
"mcpServers": {
"brain.md": {
"type": "streamable-http",
"url": "https://brainmd.example.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN_HERE"
}
}
}
}How to get a token. brain.md issues tokens through
POST /api/auth/login. You can do it from anywhere β most useful
is a quick curl:
curl -X POST https://brainmd.example.com/api/auth/login \
-H 'content-type: application/json' \
-d '{"password":"YOUR_PASSWORD"}' | jq -r .tokenPaste the returned token into the headers.Authorization field
above, restart the MCP client, done.
Heads-up. Tokens have a 24-hour TTL and are stored in memory only β a server restart invalidates every token. If your agent suddenly starts seeing
401 Unauthorized, get a fresh token. Long-term: pin the token on the client and let your agent re-login on 401 (most MCP clients don't do this yet β patches welcome).
If you're embedding the URL itself anywhere persistent, prefer a
secret-manager / .env over hard-coding the bearer string.
β¨οΈ CLI
brainmd [options] # or: bun run start
brainmd --help # -h
brainmd --version
brainmd --vault-dir <path> # -v <path>
brainmd --port <n> # -p <n>
brainmd --mcp-disabled # skip mounting MCP at /mcp/*Precedence: CLI flag > env var > XDG default. Unknown flag β stderr error + exit 2.
ποΈ Defaults & paths
Purpose | Env var | Default |
Vault |
|
|
Settings |
|
|
Same logic on macOS, Linux, Windows β no OS branching. The vault dir
is mkdir -p-ed on first run.
Per-vault state lives under <VAULT>/.brain/:
<VAULT>/
βββ Welcome.md
βββ Folder/
β βββ Note.md
β βββ .media/
β βββ img.png
βββ .brain/
βββ index.json # mtime-based search index
βββ settings.json # bookmarks, dailyDir, git autocommit, rag config
βββ folder-meta.json # icons, colors, per-folder MCP perms
βββ auth.json # argon2id hash β absent when auth is off
βββ lance/ # LanceDB tables (RAG), git-ignored
βββ trash/<ts>/... # recoverable deletesEvery env knob:
Var | Default | Notes |
| XDG | Overridden by |
|
| Overridden by |
| β | Base for default vault location. |
| β | Base for default settings location. |
|
|
|
|
| Bootstrap default only. |
ποΈ Architecture
+----------------+ /api/* +-------------------+
| React + CM6 | <------------------> | |
| web client | | |
+----------------+ | Elysia (Bun) | +-------------+
| | | Vault FS |
+----------------+ /mcp HTTP+SSE | - Vault | | .brain/ |
| Claude Desktop | <------------------> | - VaultIndex |--| index |
| (or any MCP | | - GitRepo | | trash |
| client) | | - SettingsStore | | lance/ |
+----------------+ | - AuthStore | | auth.json |
| - MCP server | +-------------+
| - RAG pipeline |
+-------------------+
|
v
+-------------------+
| LanceDB (vectors) |
| Xenova / OAI emb. |
+-------------------+Runtime: Bun
Backend: Elysia + native FS + GitRepo (libgit-free shell wrapper with an async write mutex)
Frontend: React 18 + CodeMirror 6 + unified/remark/rehype + highlight.js + KaTeX + mermaid (lazy) + Radix UI primitives + Tailwind tokens (CSS vars under the hood)
Vector store: LanceDB (
@lancedb/lancedb) per vaultMCP transport:
@modelcontextprotocol/sdkWebStandardStreamableHTTPServerTransportAuth:
Bun.password(argon2id, no native build)
Per-component documentation lives next to the code; see docs/ for the MCP reference.
π£οΈ Roadmap
Daily-note templates with variable interpolation
Snippet expansion in the editor (
/trigger)Hybrid search (BM25 + dense), fused via RRF
Multi-vault support behind a single server
Encrypted vaults (age key per vault)
Docker image (multi-arch, < 200 MB compressed)
Notarised macOS
.appwrapping the binaryHosted read-only demo
Want to nudge one of these up the list? Open an issue or PR.
π Sponsor
brain.md is a solo open-source effort. If it's useful to you and you can chip in, sponsorship pays for the time that goes into new features, docs and review.
The
Sponsor β€button at the top of this repo and the small heart in the brain.md topbar (next to About) both lead here.
π€ Contributing
Contributions welcome.
Open an issue first for anything non-trivial β a quick design sketch saves a long PR rewrite.
Write the test before the implementation. Server tests run with
bun test; the suite is currently 187 green.Open a PR. CI runs typecheck (server + web) +
bun test.
β Star history
Found brain.md useful? A β helps other people running local-first agent workflows discover it. No newsletter, no tracking, no follow-up email β just a signal that this exists.
π License
GNU Affero General Public License v3.0 or later β see LICENSE.
brain.md is, and will stay, free / libre / open-source. The AGPL was picked over weaker permissive licenses for two specific reasons:
It closes the SaaS loophole. If you modify brain.md and run it as a network service for others β hosted, multi-tenant, rebranded, whatever β you must publish your modified source under the same AGPL. Strong copyleft for a server-side tool means the community always gets the improvements back.
It can't be relicensed under a permissive license downstream. Forks stay open forever. Nobody can scoop the project, slap a new logo on it, and ship a proprietary "Pro" cut.
You're free to:
run brain.md, personally or commercially, without limits;
fork, modify, redistribute, even rebrand β provided your fork stays under the AGPL and you publish the source you're running.
You're not free to:
ship a closed-source product based on brain.md;
host a modified brain.md as a public service without publishing your modifications under the AGPL.
Trademarks
The name brain.md and the brain.md logo are not covered by the AGPL. If you fork the project, you're welcome to do almost anything with the code β but please use your own name and your own mark for your fork so users aren't confused about which project they're running.
brain.md β your notes, your machine, your agents.
Built by MichaΕ LipiΕski Β Β·Β github.com/mi4uu/brain.md Β Β·Β report a bug
This server cannot be installed
Maintenance
Latest Blog Posts
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/mi4uu/brain.md'
If you have feedback or need assistance with the MCP directory API, please join our Discord server