MCP `memory` server NO persistent memory.json location!
Persistent Data Location
Is your feature request related to a problem? Please describe.
It's in the title:
[!CAUTION] Code version updates will destroy that json file!
I am very relieved I had anticipated that happening and add backup my json yesterday before a restart. Incidentally that will super hard to find that jsonfile ! lol!
current location example: C:\Users\shane\AppData\Local\npm-cache\_npx\15b07286cbcc3329\node_modules\@modelcontextprotocol\server-memory\dist\memory.json
Describe the solution you'd like
For persistent data we need to have server code that will respect a location constant:
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
"env": {
"MCP_MEMORY_DATA_FILE": "c:\\super\\safe\\persistent\\location\\memory.jsonl"
},
Describe alternatives you've considered
n/a
Additional context
you're doing incredible work! Love the protocol so much ...
im also having trouble figuring out how to save to memory.json
create_entities seems to do nothing to actually save the file.
so close :) - but currrently not functional
I'm not a JS dev, so I'm shy to PR this code. But nonetheless, it works for me.
here you go: https://github.com/shaneholloman/mcp-knowledge-graph
published here: https://www.npmjs.com/package/mcp-knowledge-graph
I updated the server name, as I intend to develop my own version from here;
"mcp-knowledge-graph": {
"command": "npx",
"args": ["-y", "mcp-knowledge-graph", "--memory-path", "C:/Users/shane/Desktop/memory/memory.jsonl"]
},
these are now separate servers - DONT run them together yet as I will need to use unique function name before you can do that.
so remove the original if you want to use mine
Hi! Is 'memory persistence' something planned in the pipeline? I would really love to have the memory graph persisted!
Hi
Hi! Is 'memory persistence' something planned in the pipeline? I would really love to have the memory graph persisted!
kind of persistance should be working, if you specify env variable - take a look - NPX with custom setting https://github.com/modelcontextprotocol/servers/tree/main/src/memory#npx-with-custom-setting
but seems there is a glitch between version publish in npm and repo version. tested by running these commands -
""" ❯ npm view @modelcontextprotocol/server-memory version 0.6.2 """
while version in repo is newer - https://github.com/modelcontextprotocol/servers/blob/main/src/memory/package.json """ "version": "0.6.3", """
Please check version your are using and let me know about your config.
Hi,
In the end, after debugging it intensively with cline and a Claude Sonet-3.5 key, I ended up with Claude confirming that while there was an environment variable, the MCP server was indeed not actually storing data in the specified file.
I don't mean to say that this is the truth my any means, but since I needed some kind of local data storage and I was talking about it with Claude, it ended up locally rewriting the mcp with sqlite for storage. Since I'm doing this for a corporate need, I can't share the implementation though :/
So while it's very possible that you're right, that it can save to a file given the right version, I no longer have this mcp installed and I've moved on to other tasks.
Thanks for the answer anyway, I hope it can help others if they find themselves in the same situation :)
Hi!
Glad that you have found way to workaround the issue!
Based on my experience, if you clone the repository directly and use version 0.6.3, you can successfully utilize MEMORY_FILE_PATH environment variable to store memory.json permanently in a secure location. However, the standard approach using the npm package (as per documentation) won't work since npm still on version 0.6.2. Not sure who should push new version to npm. I do not have such permissions. Hence, my workaround to build directly from the repository.
here is my steps:
npm uninstall -g @modelcontextprotocol/server-memory cd /d/mcp/github_repositories/
git clone https://github.com/modelcontextprotocol/servers.git
cd modelcontextprotocol_servers/src/memory npx tsc npm install -g . npm ls -g --depth=0 C:\Program Files\nodejs -> .
@modelcontextprotocol/[email protected] -> .\D:\mcp\github_repositories\modelcontextprotocol_servers\src\memory
not sure if I provided all steps. maybe some additional are still needed ...
I've also fell on the version trap... v0.6.3 does provide the memory location argument, but that specific version is not yet published.
Part as an exercise, part of the need to have a published package available, I created a Python port of such MCP server that behaves in the same way as the original and provides the MEMORY_FILE_PATH env variable.
Here is the repo: https://github.com/edobez/mcp-memory-py
It doesn't need to be cloned, as the solution above, since the package is published on PyPI. It can be simply used as:
{
"mcpServers": {
"memory-python":
{
"command": "uvx",
"args": [
"--refresh",
"--quiet",
"mcp-memory-py"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/custom/memory.json"
}
}
}
I might add other functionalities in the future, if you are interested.
Hi @jspahrsummers any idea when the new version of memory server will be published? Seems like every new adopter of the memory server is facing this issue because of the lack of being able to pass the MEMORY_FILE_PATH.
Is there a place on my computer where this is stored? I'd really like to back up my knowledge graph
https://github.com/BRO3886/mcp-memory-custom/
Went ahead and modified the code a bit to power the following use-cases:
- project specific memories
- timestamp recording
the example prompt I am using is attached in the README
@jerome3o-anthropic please let me know if these changes can be pushed to the official repo, been working well for me across 3 different projects