Skip to content

MerlijnW70/mnema

Repository files navigation

mnema

A local, encrypted memory layer for AI agents. Give your AI a permanent, private memory that never forgets — and never leaks to the cloud.

One-line install. Zero configuration.

CI release license

Install

Homebrew (macOS / Linux):

brew install MerlijnW70/mnema/mnema

With Rust, any platform:

cargo install mnema --features mcp

No toolchain, one line — macOS / Linux, or Windows in PowerShell:

curl -fsSL https://raw.githubusercontent.com/MerlijnW70/mnema/main/install.sh | sh
irm https://raw.githubusercontent.com/MerlijnW70/mnema/main/install.ps1 | iex

Or download a binary for your OS from the latest release.

You get two commands: mnema (the CLI) and mnema-server (the server your AI editor talks to).

Try it in 30 seconds

The store is created and encrypted on first use — no key, no setup:

mnema remember mind.store open "the user prefers TypeScript"
mnema recall   mind.store 5 "language preferences"
# → the user prefers TypeScript

Give it to your AI

Add mnema to your MCP client (Cursor, Claude Desktop, Claude Code) — that's the whole setup:

{
  "mcpServers": {
    "mnema": {
      "command": "mnema-server",
      "args": ["--path", "~/mnema.store"]
    }
  }
}

Your agent now has remember, recall, recent, and more. Everything stays on your disk, encrypted. (If mnema-server isn't on your PATH, use the absolute path the installer printed.)

Why mnema

  • Private by design — everything lives on your disk, encrypted. Memories you mark private are structurally blocked from ever reaching a cloud model. Nothing phones home.
  • Trustworthy — built in Rust, 100% mutation-tested, and fail-closed: a wrong key or a crash mid-write never loses or leaks your memory.
  • Tiny & fast — a ~0.4 MB binary with zero runtime dependencies. No Python, no database, no daemon.

Commands

Command Action
mnema remember <store> <tier> <text> Store a memory (tier = open / redacted / private)
mnema recall <store> <k> <query> Retrieve the most relevant memories
mnema recent <store> <k> List the k most recent memories
mnema fact <store> <subject> <attribute> <value> Store a belief (a newer value supersedes an older one)
mnema beliefs <store> <subject> List the live beliefs about a subject
mnema reinforce <store> <id> Strengthen a memory so it resists forgetting
mnema forget <store> <substring> Hard-delete memories containing a substring
mnema forget-fact <store> <subject> [attribute] Hard-delete beliefs about a subject
mnema stats <store> Memory health — counts by privacy tier
mnema prune <store> <half_life> <threshold> Forget faded memories
mnema keygen Print a strong passphrase to use as MNEMA_KEY
mnema rekey <store> Re-encrypt the store under a fresh key

The MCP server exposes the same surface as tools — remember, recall, recent, remember_fact, beliefs, forget, forget_fact, reinforce, prune, stats — plus a mnema://recent resource (recent memories a client can auto-load as session-start context) and a recall prompt (pull relevant memories into the conversation on demand). By default recall never returns private memories; launch mnema-server --local only when it feeds an on-device model to let recall surface them.

Semantic recall (optional)

Out of the box, recall is lexical (fast, zero-dependency, no model). For meaning-based recall — so "what beverage do I like?" finds "I drink coffee" — point mnema at a local embeddings server you already run, no cloud and no heavyweight build:

# Build with the http-embed feature (a few small crates — not a whole ML stack)
cargo install mnema --features mcp,http-embed

# Run a local embedding model, e.g. Ollama:  ollama pull nomic-embed-text
MNEMA_EMBED_MODEL=nomic-embed-text mnema-server --path ~/mnema.store

It defaults to Ollama on http://localhost:11434/api/embeddings. Point it anywhere with MNEMA_EMBED_URL — an OpenAI-compatible /v1/embeddings endpoint (llama.cpp, LM Studio, vLLM, text-embeddings-inference) is auto-detected, or force it with MNEMA_EMBED_API=ollama|openai. Everything stays on your machine. (Prefer a fully self-contained binary? --features local-embed bundles all-MiniLM-L6-v2 via candle instead — heavier build, no server to run.)

Already have a store? Switching embedders changes the vector width, so re-embed it once — no data lost:

mnema-server --path ~/mnema.store --migrate   # re-embeds under the new embedder, then exits

Keys

You don't have to manage a key: omit MNEMA_KEY and mnema generates a random key file (<store>.key) next to your store. Want a portable passphrase instead (a shared store, CI, an env-only secret)? Set MNEMA_KEY to any string — or a strong random one:

export MNEMA_KEY="$(mnema keygen)"

Troubleshooting

  • cannot open store (wrong key or corrupt) — the store was sealed under a different key. Set MNEMA_KEY to the right passphrase, or make sure <store>.key is still next to the store.
  • Lost your MNEMA_KEY? If you used a passphrase and lost it, encrypted data can't be recovered — that's the point. If you used the default key file, keep <store>.key safe; it is the key.
  • already in use by another mnema process — one writer at a time. Close the other server or CLI and retry.
  • Server won't start after an interrupted rekey — set MNEMA_KEY to the old passphrase and run mnema rekey <store> again to finish the migration.

Under the hood

Curious how the privacy wall, encryption, retrieval, and the mutation-testing that proves it all actually work? → ARCHITECTURE.md.

License

Dual-licensed under MIT OR Apache-2.0.

About

A fast, secure, local-first memory layer for LLMs — contradiction-resolving writes, injection-resistant retrieval, encrypted at rest, every guarantee ratchet-proven.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages