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

Method _persistent_clear

src/mcp_cli/commands/memory/memory.py:511–538  ·  view source on GitHub ↗

Clear all persistent memories in a scope.

(self, chat_context: Any, action: str)

Source from the content-addressed store, hash-verified

509 return CommandResult(success=True)
510
511 def _persistent_clear(self, chat_context: Any, action: str) -> CommandResult:
512 """Clear all persistent memories in a scope."""
513 from mcp_cli.memory.models import MemoryScope
514
515 store = self._get_store(chat_context)
516 if not store:
517 return CommandResult(success=False, error="Memory store not available.")
518
519 # Parse: clear <scope>
520 parts = action.split(maxsplit=1)
521 if len(parts) < 2:
522 return CommandResult(
523 success=False,
524 error="Usage: /memory clear <workspace|global>",
525 )
526
527 try:
528 scope = MemoryScope(parts[1])
529 except ValueError:
530 return CommandResult(
531 success=False,
532 error=f"Invalid scope: {parts[1]}. Use 'workspace' or 'global'.",
533 )
534
535 count = store.clear(scope)
536 chat_context._system_prompt_dirty = True
537 output.success(f"Cleared {count} memories from {scope.value} scope.")
538 return CommandResult(success=True)

Callers 1

executeMethod · 0.95

Calls 5

_get_storeMethod · 0.95
CommandResultClass · 0.90
MemoryScopeClass · 0.90
successMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected