Skip to main content

Personal memory layer for AI coding agents — MCP vault for Claude Code, Cursor, and the same tools across sessions

Project description

Brainvault logo

Brainvault

Personal memory for Claude Code and Cursor — one local SQLite vault, MCP tools, and host hooks. No cloud, no extra infrastructure.

Best experience: Claude Code. Cursor works but has limitations — see Host support.

PyPI version CI Python 3.10+ SQLite MIT License

PyPI  ·  Repository  ·  Issues  ·  Changelog  ·  Documentation


Brainvault gives your agent durable context: decisions, patterns, project facts, and session notes stay in ~/.brainvault/memory.db, searchable across projects. Install once globally; hooks keep the vault warm while you work.


Quick start

pip install brainvault
brainvault install

Fully quit your editor (not just close a tab), then reopen so MCP loads. Verify:

brainvault doctor

Host support

Claude Code — recommended

Brainvault is built around Claude Code and works seamlessly there:

  • CLAUDE.md is injected as a system-level instruction — Claude follows the memory rules reliably on every turn.
  • Stop + PostToolUse hooks fire automatically after each turn — no manual steps.
  • get_my_context() is called at session start without prompting.
  • Cross-project context, proactive capture, and git scan all work out of the box.

Cursor — supported, with caveats

Cursor works but the experience is noticeably less smooth:

Limitation Detail
Agent mode only MCP tools are unavailable in plain chat. Must use Agent / Composer mode with brainvault enabled in MCP settings.
Model compliance Cursor can run non-Claude models. .mdc rules are advisory — models follow them with varying reliability. get_my_context() at session start is often skipped.
Rules vs system prompt CLAUDE.md is a hard system instruction. Cursor's .mdc rules are softer hints, especially for models not fine-tuned to follow them.

Workaround in Cursor: if context feels missing, say ”check my context” — that reliably triggers get_my_context(). Always verify brainvault is listed as an active MCP server for the current chat.


How it works in practice

Session start — context loads automatically

Open Claude Code and start working. Brainvault calls get_my_context() on your first turn:

> hey, continuing work on the backend

[Claude calls get_my_context()]

Got it. Picking up on myapp — a few things worth flagging before we start:
- Auth middleware: session tokens stored in a way that may not meet the new compliance
  requirements — this was flagged as a known risk last sprint.
- DB connection pool set to 5 in staging config, still needs bumping before prod deploy.

No briefing needed. It remembered.


Bug you've seen before — surfaces instantly

> getting a weird memory leak, can't figure out where it's coming from

[Claude calls search_memory("memory leak background task")]

Found it — you hit this in a previous project. Root cause: background tasks holding
references to closed database connections. Fix: explicit cleanup in the task teardown,
don't rely on GC. You noted this pattern 3 weeks ago.

One search, actionable answer, zero re-diagnosis.


Starting a new project — context follows you

> starting a new service, going with FastAPI + PostgreSQL

[Claude calls register_project() + save_memory(decision)]

Registered. Noted the stack. Pulling in patterns from your other projects — you've
already solved async connection pooling, JWT auth flow, and rate limiting. Want me
to flag those decisions before you re-implement them?

Prior work becomes a starting point, not forgotten history.


When does it get good?

Brainvault improves as you use it — here's roughly what to expect:

Stage What's there Experience
Day 1 (after install + bootstrap) Old session transcripts, git history Basic recall — raw notes, rough search
~1 week First live session memories, a few decisions + patterns captured Noticeably useful — key bugs and choices surface
~1 month Cross-project patterns, profile built up, outcomes recorded Seamless — Claude picks up context without prompting
Ongoing Vault grows with every session Gets sharper the more projects and decisions accumulate

Run brainvault bootstrap and brainvault bootstrap-git ~/Projects after install to seed the vault with your existing history — this jumpstarts the process significantly.


What it does

  • Hooks: after each agent turn — session notes, git scan, optional repo index, optional embedding backfill.
  • Search: FTS5 keyword search always; optional semantic blend if you install [semantic] (see below).

MCP tools (12) — available to the agent once MCP is connected:

