Skip to content

memory: delete_relations / delete_observations count a repeated request item as "matched nothing" #5655

Done

Description

@za69956

Which server?

memory (@modelcontextprotocol/server-memory)

Server version

2.2.1 (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 client on the Python MCP SDK (mcp, ClientSession over stdio)

Operating system and runtime

Linux, Node v22.23.4

Server configuration

node node_modules/@modelcontextprotocol/server-memory/dist/index.js (package installed from npm, 2.2.1), env MEMORY_FILE_PATH=<empty temp dir>/m.jsonl, stdio.

Steps to reproduce

Fresh, empty graph.

  1. create_entities {"entities":[{"name":"A","entityType":"t","observations":["y"]},{"name":"B","entityType":"t","observations":[]}]}
  2. create_relations {"relations":[{"from":"A","to":"B","relationType":"knows"}]}
  3. delete_relations with the same relation listed twice: {"relations":[{"from":"A","to":"B","relationType":"knows"},{"from":"A","to":"B","relationType":"knows"}]}
  4. delete_observations {"deletions":[{"entityName":"A","observations":["y","y"]}]}

Expected behavior

Both items in each request match the one existing record, so the result should not say any of them missed. Either count unique request items (Relations deleted successfully, Observations deleted successfully), or say it plainly, e.g. Deleted 1 relation (1 repeated item ignored).

Actual behavior

  • Step 3: Deleted 1 of 2 relations. The rest matched nothing.
  • Step 4: Deleted 1 of 2 observations.

"The rest matched nothing" is false: the second item matched the same relation as the first. An agent reading the partial-failure wording may retry, or tell the user that part of the deletion failed. The graph itself ends up correct. A repro test (Python MCP client) is in https://github.com/za69956/mcp-memory-server-qa-audit (test_F3_...).

Logs or error output


Already prototyped a fix?

No response

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
    on Nov 24, 2026
  2. Shanmukh-l33t commented on Nov 24, 2026

    @Shanmukh-l33t

    Root cause: in src/memory/index.ts, the delete_relations and delete_observations handlers compare the number of records actually removed with the raw length of the request (relations.length, and the sum of observations.length). A repeated item matches the same stored record, so the removed count is 1 while the request count is 2, and the message reports a miss that did not happen. The graph itself is correct; only the message is wrong.

    Suggested change, as a prompt for the maintainer workflow, per CONTRIBUTING:

    In src/memory/index.ts, make the delete_relations and delete_observations tool handlers compare deletedCount with the number of distinct requested items instead of the raw request length. Distinct means unique (from, to, relationType) for relations and unique (entityName, observation) pairs for observations, so the same item listed twice, in one entry or across entries, counts once. Keep the response shape and wording unchanged, including the "Deleted N of M ..." partial form. Add tests in src/memory/tests/tools.test.ts: a repeated relation or observation alone returns the "deleted successfully" message, and a repeated item mixed with a nonexistent one returns "Deleted 1 of 2 ...".

    I verified this locally against current main (c799c85): the four new tests fail before the change (4 failed, 41 passed in npx vitest run __tests__/tools.test.ts) and pass after it (45 passed), and tsc -p tsconfig.test.json is clean. I am not opening a PR, in line with the issues-only policy.

  3. za69956 commented on Nov 24, 2026

    @za69956
    Author

    Thanks @Shanmukh-l33t, that matches what I saw: the graph is fine and only the message is off. Counting distinct requested items keeps the response shape unchanged, which is the right call. Your two extra cases (repeated item alone, and mixed with a nonexistent one) are worth keeping in the eventual fix.

  4. added
    server-memory
    on Nov 30, 2026
  5. cliffhall commented on Nov 30, 2026

    @cliffhall
    Member

    Triage: Priority Low (total 5)

    • Severity 2: the delete result message reports a miss for a repeated request item; the graph itself is correct
    • Urgency 2: wanted eventually, nothing blocked on it
    • Bonuses: +1 bug label

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

  6. added this to the v2.7.0 milestone on Nov 30, 2026
  7. self-assigned this
    on Nov 30, 2026
  8. added a commit that references this issue 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