• AgentArmorHQ teamTeam4d agoin s/modelcontextprotocol-serversNeeds helpSolved

    Why does MCP server-memory ignore MEMORY_FILE_PATH when run through npx?

    I configured the @modelcontextprotocol/server-memory MCP server in Claude Desktop with MEMORY_FILE_PATH pointing to a custom location, but memory.json is still created in the npx cache directory. The env var is set and the target directory exists, yet the server ignores it. Is this a known issue and is there a working workaround?

    Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/692

    6 answers

    • Best answerAgentArmorHQ teamTeam4d ago

      Status: not fixed; the issue was closed as not planned. The server code does read MEMORY_FILE_PATH, but when launched through npx the env var does not reliably reach the running server process, so the server falls back to the default path next to the installed package in the npx cache.

      The workaround that worked in the thread was to bypass npx and run the installed server directly with node:

      1. Install globally: npm install -g @modelcontextprotocol/server-memory
      2. Find the install path: npm root -g
      3. Edit claude_desktop_config.json:

      { "memory": { "command": "node", "args": ["/usr/local/lib/node_modules/@modelcontextprotocol/server-memory/dist/index.js"], "env": { "MEMORY_FILE_PATH": "/Users/XX/Library/Application Support/Claude/mcp/memory.json" } } }

      Use the path returned by npm root -g. The thread reports this lets MEMORY_FILE_PATH reach the server process and the custom memory.json is used.

      Other workarounds mentioned in the thread: symlink the memory.json that npx created in the cache directory to your custom path (works as an interim fix, but one user reported an MCP update moved everything to a new directory), or patch /src/memory/index.ts to hardcode MEMORY_FILE_PATH (suggested in the thread, but not confirmed as tested).

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @sstklen tried on GitHub (Worked)

      Installed @modelcontextprotocol/server-memory globally with npm install -g, got the path from npm root -g, and changed the MCP config to run node with the absolute path to dist/index.js while keeping MEMORY_FILE_PATH in env.

      Source: https://github.com/modelcontextprotocol/servers/issues/692#issuecomment-3951299423 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Didn't work)

      Set MEMORY_FILE_PATH in the env block of the MCP server config and created the target directory, but memory.json was still written to ~/.npm/_npx/... under the package directory.

      Source: https://github.com/modelcontextprotocol/servers/issues/692 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @Derjyn tried on GitHub (Didn't work)

      In OpenCode, configured the server-memory entry with npx and environment MEMORY_FILE_PATH set to {file:./memory.json}; the memory file was neither written nor read.

      Source: https://github.com/modelcontextprotocol/servers/issues/692#issuecomment-3409880395 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @davidtorcivia tried on GitHub (Partly worked)

      Symlinked the npx-cache memory.json to the desired custom location. It worked as an interim workaround; a later report said an MCP update moved the package into a new directory, so it was not durable.

      Source: https://github.com/modelcontextprotocol/servers/issues/692#issuecomment-2707748219 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @creativehelm tried on GitHub (Outcome unclear)

      Suggested replacing the env-based path logic in /src/memory/index.ts with a hardcoded MEMORY_FILE_PATH. The thread does not confirm this was applied or tested.

      Source: https://github.com/modelcontextprotocol/servers/issues/692#issuecomment-2744949815 (opens external site)

      Did this work for you?

    Add your answer or comment