{"slug": "the-memory-mcp-server-setup-for-claude-code-and-codex-and-the-setting-that-keeps", "title": "The memory MCP server: setup for Claude Code and Codex, and the setting that keeps your memories", "summary": "Setting the MEMORY_FILE_PATH environment variable to a file in the user's home folder, such as ~/memory.jsonl, is required to keep the @modelcontextprotocol/server-memory MCP server from saving its knowledge graph inside the npx cache, where clearing or updating the cache can delete everything the agent remembered, according to a Calyban developer blog post published 2026-11-28. The post documents setup for Claude Code (via `claude mcp add --scope user`), Codex (an absolute path in `[mcp_servers.memory.env]`), and Cursor, Gemini CLI and Claude Desktop, and notes that two agents can share one memory by pointing at the same MEMORY_FILE_PATH, with each write taking a memory.jsonl.lock file so writes take turns. Calyban's one-click installer writes each agent's config format, wraps npx in `cmd /c` on Windows, and checks the package against the OpenSSF malicious-packages list.", "body_md": "[Dev blog](https://calyban.com/blog) · [Guides](https://calyban.com/blog#guide) · 2026-11-28\n\n# The memory MCP server: setup for Claude Code and Codex, and the setting that keeps your memories\n\n**Short answer:** add `@modelcontextprotocol/server-memory` to your agent and **set `MEMORY_FILE_PATH` to a file in your home folder**, like `~/memory.jsonl`. Without that variable the graph is saved next to the server’s code, inside the `npx` cache, and clearing or updating that cache can delete everything your agent remembered.\n\nThat second half is in the server’s README, well below the setup section. Most install guides skip it.\n\n[Calyban](https://calyban.com/) installs the memory server into Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI and Claude Desktop in one click, so every agent shares one memory without six config edits. Free, no account.\n\n## What it does\n\nThe memory server keeps a small knowledge graph in one JSONL file:\n\n- **Entities** are things with a name and a type (`John_Smith` ,`person` ).\n- **Relations** connect them, in active voice (`John_Smith works_at Anthropic` ).\n- **Observations** are single facts attached to an entity (`Prefers morning meetings` ).\n\nYour agent gets tools to create, search, read and delete all three. Tell it “remember that the staging database is read-only” in one session, and a later session can find it with `search_nodes`.\n\n## Claude Code\n\n```\nclaude mcp add --scope user memory \\\n  -e MEMORY_FILE_PATH=\"$HOME/memory.jsonl\" \\\n  -- npx -y @modelcontextprotocol/server-memory\n```\n\n`--scope user` makes it available in every project, which is usually what you want from memory.\n\n## Codex\n\n```\n[mcp_servers.memory]\ncommand = \"npx\"\nargs = [\"-y\", \"@modelcontextprotocol/server-memory\"]\n\n[mcp_servers.memory.env]\nMEMORY_FILE_PATH = \"/home/you/memory.jsonl\"\n```\n\nUse an absolute path. A relative one resolves against the server’s own folder, which puts you back in the `npx` cache.\n\n## Cursor, Gemini CLI, Claude Desktop\n\nSame shape in JSON:\n\n```\n\"memory\": {\n  \"command\": \"npx\",\n  \"args\": [\"-y\", \"@modelcontextprotocol/server-memory\"],\n  \"env\": { \"MEMORY_FILE_PATH\": \"/home/you/memory.jsonl\" }\n}\n```\n\nOn Windows, `\"command\": \"cmd\"` with `\"/c\", \"npx\"` at the front of `args`, and a path like `C:\\\\Users\\\\you\\\\memory.jsonl`.\n\n## Can two agents share one memory?\n\nYes. Point both at the same `MEMORY_FILE_PATH`. Each agent starts its own server process, and every write takes a lock file (`memory.jsonl.lock`) while it saves, so writes take turns and none is lost. The folder has to be writable for that lock.\n\nThat’s the easy way to give Claude Code and Codex the same long-term memory about you and your projects.\n\n## Memory for code, specifically\n\nThe memory server remembers facts you tell it. If what you want is an agent that remembers the structure of a big codebase, that’s a different tool: [Codebase Memory](https://calyban.com/mcp/io-github-deusdata-codebase-memory-mcp) builds a knowledge graph of the code itself, across 162 languages, so the agent can ask “who calls this” without reading half the repo.\n\n## The Calyban way\n\nOpen [Memory](https://calyban.com/mcp/memory) in Calyban, press **Install**, and tick every agent that should remember: Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Claude Desktop. Calyban writes each config in that agent’s format, wraps `npx` in `cmd /c` on Windows, and checks the package against the OpenSSF malicious-packages list first. **Capabilities** then shows how often your agents actually call the memory tools, so you can tell whether it’s earning its place in every request.\n\nCalyban is free for Windows and Linux at [/#download](https://calyban.com/#download). Tell us on [Discord](https://discord.gg/pHDNtgYvWn) what you’ve taught yours to remember.", "url": "https://wpnews.pro/news/the-memory-mcp-server-setup-for-claude-code-and-codex-and-the-setting-that-keeps", "canonical_source": "https://calyban.com/blog/memory-mcp-server-setup", "published_at": "2026-11-28 00:00:00+00:00", "updated_at": "2026-11-29 06:14:54.889571+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "developer-tools"], "entities": ["Calyban", "@modelcontextprotocol/server-memory", "Claude Code", "Codex", "Cursor", "Gemini CLI", "Claude Desktop", "OpenSSF"], "also_reported_by": [], "takeaway": "Set MEMORY_FILE_PATH to an absolute path in your home folder (e.g. ~/memory.jsonl) when installing @modelcontextprotocol/server-memory, or the graph is written inside the npx cache and can be wiped by a cache clear or update.", "recommendation": {"advice": "Point MEMORY_FILE_PATH at an absolute home-folder file like ~/memory.jsonl, and give multiple agents the same path so they share one locked JSONL memory graph instead of losing it in the npx cache.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/the-memory-mcp-server-setup-for-claude-code-and-codex-and-the-setting-that-keeps", "markdown": "https://wpnews.pro/news/the-memory-mcp-server-setup-for-claude-code-and-codex-and-the-setting-that-keeps.md", "text": "https://wpnews.pro/news/the-memory-mcp-server-setup-for-claude-code-and-codex-and-the-setting-that-keeps.txt", "jsonld": "https://wpnews.pro/news/the-memory-mcp-server-setup-for-claude-code-and-codex-and-the-setting-that-keeps.jsonld"}}