Tool Purpose
get_my_context Profile, active projects, short vault stats
search_memory Find memories by query (FTS5; + vectors if [semantic] installed)
save_memory Store a memory (profile, project, decision, pattern, note)
register_project Create or update a project record
get_project Everything stored for one project (+ recent memories)
record_outcome Attach outcome + sentiment to a decision
reflect Open decisions, cross-project patterns, stale projects, hot memories
update_memory Edit an existing memory
forget Delete a memory (and its embedding row)
get_code_context Memories + indexed files / co-change for a project + topic
get_recent_activity Recent sessions and tool activity
get_session_timeline Chronological tool events for one session

Memory types (for save_memory):

Type Use for
profile You — preferences and working style (global)
project Stack, constraints, onboarding-style facts
decision Choices with why (alternatives rejected)
pattern Repeatable “when X, do Y” rules
note Mostly auto-captured session summaries

Vault: ~/.brainvault/memory.db (global — not per-repo).

Configs patched (global):

Host Main paths
Claude Code ~/.claude/settings.json, ~/.claude/CLAUDE.md
Cursor ~/.cursor/mcp.json, ~/.cursor/rules/brainvault.mdc, ~/.cursor/hooks.json

brainvault install --agent claude_code or --agent cursor limits which host is patched.


When to run what

You want Command
Catch up old Claude sessions (~/.claude/projects) brainvault bootstrap --host claude_code
Catch up old Cursor transcripts (~/.cursor/projects/.../agent-transcripts) brainvault bootstrap --host cursor
Both (default) brainvault bootstrap
Mine git across many repos brainvault bootstrap-git ~/Projects (or ~)
Inspect / fix wiring brainvault doctor
Search from terminal brainvault search "<query>"
Quickly save a decision/pattern without opening Claude brainvault save "chose celery over rq: better retry budgets" --type decision --project myapp
Vault overview brainvault status, brainvault stats, brainvault reflect
Optional meaning-based search (heavier install) pip install 'brainvault[semantic]' then brainvault embed once to backfill vectors

Bootstrap and bootstrap-git are idempotent (safe to re-run).


CLI (short list)

Run brainvault help for the full command list. Common ones: install, uninstall, doctor, bootstrap, bootstrap-git, git-scan, index-repo, search, status, stats, reflect, export / import, embed, graph, sessions, activity.


Optional semantic search

pip install 'brainvault[semantic]'
brainvault embed

Adds local embeddings (fastembed + sqlite-vec); first run downloads a small model to ~/.cache/huggingface. Search blends keywords + vectors when extras are installed. Not required for normal use.


Platform support

macOS and Linux are fully supported and tested. Windows support is best-effort — hook commands use forward-slash paths (C:/Users/...) which work in both cmd.exe and PowerShell, and all file I/O is UTF-8. If you hit an issue on Windows, please open an issue.


Out of scope

  • Not cloud sync or team wiki.
  • Not full RAG over every line of your repo; index-repo + get_code_context are structural (files, imports, co-change), not “embed all source”.

Contributing / internals

  • CLAUDE.md — module map, hook behaviour, MCP tool details, how to run tests.
  • CONTRIBUTING.md — releases, PyPI README images, dev notes.
git clone https://github.com/SumithSB/brainvault.git
cd brainvault
pip install -e ".[dev]"
pytest

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brainvault-0.1.0.tar.gz (455.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brainvault-0.1.0-py3-none-any.whl (98.2 kB view details)

Uploaded Python 3

File details

Details for the file brainvault-0.1.0.tar.gz.

File metadata

  • Download URL: brainvault-0.1.0.tar.gz
  • Upload date:
  • Size: 455.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for brainvault-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40ab54478c657b35a638b55732536c57727b83daff2d76aedf326b6a4a31ac68
MD5 cfcf9fed7921347df4dab5bec5ecace3
BLAKE2b-256 3f5e977063b1c067fb6df845bb71fb7ef36a6fee63c7474704d59049b5eb5971

See more details on using hashes here.

Provenance

The following attestation bundles were made for brainvault-0.1.0.tar.gz:

Publisher: publish.yml on SumithSB/brainvault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brainvault-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: brainvault-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 98.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for brainvault-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fea4d7e71dc0f5a391c761828087e02503c16dbd5bf6f0ffb70cd6b03048d44e
MD5 3e30717f3c1022fb17232438aee6347d
BLAKE2b-256 80adfbc758590abd7db1dd85fce3ae30dcdc203fe306c04e6db0d4817195b99a

See more details on using hashes here.

Provenance

The following attestation bundles were made for brainvault-0.1.0-py3-none-any.whl:

Publisher: publish.yml on SumithSB/brainvault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page