You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Environment variables not respected in @modelcontextprotocol/server-memory package #1018
The published version of @modelcontextprotocol/server-memory (0.6.2) on npm does not respect the MEMORY_FILE_PATH environment variable. The repository source code correctly handles environment variables, but the compiled version published to npm uses a hardcoded path for the memory file.
Fix
Publish to npm the latest 0.6.3 version
Steps to Reproduce
Install the package with npm i -g @modelcontextprotocol/server-memory
Set environment variable: export MEMORY_FILE_PATH="/custom/path/memory.json"
Run the server: mcp-server-memory
Observe that the memory file is still created at the default location, not the path specified in the environment variable
Expected Behavior
The server should use the path specified in the MEMORY_FILE_PATH environment variable for storing the memory file.
Actual Behavior
The server ignores the environment variable and always uses a hardcoded path: path.join(__dirname, 'memory.json').
I resolved (temporarily) by hardcoding a change to the code on-disk, at e.g., /Users/X/.nvm/versions/node/v22.5.1/lib/node_modules/@modelcontextprotocol/server-memory/dist/index.js
with this code to enable shared memory across clients and devices (overdid it with the argument/environment handling to avoid any ambiguities):
My understanding was that version 2025.4.25 finally included the fix for this, if you're still having this issue could you try adding @latest to your package version eg in your config use: @modelcontextprotocol/server-memory@latest?
My understanding was that version 2025.4.25 finally included the fix for this, if you're still having this issue could you try adding @latest to your package version eg in your config use: @modelcontextprotocol/server-memory@latest?
I just did set it to @latest and did reset the MCP server cache, though it still doesn't work as I expected. When I set "MEMORY_FILE_PATH": "memory.jsonl" I expect it to access the memory.jsonl in the project root, just like everything else in VS Code. server-memory@latest is not writing to memory.jsonl in the project but to somewhere else, not sure where. At least it's not throwing an error, so I assume it's writing to somewhere else. I've been looking for the file, but I couldn't find it on my box. Do I misunderstand how the server works? Does it not interpret "memory.jsonl" as a relative path? The file does exist and when it set MEMORY_FILE_PATH to the absolute path, everything works.
I ran into the same issue and decided to solve it for myself by rewriting this server in Rust. It’s basically the same MCP implementation, but with some improvements to the search logic and with tokio under the hood — which should give better performance and handle resources more reliably.
If anyone’s interested, I’ve published it as a separate project.
There are brew formulas with prebuilt binaries for popular platforms on the releases page.
You can set the path to the memory file using the same approach — via the MEMORY_FILE_PATH environment variable.
"inputs": [
{
"id": "memory_file_path",
"type": "promptString",
"description": "Path to the memory storage file",
"password": false
}
]
When memory_file_path is set through VSCODE to /home/user/.mcp/memory.json, it cannot establish a connection. However, if I manually define the file path, it recognizes it but cannot write the memories.
Again, if using locally, both approaches work fine ...🤔
I also changed the r+w permission via chmod; it is really a little bit frustrating.
Reacted by Sascha Roman Robitzki, Ahmad Omira and movy
JUST a mention/note:
Still not fixed. I ran into the same error today and still not knowing how memoy-tool exactly works. Why isn't there a good documentation about? Nah, just asking myself. ^_~
"Error: Failed to list local tools"
This still isn't (properly?) resolved. I'm using OpenCode (this works just fine, minimal translation for the MCP setup), and while the reference to the memory.json file works, the file is never written to when forming new memory. Pretty important for this to work cleanly, one would assume.
On the same topic - where is the default memory file stored if we don't define one?
The published package has read MEMORY_FILE_PATH since 0.6.3 was released in 2025 (c0939060), and every version since. The remaining path problems reported here are about relative values resolving against the package directory rather than the working directory; that is tracked in #692 and fixed by #4327. Closing this one as completed.
Activity
rossshannon commentedon Mar 24, 2025
Related items #692 #674 and #220 could all be closed when this is fixed.
It’s confusing as when you read the code of the package at https://github.com/modelcontextprotocol/servers/tree/main/src/memory you are looking at pre-release code (even though the last change to the readme was on February 2nd). FYI @jerome3o-anthropic
I resolved (temporarily) by hardcoding a change to the code on-disk, at e.g.,
/Users/X/.nvm/versions/node/v22.5.1/lib/node_modules/@modelcontextprotocol/server-memory/dist/index.jswith this code to enable shared memory across clients and devices (overdid it with the argument/environment handling to avoid any ambiguities):
anoblet commentedon Apr 28, 2025
Was this ever fixed? I'm not able to get
memory.jsonwritten anywhere.Edit: I got it working.
thuantruong-kite commentedon Jun 1, 2025
+1? a lot of contributions for this issue, please merge it
sascharo commentedon Jun 4, 2025
What's your solution? My only working workaround is an absolute path but it's not a great solution.
olaservo commentedon Jun 7, 2025
My understanding was that version
2025.4.25finally included the fix for this, if you're still having this issue could you try adding@latestto your package version eg in your config use:@modelcontextprotocol/server-memory@latest?sascharo commentedon Jun 7, 2025
I just replied to you here: #1481 (comment)
DenysVuika commentedon Jul 1, 2025
This is so frustrating, none of the examples in docs works properly.
It would really help if maintainers put effort into quality control
aliev commentedon Jul 11, 2025
Hey everyone,
I ran into the same issue and decided to solve it for myself by rewriting this server in Rust. It’s basically the same MCP implementation, but with some improvements to the search logic and with
tokiounder the hood — which should give better performance and handle resources more reliably.If anyone’s interested, I’ve published it as a separate project.
There are
brewformulas with prebuilt binaries for popular platforms on the releases page.You can set the path to the memory file using the same approach — via the
MEMORY_FILE_PATHenvironment variable.Here’s the link: https://github.com/aliev/mcp_memory
Anselmoo commentedon Jul 26, 2025
Hey everyone,
Is there any update?
Running on a local machine with
MacOSworks fine, but using it viassh-remoteon a Ubuntu machine does not allow of use.and:
When
memory_file_pathis set throughVSCODEto/home/user/.mcp/memory.json, it cannot establish a connection. However, if I manually define the file path, it recognizes it but cannot write the memories.Again, if using locally, both approaches work fine ...🤔
I also changed the
r+wpermission viachmod; it is really a little bit frustrating.itsmetoolala commentedon Sep 20, 2025
JUST a mention/note:
Still not fixed. I ran into the same error today and still not knowing how memoy-tool exactly works. Why isn't there a good documentation about? Nah, just asking myself. ^_~
"Error: Failed to list local tools"
Derjyn commentedon Oct 16, 2025
This still isn't (properly?) resolved. I'm using OpenCode (this works just fine, minimal translation for the MCP setup), and while the reference to the
memory.jsonfile works, the file is never written to when forming new memory. Pretty important for this to work cleanly, one would assume.On the same topic - where is the default memory file stored if we don't define one?
twooten commentedon Dec 12, 2025
This was a bit of a pain but got it working. I used the Claude Code extension in VS Code to resolve it.
git clone https://github.com/modelcontextprotocol/servers.git mcp-serversHopefully this helps someone in the future.
ferhimedamine commentedon Jun 12, 2026
laozhangzzz commentedon Jun 25, 2026
olaservo commentedon Sep 3, 2026
The published package has read
MEMORY_FILE_PATHsince 0.6.3 was released in 2025 (c0939060), and every version since. The remaining path problems reported here are about relative values resolving against the package directory rather than the working directory; that is tracked in #692 and fixed by #4327. Closing this one as completed.