server-memory ignores MEMORY_FILE_PATH in npm 0.6.2; how to set a custom path?
The npm package @modelcontextprotocol/server-memory version 0.6.2 ignores the MEMORY_FILE_PATH environment variable even though the GitHub source handles it. After a global install, setting export MEMORY_FILE_PATH=/custom/path/memory.json, and running mcp-server-memory, the memory file is still created at a hardcoded path inside the package (path.join(__dirname, 'memory.json')). How can I make the server store memories at a custom location?
Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/1018
6 answers
This was a packaging bug: npm still had 0.6.2 while the repo source (which reads MEMORY_FILE_PATH) was at 0.6.3. A maintainer said version 2025.4.25 was understood to include the fix and recommended updating your MCP client config to use @modelcontextprotocol/server-memory@latest. Note that even on @latest, a relative path like "memory.jsonl" was not resolved against the project root; the setups that worked in this thread all used an absolute path for MEMORY_FILE_PATH.
While on an old install, two workarounds from the thread work:
-
Edit the installed file. In the global install (for example /Users/X/.nvm/versions/node/v22.5.1/lib/node_modules/@modelcontextprotocol/server-memory/dist/index.js), replace the hardcoded MEMORY_FILE_PATH line with code that reads process.env.MEMORY_FILE_PATH, falls back to a --memory-path argument, then a default, and logs the chosen path. As general advice, this is a manual hack to the package file, so check it again after any reinstall or update.
-
Build from source and point the client at the local build: clone https://github.com/modelcontextprotocol/servers.git (opens external site), run npm install and npm run build in src/memory, then in ~/.claude.json add to mcpServers: "memory": { "type": "stdio", "command": "node", "args": ["/path/to/src/memory/dist/index.js"], "env": { "MEMORY_FILE_PATH": "/absolute/path/memory.jsonl" } }. This was reported working with the Claude Code extension in VS Code.
If the server process cannot write the file, check write permission (chmod) of the target directory for the user running the stdio process, as one user needed to on Ubuntu via ssh-remote.
Did this work for you?-
What a GitHub user tried on GitHub (Didn't work)
Installed @modelcontextprotocol/server-memory 0.6.2 globally, exported MEMORY_FILE_PATH=/custom/path/memory.json, and ran mcp-server-memory; the file was still created at the hardcoded package-internal path.
Source: https://github.com/modelcontextprotocol/servers/issues/1018 (opens external site)
Did this work for you?What @olaservo tried on GitHub (Outcome unclear)
A maintainer suggested pinning @modelcontextprotocol/server-memory@latest, saying version 2025.4.25 was understood to include the fix.
Did this work for you?What @twooten tried on GitHub (Worked)
Cloned the servers repo, ran npm install and npm run build in src/memory, then configured Claude Code's mcpServers to run node with the local dist/index.js and an absolute MEMORY_FILE_PATH in the env block.
Did this work for you?What @sascharo tried on GitHub (Partly worked)
On server-memory@latest, set MEMORY_FILE_PATH to "memory.jsonl" expecting project-root resolution; no error occurred but the file was not written to the project root. Setting the absolute path then worked.
Did this work for you?What @rossshannon tried on GitHub (Worked)
Hardcoded a replacement path in the installed dist/index.js so the server reads MEMORY_FILE_PATH, falls back to a --memory-path argument, then a default path, and logs the chosen path; described as a temporary hack.
Did this work for you?
Related questions
- mcp-server-fetch: 'AnyUrl' object has no attribute 'decode' error
- Does the official MCP Postgres example validate SQL before executing it?
- How to fix UTF-8 Japanese text corruption/crash in mcp-server-sqlite with Claude Desktop on Windows?
- MCP Knowledge Graph Memory Server fails with ${workspaceFolder} in MEMORY_FILE_PATH
- npx @modelcontextprotocol/server-filesystem: ERR_MODULE_NOT_FOUND for zod-to-json-schema