Skip to content

Memory Server not adding to JSON Array #1481

Closed as not planned
Closed as not planned

Description

@bbarrington0099

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.

Activity

  1. lamba commented on Apr 19, 2025

    @lamba

    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"
          ]
        }
      }
    }
    
    
    
  2. leependu commented on Apr 19, 2025

    @leependu

    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.

  3. lamba commented on Apr 19, 2025

    @lamba

    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

  4. ruiwarn commented on Apr 22, 2025

    @ruiwarn

    I have the same issue, please deal with this bug

  5. kc0ed commented on Apr 22, 2025

    @kc0ed

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

  6. added
    server-memoryReference implementation for the Memory MCP server - src/memory
    on Apr 26, 2025
  7. sascharo commented on Jun 4, 2025

    @sascharo

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

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

  8. sascharo commented on Jun 4, 2025

    @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.

  9. olaservo commented on Jun 7, 2025

    @olaservo
    Member

    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?

  10. sascharo commented on Jun 7, 2025

    @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?

    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.

  11. skynet commented on Aug 26, 2025

    @skynet

    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
  12. ferhimedamine commented on Jun 12, 2026

    @ferhimedamine
  13. olaservo commented on Sep 3, 2026

    @olaservo
    Member

    The memory file is JSON Lines by design: one JSON object per line, not a JSON array (9d8c2dfc changed the default filename to memory.jsonl to make that explicit). Reading it with a plain JSON parser will fail as described. Windows absolute paths in MEMORY_FILE_PATH work; %USERPROFILE% does not because the server does not expand shell variables, and ~ expansion is proposed in #4447. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserver-memoryReference implementation for the Memory MCP server - src/memory

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions