How do I give Claude Code memory that survives sessions?

Magnemo is an open-source MCP server that gives Claude Code a folder of plain markdown notes you approve, which the next session reads first when it starts.

What happens at compaction

Every long session hits the same wall. The context fills, Claude Code compacts, and the work it was holding turns into a summary nobody checked. From there the agent forgets what it was doing, or keeps a wrong guess as fact, and you re-explain.

That is the model, not your prompt. The window closes, compaction guesses at what mattered, and what survives can't be audited.

The record the next session boots from

Magnemo keeps the record outside the model, in a vault on your own computer. It exposes exactly four tools:

  • retrieve reads the canon, the notes you have approved.
  • stage lets the agent propose a note.
  • bootpack returns what the next session reads first.
  • handoff closes a session with a note for the next one.

Agents can only stage. Nothing is kept until you run magnemo yes, and an agent cannot call that step. Every entry carries who wrote it, who approved it, and when. A newer note supersedes an older one, and the older one is archived with its words, never overwritten.

So the loop is: Claude Code stages notes as it works, you promote the ones that are right, and at the end of a session it calls handoff. The next session calls bootpack and starts from that approved record, not from a guess.

Notes that look like secrets or injected instructions are tainted when they arrive and are never served to an agent.

The paste for Claude Code

Install it and make a vault:

pip install magnemo
magnemo init ./vault

You can also run it with uvx magnemo-mcp. Then add this to your Claude Code MCP config, using the absolute path to your vault:

{
  "mcpServers": {
    "magnemo": {
      "command": "magnemo-mcp",
      "env": {
        "MAGNEMO_VAULT": "/absolute/path/to/vault"
      }
    }
  }
}

The one variable is MAGNEMO_VAULT.

Why does my agent forget in the first place? The context window fills and compaction summarizes it without checking, which is covered in /why-does-my-agent-forget.

What is a memory MCP server? It is a tool your agent calls to read and write notes that live outside the model, explained in /memory-mcp.

Does the same vault work in Cursor? Yes, the same vault works there with the same config shape, described in /cursor-memory.

Sessions die. The memory doesn't.