memory MCP: memories not persisting across sessions (check MEMORY_FILE_PATH)
Fixes the memory MCP server losing everything between sessions. Use when entities created in one session are gone in the next. Not for duplicate entities or a bloated memory file.
TL;DR
Memories vanish between sessions when MEMORY_FILE_PATH is unset, relative, or different per client: each launch then writes to a different file (or a temp default). Set MEMORY_FILE_PATH to one absolute, writable path in every client's MCP config. All sessions then share the same knowledge graph file.
The error
Error: Changes not saved across sessionsFix it
Check what path each client is actually using. Look at the
envblock of the memory entry in every MCP config (Claude Desktop, Claude Code, Cursor each have their own).- Expected: you find either no
MEMORY_FILE_PATHor different values per client.
- Expected: you find either no
Set one absolute path everywhere:
{ "mcpServers": { "memory": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-memory"], "env": { "MEMORY_FILE_PATH": "[HOME]/..." } } } }- Expected: identical absolute path in every client config.
Make sure the file is writable (
touchit once as your user), then create a test entity and restart the client.- Expected: the entity is still there after restart.
When to use
- Entities created in one session are missing in the next.
- Different clients (Desktop vs Code) seem to have different memories.
When NOT to use
- Duplicate entities piling up - that is a naming/search_nodes discipline problem.
- memory.json over 10MB and slow - that is bloat, prune it.
- Server will not start at all - check npx and the install first.
Compatibility
- @modelcontextprotocol/server-memory, all clients.
Root cause
The server persists the knowledge graph to the JSONL file at MEMORY_FILE_PATH. Without the variable it falls back to a default location that varies by working directory, so two clients (or two launches) silently use two different files. A relative path has the same effect because the server's working directory differs per client.
Edge cases
- Do not point the file inside a synced folder with aggressive conflict handling unless you enjoy resolving JSONL merge conflicts.
- Keep secrets out of the file: it is plain text on disk and outlives the session.
- Back the file up before pruning; there is no undo for delete_entities.