MCPcopy Create free account
hub / github.com/IBM/mcp-cli / remember

Method remember

src/mcp_cli/memory/store.py:49–74  ·  view source on GitHub ↗

Store or update a memory entry (upsert by key).

(self, scope: MemoryScope, key: str, content: str)

Source from the content-addressed store, hash-verified

47 # ------------------------------------------------------------------
48
49 def remember(self, scope: MemoryScope, key: str, content: str) -> MemoryEntry:
50 """Store or update a memory entry (upsert by key)."""
51 with self._lock:
52 data = self._load(scope)
53 now = datetime.now(timezone.utc)
54
55 # Upsert
56 for entry in data.entries:
57 if entry.key == key:
58 entry.content = content
59 entry.updated_at = now
60 self._save(scope, data)
61 return entry
62
63 # New entry — enforce max
64 if len(data.entries) >= self._max_entries:
65 # Evict oldest by updated_at
66 data.entries.sort(key=lambda e: e.updated_at)
67 data.entries.pop(0)
68
69 entry = MemoryEntry(
70 key=key, content=content, created_at=now, updated_at=now
71 )
72 data.entries.append(entry)
73 self._save(scope, data)
74 return entry
75
76 def recall(
77 self,

Callers 15

test_truncationMethod · 0.95
test_global_sharedMethod · 0.95
test_evicts_oldestMethod · 0.95
test_survives_reloadMethod · 0.95
_persistent_addMethod · 0.80
handle_memory_toolFunction · 0.80
test_recall_allMethod · 0.80
test_recall_by_keyMethod · 0.80
test_recall_by_queryMethod · 0.80

Calls 3

_loadMethod · 0.95
_saveMethod · 0.95
MemoryEntryClass · 0.90

Tested by 15

test_truncationMethod · 0.76
test_global_sharedMethod · 0.76
test_evicts_oldestMethod · 0.76
test_survives_reloadMethod · 0.76
test_recall_allMethod · 0.64
test_recall_by_keyMethod · 0.64
test_recall_by_queryMethod · 0.64
test_forget_existingMethod · 0.64
test_creates_entryMethod · 0.64