Skip to main content
Glama

delete_memory

Remove a specific stored conversation from the MITM proxy memory system by providing its unique ID, enabling users to manage their conversation history and maintain privacy.

Instructions

Delete a specific memory by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYes

Implementation Reference

  • MCP tool handler for 'delete_memory'. Registers the async function as an MCP tool and implements the logic by delegating to MemoryService.delete_memory, handling errors, and returning a success response.
    @mcp.tool(name="delete_memory", description="Delete a specific memory by ID")
    async def delete_memory(memory_id: str) -> dict[str, str]:
        """
        Permanently delete a specific memory by its ID.
    
        ## When to Use
    
        - User explicitly requests to forget something ("forget about...", "delete that memory")
        - Incorrect or misleading information was stored
        - Outdated memories that are no longer relevant
        - Privacy concerns or sensitive data removal
        - Cleaning up test or temporary memories
    
        ## Example Usage
    
        ```python
        # Delete after finding incorrect memory
        memories = await search_memories("API endpoint")
        # User: "That old endpoint is wrong, delete it"
        await delete_memory("mem_oldid456")
    
        # Delete outdated preference
        # User: "Actually, forget what I said about tabs vs spaces"
        await delete_memory("mem_tabpref789")
        ```
    
        ## Example Response
    
        ```json
        {
            "status": "deleted",
            "memory_id": "mem_oldid456",
            "message": "Memory successfully deleted"
        }
        ```
    
        ⚠️ **Caution**: Deletions are permanent and cannot be undone. Always confirm with the user if you're unsure about deleting a memory.
    
        Args:
            memory_id: The unique memory ID to delete (obtained from search_memories or list_memories)
    
        Returns:
            Confirmation dictionary containing:
            - status: "deleted" on success
            - memory_id: The ID that was deleted
            - message: Confirmation message
        """
        try:
            await memory_service.delete_memory(memory_id=memory_id)
            logger.info("Memory deleted", memory_id=memory_id)
            return {"status": "deleted", "memory_id": memory_id}
        except Exception as e:
            logger.error("Delete failed", error=str(e))
            raise RuntimeError(f"Delete failed: {str(e)}") from e
  • MemoryService.delete_memory method: the core implementation that calls the Mem0 AsyncMemoryClient.delete API to perform the actual memory deletion.
    async def delete_memory(self, memory_id: str) -> dict[str, Any]:
        """Delete a specific memory asynchronously.
    
        Args:
            memory_id: ID of the memory to delete
    
        Returns:
            Deletion response
        """
        try:
            self._logger.info("Deleting memory", memory_id=memory_id)
    
            result = await self.async_client.delete(memory_id=memory_id)
    
            self._logger.info("Memory deleted", memory_id=memory_id)
            return result
    
        except Exception as e:
            self._logger.error(
                "Failed to delete memory", memory_id=memory_id, error=str(e)
            )
            raise

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/terrymunro/mcp-mitm-mem0'

If you have feedback or need assistance with the MCP directory API, please join our Discord server