Skip to main content
Glama

delete_memory

Remove specific memory entries by their ID from the Memory MCP server. This tool ensures precise data management by permanently deleting selected memories.

Instructions

Delete a memory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesThe ID of the memory to delete

Implementation Reference

  • The core handler function implementing the delete_memory tool logic. It uses the DatabaseManager to delete the specified memory and returns a formatted success or error message.
    def delete_memory(memory_id: int) -> str: """ Delete a memory. Args: memory_id: The ID of the memory to delete Returns: A confirmation message """ try: success = db.delete_memory(memory_id) if success: return f"Memory {memory_id} deleted successfully." return f"Memory with ID {memory_id} not found." except Exception as e: return f"Error deleting memory: {str(e)}"
  • The input schema for the delete_memory tool, defining the required memory_id as an integer.
    types.Tool( name="delete_memory", description="Delete a memory.", inputSchema={ "type": "object", "properties": { "memory_id": { "type": "integer", "description": "The ID of the memory to delete", }, }, "required": ["memory_id"], "title": "deleteMemoryArguments", }, ),
  • The DatabaseManager.delete_memory helper method that performs the actual SQL deletion after existence check.
    def delete_memory(self, memory_id: int) -> bool: """Delete a memory by its ID.""" if not self.conn: self.initialize_db() if self.conn is None: raise RuntimeError("Database connection not available") # Check if memory exists if not self.get_memory_by_id(memory_id): return False self.conn.execute("DELETE FROM memories WHERE id = ?", (memory_id,)) self.conn.commit() return True
  • The dispatch handler in the MCP server's call_tool method that parses arguments and invokes the delete_memory function for the tool.
    elif name == "delete_memory": if not arguments or "memory_id" not in arguments: raise ValueError("Missing memory_id argument") memory_id = int(arguments["memory_id"]) result = delete_memory(memory_id) return [types.TextContent(type="text", text=result)]
  • The tool registration within the list_tools handler, where the delete_memory tool is defined and returned as part of available tools.
    return [ types.Tool( name="remember", description="Store a new memory.", inputSchema={ "type": "object", "properties": { "title": { "type": "string", "description": "A concise title for the memory", }, "content": { "type": "string", "description": "The full content of the memory to store", }, }, "required": ["title", "content"], "title": "rememberArguments", }, ), types.Tool( name="get_memory", description="Retrieve a specific memory by ID or title.", inputSchema={ "type": "object", "properties": { "memory_id": { "type": "integer", "description": "The ID of the memory to retrieve", }, "title": { "type": "string", "description": "The title of the memory to retrieve", }, }, "title": "getMemoryArguments", }, ), types.Tool( name="list_memories", description="List all stored memories.", inputSchema={ "type": "object", "properties": {}, "title": "listMemoriesArguments", }, ), types.Tool( name="update_memory", description="Update an existing memory.", inputSchema={ "type": "object", "properties": { "memory_id": { "type": "integer", "description": "The ID of the memory to update", }, "title": { "type": "string", "description": "Optional new title for the memory", }, "content": { "type": "string", "description": "Optional new content for the memory", }, }, "required": ["memory_id"], "title": "updateMemoryArguments", }, ), types.Tool( name="delete_memory", description="Delete a memory.", inputSchema={ "type": "object", "properties": { "memory_id": { "type": "integer", "description": "The ID of the memory to delete", }, }, "required": ["memory_id"], "title": "deleteMemoryArguments", }, ), ]

Other Tools

Related Tools

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/drdee/memory-mcp'

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