Skip to main content
Glama

get_memento

Retrieve stored memories by ID to access specific solutions, facts, or decisions from a persistent knowledge base, including related memories when needed.

Instructions

Retrieve a specific memento by ID.

Use when you have a memory_id from search results or store_memento. Set include_relationships=true (default) to see connected memories.

EXAMPLE: get_memento(memory_id="abc-123")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memory_idYesID of the memory to retrieve
include_relationshipsNoWhether to include related memories

Implementation Reference

  • The implementation of the get_memento tool handler in memory_tools.py.
    @handle_tool_errors("get memory")
    async def handle_get_memento(
        memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any]
    ) -> CallToolResult:
        """Handle get_memory tool call.
    
        Args:
            memory_db: Database instance for memory operations
            arguments: Tool arguments from MCP call containing:
                - memory_id: ID of memory to retrieve
                - include_relationships: Whether to include related memories (default: True)
    
        Returns:
            CallToolResult with formatted memory details or error message
        """
        memory_id = arguments["memory_id"]
        include_relationships = arguments.get("include_relationships", True)
    
        memory = await memory_db.get_memory(memory_id, include_relationships)
    
        if not memory:
            return CallToolResult(
                content=[TextContent(type="text", text=f"Memory not found: {memory_id}")],
                isError=True,
            )
    
        # Format memory for display
        memory_text = f"""**Memory: {memory.title}**
    Type: {memory.type.value}
    Created: {memory.created_at}
    Importance: {memory.importance}
    Tags: {", ".join(memory.tags) if memory.tags else "None"}
    
    **Content:**
    {memory.content}"""
    
        if memory.summary:
            memory_text = f"**Summary:** {memory.summary}\n\n" + memory_text
    
        # Add context information if available
        if memory.context:
            context_parts = []
    
            if memory.context.project_path:
                context_parts.append(f"Project: {memory.context.project_path}")
    
            if memory.context.files_involved:
                files_str = ", ".join(memory.context.files_involved[:3])
                if len(memory.context.files_involved) > 3:
                    files_str += f" (+{len(memory.context.files_involved) - 3} more)"
                context_parts.append(f"Files: {files_str}")
    
            if memory.context.languages:
                context_parts.append(f"Languages: {', '.join(memory.context.languages)}")
    
            if memory.context.frameworks:
                context_parts.append(f"Frameworks: {', '.join(memory.context.frameworks)}")
    
            if memory.context.technologies:
                context_parts.append(
                    f"Technologies: {', '.join(memory.context.technologies)}"
                )
    
            if memory.context.git_branch:
                context_parts.append(f"Branch: {memory.context.git_branch}")
    
            if context_parts:
                context_text = "\n**Context:**\n" + "\n".join(
                    f"  {part}" for part in context_parts
                )
                memory_text += "\n" + context_text
    
        # Add relationships section if requested
        if include_relationships:
            related = await memory_db.get_related_memories(memory_id, max_depth=1)
    
            if related:
                memory_text += "\n\n**Relationships:**"
    
                by_type: dict = {}
                for rel_memory, relationship in related:
                    rel_type = relationship.type.value if relationship and hasattr(relationship, "type") else "RELATED_TO"
                    if rel_type not in by_type:
                        by_type[rel_type] = []
                    by_type[rel_type].append(
                        f"{rel_memory.title} (ID: {rel_memory.id})"
                    )
    
                for rel_type, entries in sorted(by_type.items()):
                    memory_text += f"\n  {rel_type}:"
                    for entry in entries:
                        memory_text += f"\n    - {entry}"
    
        return CallToolResult(content=[TextContent(type="text", text=memory_text)])

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/annibale-x/mcp-memento'

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