From 8a10f271f7e78318024e9505515783abfbea303a Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Wed, 3 Jun 2026 11:36:19 +0900 Subject: [PATCH] Memory MCP delete: match exact id, not prefix (#1303) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The delete action looked up the target with startswith() to capture full_id, but then re-applied startswith() to filter the list — so a short or ambiguous memory_id silently deleted every memory whose id shared the prefix, while the success message reported only the first match. The edit action used the first match and stopped, so the two actions disagreed on multi-match behaviour. Use full_id for both. Caught by #1303. --- mcp_servers/memory_server.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mcp_servers/memory_server.py b/mcp_servers/memory_server.py index c2812e1..1f226ad 100644 --- a/mcp_servers/memory_server.py +++ b/mcp_servers/memory_server.py @@ -161,10 +161,9 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]: deleted_text = m.get("text", "") deleted_category = m.get("category", "") break - original_len = len(memories) - memories = [m for m in memories if not m.get("id", "").startswith(memory_id)] - if len(memories) == original_len: + if not full_id: return [TextContent(type="text", text=f"Error: Memory '{memory_id}' not found")] + memories = [m for m in memories if m.get("id") != full_id] _memory_manager.save(memories) if _memory_vector and _memory_vector.healthy and full_id: try: