Skip to main content
Glama
drdee

Memory MCP

by drdee

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",
            },
        ),
    ]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Delete a memory' implies a destructive, irreversible mutation, but it doesn't specify permissions required, whether deletion is permanent or recoverable, error handling (e.g., if memory_id doesn't exist), or side effects. This is a significant gap for a destructive tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at three words, with zero wasted text. It's front-loaded with the core action, making it easy to parse quickly. Every word earns its place by directly stating the tool's function without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a destructive mutation tool with no annotations and no output schema, the description is incomplete. It doesn't address critical context like what happens post-deletion (e.g., confirmation message, error responses), prerequisites, or how it differs from sibling tools. The agent lacks sufficient information to use this tool safely and effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'memory_id' clearly documented in the schema as 'The ID of the memory to delete'. The description adds no additional meaning beyond this, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Delete a memory' clearly states the verb (delete) and resource (memory), making the basic purpose understandable. However, it doesn't differentiate this tool from its sibling 'update_memory' which could also modify memory state, nor does it specify what type of memory is being deleted (e.g., user memory, system memory, cached data). It's adequate but vague about scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_memory', 'list_memories', 'remember', and 'update_memory', there's no indication of when deletion is appropriate (e.g., after retrieval, as cleanup, or for specific memory types). The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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