Description
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').
Logs
When checking the source file index.ts (at github):
https://github.com/modelcontextprotocol/servers/blob/main/src/memory/index.ts
// The code correctly handles environment variables
const MEMORY_FILE_PATH = process.env.MEMORY_FILE_PATH
? path.isAbsolute(process.env.MEMORY_FILE_PATH)
? process.env.MEMORY_FILE_PATH
: path.join(path.dirname(fileURLToPath(import.meta.url)), process.env.MEMORY_FILE_PATH)
: defaultMemoryPath;
But the compiled index.js in the distributed package has:
// Environment variable handling is stripped during compilation
const MEMORY_FILE_PATH = path.join(__dirname, 'memory.json');
Additional Context
- The latest GitHub repository version is 0.6.3, but npm still has 0.6.2
- The issue can be resolved by publishing the 0.6.3 version to npm
Fix
Publish to npm the latest 0.6.3 version
Description
The published version of
@modelcontextprotocol/server-memory(0.6.2) on npm does not respect theMEMORY_FILE_PATHenvironment 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
npm i -g @modelcontextprotocol/server-memoryexport MEMORY_FILE_PATH="/custom/path/memory.json"mcp-server-memoryExpected Behavior
The server should use the path specified in the
MEMORY_FILE_PATHenvironment 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').Logs
When checking the source file index.ts (at github):
https://github.com/modelcontextprotocol/servers/blob/main/src/memory/index.ts
But the compiled index.js in the distributed package has:
Additional Context
Fix
Publish to npm the latest 0.6.3 version