Skip to main content
Glama
drdee

Memory MCP

by drdee

get_memory

Retrieve specific memories by ID or title using the Memory MCP server. Access stored data efficiently for quick retrieval and management.

Instructions

Retrieve a specific memory by ID or title.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idNoThe ID of the memory to retrieve
titleNoThe title of the memory to retrieve

Implementation Reference

  • The primary handler function implementing the get_memory tool logic. It retrieves a memory from the database by ID or title and returns a formatted text response.
    def get_memory(memory_id: Optional[int] = None, title: Optional[str] = None) -> str:
        """
        Retrieve a specific memory by ID or title.
    
        Args:
            memory_id: The ID of the memory to retrieve
            title: The title of the memory to retrieve
    
        Returns:
            The memory content or an error message
        """
        try:
            if memory_id is not None:
                memory = db.get_memory_by_id(int(memory_id))
            elif title is not None:
                memory = db.get_memory_by_title(title)
            else:
                return "Error: Please provide either a memory_id or title."
    
            if memory:
                return f"Title: {memory['title']}\n\nContent: {memory['content']}"
            return "Memory not found."
        except Exception as e:
            return f"Error retrieving memory: {str(e)}"
  • The input schema definition for the get_memory tool, allowing optional memory_id (integer) or title (string).
    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",
        },
    ),
  • The dispatch logic in the call_tool handler that invokes the get_memory function with parsed arguments.
    elif name == "get_memory":
        if not arguments:
            raise ValueError("Missing arguments")
        memory_id = arguments.get("memory_id")
        title = arguments.get("title")
        result = get_memory(memory_id, title)
        return [types.TextContent(type="text", text=result)]
  • Database helper method to fetch memory by ID from SQLite.
    def get_memory_by_id(self, memory_id: int) -> Optional[Dict[str, Any]]:
        """Retrieve a memory by its ID."""
        if not self.conn:
            self.initialize_db()
    
        if self.conn is None:
            raise RuntimeError("Database connection not available")
    
        cursor = self.conn.execute(
            "SELECT id, title, content, created_at, updated_at FROM memories WHERE id = ?",
            (memory_id,),
        )
        row = cursor.fetchone()
    
        if row:
            return {
                "id": row[0],
                "title": row[1],
                "content": row[2],
                "created_at": row[3],
                "updated_at": row[4],
            }
        return None
  • Database helper method to fetch memory by title from SQLite.
    def get_memory_by_title(self, title: str) -> Optional[Dict[str, Any]]:
        """Retrieve a memory by its title."""
        if not self.conn:
            self.initialize_db()
    
        if self.conn is None:
            raise RuntimeError("Database connection not available")
    
        cursor = self.conn.execute(
            "SELECT id, title, content, created_at, updated_at FROM memories WHERE title = ?",
            (title,),
        )
        row = cursor.fetchone()
    
        if row:
            return {
                "id": row[0],
                "title": row[1],
                "content": row[2],
                "created_at": row[3],
                "updated_at": row[4],
            }
        return None
Behavior2/5

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

With no annotations, the description carries full burden but lacks behavioral details. It states the tool retrieves but doesn't disclose error handling (e.g., if memory doesn't exist), authentication needs, rate limits, or return format. The description is minimal and doesn't compensate for the absence of annotations, leaving key operational traits unclear.

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 a single, efficient sentence that front-loads the core action ('Retrieve a specific memory') and adds necessary qualification ('by ID or title'). There is zero waste, and every word earns its place, making it appropriately sized for a simple retrieval tool.

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 the tool's moderate complexity (retrieval with two parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like error cases or return values, leaving gaps that could hinder an AI agent's ability to use it correctly. More context is needed for a retrieval operation.

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%, so the schema already documents both parameters ('memory_id' and 'title') fully. The description adds no extra meaning beyond implying these are alternative lookup methods, but doesn't explain exclusivity, precedence, or format details. This meets the baseline of 3 when schema coverage is high.

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

Purpose4/5

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

The description clearly states the action ('Retrieve') and resource ('a specific memory'), and specifies the lookup methods ('by ID or title'). It distinguishes from siblings like 'list_memories' (which retrieves multiple) and 'delete_memory'/'update_memory' (which modify). However, it doesn't explicitly contrast with 'remember' (which likely creates memories), keeping it from a perfect 5.

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. It doesn't mention prerequisites (e.g., needing an existing memory), exclusions (e.g., not for bulk retrieval), or direct comparisons to siblings like 'list_memories' for multiple memories or 'remember' for creation. Usage is implied but not articulated.

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