Skip to content

memory: create_entities keeps repeated observations that add_observations would drop, then delete_observations reports "Deleted 2 of 1" #5653

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":["x","x"]}]}
  2. add_observations {"observations":[{"entityName":"A","contents":["y","y"]}]}
  3. open_nodes {"names":["A"]}
  4. delete_observations {"deletions":[{"entityName":"A","observations":["x"]}]}

Expected behavior

The two write paths treat a repeated observation the same way. Since #5201, add_observations stores a string repeated within one call once; create_entities should do the same, so step 3 returns ["x","y"] and step 4 reports Observations deleted successfully (1 of 1).

Actual behavior

The same repeated string is kept or dropped depending on which tool wrote it. A repro test (Python MCP client) is in https://github.com/za69956/mcp-memory-server-qa-audit (test_F1_...).

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. yjjnls commented on Nov 24, 2026

    @yjjnls

    Reproduced on both the published 2.2.1 package and current main (c799c85), driving the real stdio server with a Python MCP client on a fresh graph:

    • create_entities (A, observations ["x","x"]) stores and returns ["x","x"]
    • add_observations (["y","y"]) returns addedObservations: ["y"]
    • open_nodes returns "observations": ["x","x","y"]
    • delete_observations for ["x"] returns Deleted 2 of 1 observations.

    Root cause: createEntities pushes the requested entities unchanged (src/memory/index.ts:886-894), while addObservations normalizes with [...new Set(...)] first (src/memory/index.ts:955-958). deleteObservations counts removed array entries (src/memory/index.ts:1001), so the stored duplicate doubles the reported count.

    A one-line dedupe per new entity before the push fixes both symptoms:

    for (const e of newEntities) e.observations = [...new Set(e.observations)];

    In place, because skippedEntityNames (src/memory/index.ts:163) tells skipped entities apart by object identity (created.includes(e)); returning mapped copies instead would report every created entity as skipped. With that change the same repro returns ["x","y"] and Observations deleted successfully, and the memory suite passes (297/297).

  3. za69956 commented on Nov 24, 2026

    @za69956
    Author

    Thanks for reproducing this on both 2.2.1 and main, and for tracing it to the missing dedupe in createEntities. The point about skippedEntityNames relying on object identity is a good catch; a mapped-copy fix would have broken that silently.

    Are you planning to open a PR with the fix? If not, I'm happy to open one: your in-place dedupe plus a regression test covering

    1. create_entities with duplicate observations stores them once,
    2. delete_observations then reports the correct count.
      Credit to you for the root cause, of course.
  4. za69956 commented on Nov 24, 2026

    @za69956
    Author

    Correction to my earlier comment: I just re-read CONTRIBUTING.md and this repo accepts issues, not PRs, so I won't open one. The root cause and fix from @yjjnls above, plus the two regression cases I listed, should give the maintainers what they need.

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

    @cliffhall
    Member

    Triage: Priority Medium (total 6)

    • Severity 3: create_entities stores repeated observations that add_observations would drop, and delete_observations then reports deleting more than was asked
    • Urgency 2: wanted eventually, nothing blocked on it
    • Bonuses: +1 bug label

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

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