Skip to content

memory: write tools fail with raw lock-file ENOENT when MEMORY_FILE_PATH's parent directory does not exist, while read tools silently return an empty graph #5689

Done

Description

@MicroMilo

Which server?

memory (@modelcontextprotocol/server-memory)

Server version

2.2.2 (npm)

How did you run the server?

npx (npm package)

Transport

stdio

Protocol era

Legacy (2025-11-25 or earlier)

MCP client and version

Custom Python JSON-RPC stdio client (mcpfuse test harness)

Operating system and runtime

macOS 26.3.2, Node v25.9.0

Server configuration

MEMORY_FILE_PATH=/tmp/mem-repro/missing_dir/memory.jsonl \
  npx -y @modelcontextprotocol/server-memory@2.2.2

(where /tmp/mem-repro/missing_dir does not exist yet)

Steps to reproduce

  1. Ensure /tmp/mem-repro/missing_dir does not exist.
  2. Start the server with MEMORY_FILE_PATH=/tmp/mem-repro/missing_dir/memory.jsonl.
  3. Call read_graph with {}.
  4. Call create_entities with:
    {
      "entities": [
        { "name": "Alice", "entityType": "person", "observations": ["hi"] }
      ]
    }
    (The same error occurs for every write tool: create_relations, add_observations, delete_entities, delete_observations, delete_relations.)

Expected behavior

Consistent, user-friendly handling across read and write tools when MEMORY_FILE_PATH's parent directory does not exist: either create the missing parent directory on first write (e.g., fs.mkdir(path.dirname(memoryFilePath), { recursive: true }) before acquiring the lock), or fail cleanly at startup/call time with an actionable message naming MEMORY_FILE_PATH rather than leaking an internal .lock file path.

Actual behavior

  1. read_graph (and open_nodes / search_nodes) silently succeeds with {"entities": [], "relations": []} because loadGraphWithUnreadable() treats ENOENT as an empty graph — giving the client/model the impression that the store is ready.
  2. Every write tool then fails immediately inside withFileLock() (src/memory/index.ts, fs.open(lockPath, "wx")) with a raw Node filesystem error exposing the internal sibling lock path:
    ENOENT: no such file or directory, open '/tmp/mem-repro/missing_dir/memory.jsonl.lock'.

Logs or error output

Step 1 (read_graph): isError=false
{
  "entities": [],
  "relations": []
}

Step 2 (create_entities): isError=true
ENOENT: no such file or directory, open '/tmp/mem-repro/missing_dir/memory.jsonl.lock'

Already prototyped a fix?

Per CONTRIBUTING.md (issues-only policy), I am not opening a pull request. Related context: lock-file management in #5485 / #5565, and a similar raw-ENOENT fix in filesystem (#5432).

Suggested prompt for fixing this:

In src/memory/index.ts, handle the case where MEMORY_FILE_PATH's parent directory does not exist consistently between read and write tools. Either ensure the parent directory exists (fs.mkdir(path.dirname(this.memoryFilePath), { recursive: true })) before withFileLock acquires ${this.memoryFilePath}.lock, or if creating directories automatically is undesirable, catch ENOENT on fs.open(lockPath, "wx") and throw a clear, actionable error explaining that the parent directory of MEMORY_FILE_PATH does not exist (without exposing the internal .lock path). Add unit tests covering read_graph and write tools when the parent directory of MEMORY_FILE_PATH is missing.

Before you submit

  • I searched existing issues and this is not a duplicate.
  • This is not a security vulnerability report (those go through the private advisory form).

Activity

  1. added
    bug
    server-memory
    on Nov 30, 2026
  2. cliffhall commented on Nov 30, 2026

    @cliffhall
    Member

    Triage: Priority Low (total 5)

    • Severity 2: a raw lock-file ENOENT instead of an actionable error when the parent directory of MEMORY_FILE_PATH is missing; creating the directory works around it
    • Urgency 2: wanted eventually, nothing blocked on it
    • Bonuses: +1 bug label

    Board: Servers V2 (#43), Status Incoming, awaiting maintainer review (no milestone yet).

  3. added this to the v2.7.0 milestone on Nov 30, 2026
  4. self-assigned this
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugserver-memoryv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions