delete_memory
Remove outdated or irrelevant memory files upon user request to ensure accurate data retrieval and project relevance. Part of the Serena MCP server.
Instructions
Delete a memory file. Should only happen if a user asks for it explicitly, for example by saying that the information retrieved from a memory file is no longer correct or no longer relevant for the project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memory_file_name | Yes |
Implementation Reference
- src/serena/tools/memory_tools.py:55-66 (handler)The apply method in DeleteMemoryTool implements the core logic of the 'delete_memory' MCP tool by calling the memories_manager's delete_memory method.class DeleteMemoryTool(Tool): """ Deletes a memory from Serena's project-specific memory store. """ def apply(self, memory_file_name: str) -> str: """ Delete a memory file. Should only happen if a user asks for it explicitly, for example by saying that the information retrieved from a memory file is no longer correct or no longer relevant for the project. """ return self.memories_manager.delete_memory(memory_file_name)
- src/serena/project.py:51-54 (helper)The delete_memory method in MemoriesManager performs the actual file deletion of the memory file and returns a confirmation message. This is called by the tool handler.def delete_memory(self, name: str) -> str: memory_file_path = self.get_memory_file_path(name) memory_file_path.unlink() return f"Memory {name} deleted."
- src/serena/tools/tools_base.py:129-130 (registration)The get_name method derives the tool name 'delete_memory' from the class name DeleteMemoryTool.return self.get_name_from_cls()
- src/serena/tools/tools_base.py:362-370 (registration)ToolRegistry automatically registers all Tool subclasses in serena.tools modules, including DeleteMemoryTool as 'delete_memory'.for cls in iter_subclasses(Tool): if not cls.__module__.startswith("serena.tools"): continue is_optional = issubclass(cls, ToolMarkerOptional) name = cls.get_name_from_cls() if name in self._tool_dict: raise ValueError(f"Duplicate tool name found: {name}. Tool classes must have unique names.") self._tool_dict[name] = RegisteredTool(tool_class=cls, is_optional=is_optional, tool_name=name)