servers icon indicating copy to clipboard operation
servers copied to clipboard

Memory Server not adding to JSON Array

Open bbarrington0099 opened this issue 7 months ago • 9 comments

Describe the bug Running the server locally with no changes to the repo, have env set to a custom MEMORY_FILE_PATH. I have tried starting the server with the memory.json being both an empty JSON Object and Array. When a new entity is created, it removes the existing structure of the empty file and adds a new entity, then when another entity is created it just adds a new JSON Object so there are 2 JSON Objects in the file but nothing wrapping them so the file is invalid

To Reproduce Steps to reproduce the behavior:

  1. Have one entity created
  2. Have a second entity created
  3. See that the .json file is errored

Expected behavior I expect multiple entities to go into and be pulled from a valid JSON Array

Logs {"type":"entity","name":"Brandon","entityType":"User","observations":["Primary user as provided by himself."]} {"type":"entity","name":"MCP","entityType":"Self","observations":["This is the self entity for the assistant, created as per server instructions."]}

Additional context Client created to use OpenAI API, other tools are working as expected, when only one entity is present the Memory tools work as well.

bbarrington0099 avatar Apr 17 '25 16:04 bbarrington0099

In my case the memories being saved (not sure where) because Claude recalls those memories across sessions. But it's not clear where they are being stored. They are certainly not being stored in the location I specified.

Here's my config file

{
  "tools": [
    {
      "name": "memory",
      "type": "memory_server",
      "storage_path": "/Users/lamba/Dropbox/Claude-MCP/memory.json"
    }
  ],
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory",
        "--file",
        "/Users/lamba/Dropbox/Claude-MCP/memory.json"      
      ],
      "env": {
        "MEMORY_FILE_PATH": "/Users/lamba/Dropbox/Claude-MCP/memory.json"
      }
    },
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/lamba/Desktop",
        "/Users/lamba/Dropbox"
      ]
    }
  }
}


lamba avatar Apr 19 '25 18:04 lamba

I've also been unable to get my memory.json saved to the specified path. Here's my config:

    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ],
      "env": {
        "MEMORY_FILE_PATH": "C:\\Users\\taket\\Documents\\GitHub\\claude-memory\\memory.json"
      }
    },

I think my knowledge graph is empty now, but at some point Claude was steadily filling it up, and I asked Claude where he was writing it, because it was not at C:\Users\taket\Documents\GitHub\claude-memory\memory.json.

After some investigating we found that the file is being saved to the dist folder in my local install of @modelcontextprotocol/server-memory. Note that I've installed all of my MCP servers to my Windows PC's home folder; so if you haven't done that, then you might not have the directory.

cd ~
npm install @modelcontextprotocol/server-memory
...

So, the memory file for me is: C:\Users\taket\node_modules\@modelcontextprotocol\server-memory\dist\memory.json (if you run npm install * in a different directory, I think ./node_modules/ will be created there)

Unfortunately, I don't know if this file in ./dist/ is persistent.

Claude had previously saved a lot of memories to that graph, but they've since been erased. I had to ask him to recreate the file just now, to verify its creation in ./dist/. Maybe restarting the server with a new npx command clears the ./dist/ directory.

leependu avatar Apr 19 '25 22:04 leependu

Thanks. I found it and replaced it with a sym link pointing to the actual file in my Dropbox so that my memories can be accesses by Claude across multiple machines.

Seems like when memory server was running locally, it was storing here /Users/lamba/.npm/_npx/15b07286cbcc3329/node_modules/@modelcontextprotocol/server-memory/dist/memory.json When i installed it globally, it started storing here /usr/local/lib/node_modules/@modelcontextprotocol/server-memory/dist/memory.json

lamba avatar Apr 19 '25 23:04 lamba

I have the same issue, please deal with this bug

ruiwarn avatar Apr 22 '25 09:04 ruiwarn

所以这应该是个bug....我的天, 有没有其他memoryMCP代替品lol

kc0ed avatar Apr 22 '25 09:04 kc0ed

所以这应该是个bug....我的天, 有没有其他memoryMCP代替品lol

例如 https://github.com/doobidoo/mcp-memory-service

sascharo avatar Jun 04 '25 05:06 sascharo

In my case the memories being saved (not sure where) because Claude recalls those memories across sessions. But it's not clear where they are being stored. They are certainly not being stored in the location I specified.

I've also been unable to get my memory.json saved to the specified path. Here's my config:

    "memory": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-memory"
      ],
      "env": {
        "MEMORY_FILE_PATH": "C:\\Users\\taket\\Documents\\GitHub\\claude-memory\\memory.json"
      }
    },

It might be related to #1846, #1600, and #1018.

sascharo avatar Jun 04 '25 08:06 sascharo

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?

olaservo avatar Jun 07 '25 03:06 olaservo

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.

sascharo avatar Jun 07 '25 05:06 sascharo

Was this fixed? I can NOT confirm that it works with relative and absolute path on Windows: "MEMORY_FILE_PATH": "c:\\path\\to\\dir\\memory.json" I also expected to have something like this work: "MEMORY_FILE_PATH": "%USERPROFILE%\\memory.json" on Windows

Actually NOT:

Image

skynet avatar Aug 26 '25 20:08 skynet