Skip to main content
Glama

add_memory

Store information like facts, preferences, or events in MemoVault's long-term memory system for persistence across sessions.

Instructions

Store new information in memory.

Use this to remember facts, preferences, events, or any important information the user wants to persist across sessions.

Args: content: The information to remember memory_type: Optional type (fact, preference, event, opinion, procedure, personal)

Returns: Confirmation message with the memory ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
memory_typeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler function that implements add_memory. Decorated with @self.mcp.tool(), it accepts content and optional memory_type, creates a memory item with metadata, and returns a confirmation message with the memory ID.
    async def add_memory(content: str, memory_type: str | None = None) -> str:
        """Store new information in memory.
    
        Use this to remember facts, preferences, events, or any important
        information the user wants to persist across sessions.
    
        Args:
            content: The information to remember
            memory_type: Optional type (fact, preference, event, opinion, procedure, personal)
    
        Returns:
            Confirmation message with the memory ID
        """
        try:
            metadata = {}
            if memory_type:
                metadata["type"] = memory_type
    
            ids = self.vault.add(content, **metadata)
            return f"Memory stored successfully (ID: {ids[0]})"
        except Exception as e:
            logger.error(f"Error adding memory: {e}")
            return f"Error storing memory: {str(e)}"
  • Pydantic BaseModel defining the AddMemoryRequest schema with content (required string), type (optional string), and tags (optional string list) fields for input validation.
    class AddMemoryRequest(BaseModel):
        """Request to add a memory."""
    
        content: str = Field(..., description="Memory content to add")
        type: str | None = Field(default=None, description="Memory type")
        tags: list[str] | None = Field(default=None, description="Memory tags")
  • The _setup_tools() method where add_memory is registered as an MCP tool. The @self.mcp.tool() decorator at line 39 registers the function with the FastMCP framework.
    def _setup_tools(self):
        """Set up MCP tools."""
    
        @self.mcp.tool()
        async def add_memory(content: str, memory_type: str | None = None) -> str:
            """Store new information in memory.
    
            Use this to remember facts, preferences, events, or any important
            information the user wants to persist across sessions.
    
            Args:
                content: The information to remember
                memory_type: Optional type (fact, preference, event, opinion, procedure, personal)
    
            Returns:
                Confirmation message with the memory ID
            """
            try:
                metadata = {}
                if memory_type:
                    metadata["type"] = memory_type
    
                ids = self.vault.add(content, **metadata)
                return f"Memory stored successfully (ID: {ids[0]})"
            except Exception as e:
                logger.error(f"Error adding memory: {e}")
                return f"Error storing memory: {str(e)}"
  • The core MemoVault.add() method that performs the actual memory addition. It normalizes input to MemoryItem objects and delegates to the MemCube for storage, returning a list of memory IDs.
    def add(
        self,
        content: str | list[str] | MemoryItem | list[MemoryItem],
        **metadata: Any,
    ) -> list[str]:
        """Add memories.
    
        Args:
            content: Memory content (string, list of strings, or MemoryItem).
            **metadata: Additional metadata to attach to memories.
    
        Returns:
            List of memory IDs that were added.
    
        Example:
            >>> mem.add("I prefer dark mode")
            >>> mem.add(["Fact 1", "Fact 2"], type="fact")
        """
        # Normalize input to list
        if isinstance(content, str):
            items = [MemoryItem(memory=content, metadata=metadata)]
        elif isinstance(content, MemoryItem):
            items = [content]
        elif isinstance(content, list):
            items = []
            for item in content:
                if isinstance(item, str):
                    items.append(MemoryItem(memory=item, metadata=metadata))
                elif isinstance(item, MemoryItem):
                    items.append(item)
                else:
                    items.append(MemoryItem(**item))
        else:
            items = [MemoryItem(**content)]
    
        return self._cube.add(items)
Behavior3/5

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

With no annotations, the description carries full burden. It discloses that it 'stores' (a write operation) and persists 'across sessions', but lacks details on permissions, rate limits, or error handling. It adds some context (persistence scope) but misses behavioral traits like idempotency or side effects.

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?

Front-loaded with purpose, followed by usage guidelines, args, and returns in a structured format. Every sentence adds value with no redundancy, efficiently covering key aspects in minimal text.

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

Completeness4/5

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

Given 2 parameters, no annotations, and an output schema (returns confirmation with ID), the description is mostly complete. It covers purpose, usage, params, and returns, but lacks behavioral details like error cases or persistence guarantees, which are important for a write tool.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It explains 'content' as 'information to remember' and 'memory_type' with optional values (fact, preference, etc.), adding meaning beyond the bare schema. However, it doesn't detail format constraints or examples for 'content'.

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

Purpose5/5

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

The description clearly states the verb 'store' and resource 'information in memory', specifying it's for persisting facts, preferences, events, etc. It distinguishes from siblings like 'clear_memories' (deletion) or 'get_memory' (retrieval) by focusing on creation/persistence.

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

Usage Guidelines4/5

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

It provides clear context on when to use ('to remember facts, preferences, events... across sessions'), but doesn't explicitly state when not to use or name alternatives like 'update_memory' if such a tool existed. It implies usage for persistence needs.

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

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/Blvckjs96/MemoVault'

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