Skip to main content
Glama

open_memories

Retrieve specific memories by their IDs with detailed information including relations to other memories and decay scores for contextual recall.

Instructions

Retrieve specific memories by their IDs.

Similar to the reference MCP memory server's open_nodes functionality.
Returns detailed information about the requested memories including
their relations to other memories.

Args:
    memory_ids: Single memory ID or list of memory IDs to retrieve.
    include_relations: Include relations from/to these memories.
    include_scores: Include decay scores and age.

Returns:
    Detailed information about the requested memories with relations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_relationsNo
include_scoresNo
memory_idsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'open_memories' MCP tool. Decorated with @mcp.tool(), it retrieves memories by ID list, optionally includes relations and decay scores, supports pagination, validates inputs, and returns structured results.
    @mcp.tool()
    def open_memories(
        memory_ids: str | list[str],
        include_relations: bool = True,
        include_scores: bool = True,
        page: int | None = None,
        page_size: int | None = None,
    ) -> dict[str, Any]:
        """
        Retrieve specific memories by their IDs.
    
        Similar to the reference MCP memory server's open_nodes functionality.
        Returns detailed information about the requested memories including
        their relations to other memories.
    
        **Pagination:** When retrieving many memories by ID, results are paginated.
        Use `page` and `page_size` to navigate through the list of requested memories.
    
        Args:
            memory_ids: Single memory ID or list of memory IDs to retrieve (max 100 IDs).
            include_relations: Include relations from/to these memories.
            include_scores: Include decay scores and age.
            page: Page number to retrieve (1-indexed, default: 1).
            page_size: Number of memories per page (default: 10, max: 100).
    
        Returns:
            Dictionary with paginated results including:
            - memories: Detailed memory information for current page
            - not_found: List of IDs that weren't found
            - pagination: Metadata (page, page_size, total_count, total_pages, has_more)
    
        Examples:
            # Get first page of memories
            open_memories(["id1", "id2", "id3", ...], page=1, page_size=10)
    
            # Get next page
            open_memories(["id1", "id2", "id3", ...], page=2, page_size=10)
    
        Raises:
            ValueError: If any memory ID is invalid or list exceeds maximum length.
        """
        # Input validation
        ids = [memory_ids] if isinstance(memory_ids, str) else memory_ids
    
        if not isinstance(ids, list):
            raise ValueError(f"memory_ids must be a string or list, got {type(ids).__name__}")
    
        ids = validate_list_length(ids, MAX_LIST_LENGTH, "memory_ids")
        ids = [validate_uuid(mid, f"memory_ids[{i}]") for i, mid in enumerate(ids)]
    
        # Only validate pagination if explicitly requested
        pagination_requested = page is not None or page_size is not None
    
        memories = []
        not_found = []
        now = int(time.time())
    
        for memory_id in ids:
            memory = db.get_memory(memory_id)
            if memory is None:
                not_found.append(memory_id)
                continue
    
            mem_data: dict[str, Any] = {
                "id": memory.id,
                "content": memory.content,
                "entities": memory.entities,
                "tags": memory.meta.tags,
                "source": memory.meta.source,
                "context": memory.meta.context,
                "created_at": memory.created_at,
                "last_used": memory.last_used,
                "use_count": memory.use_count,
                "strength": memory.strength,
                "status": memory.status.value,
                "promoted_at": memory.promoted_at,
                "promoted_to": memory.promoted_to,
            }
    
            if include_scores:
                score = calculate_score(
                    use_count=memory.use_count,
                    last_used=memory.last_used,
                    strength=memory.strength,
                    now=now,
                )
                mem_data["score"] = round(score, 4)
                mem_data["age_days"] = round((now - memory.created_at) / 86400, 1)
    
            if include_relations:
                relations_from = db.get_relations(from_memory_id=memory_id)
                relations_to = db.get_relations(to_memory_id=memory_id)
                mem_data["relations"] = {
                    "outgoing": [
                        {
                            "to": r.to_memory_id,
                            "type": r.relation_type,
                            "strength": round(r.strength, 4),
                        }
                        for r in relations_from
                    ],
                    "incoming": [
                        {
                            "from": r.from_memory_id,
                            "type": r.relation_type,
                            "strength": round(r.strength, 4),
                        }
                        for r in relations_to
                    ],
                }
    
            memories.append(mem_data)
    
        # Apply pagination only if requested
        if pagination_requested:
            # Validate and get non-None values
            valid_page, valid_page_size = validate_pagination_params(page, page_size)
            paginated_memories = paginate_list(memories, page=valid_page, page_size=valid_page_size)
            return {
                "success": True,
                "count": len(paginated_memories.items),
                "memories": paginated_memories.items,
                "not_found": not_found,
                "pagination": paginated_memories.to_dict(),
            }
        else:
            # No pagination - return all memories
            return {
                "success": True,
                "count": len(memories),
                "memories": memories,
                "not_found": not_found,
            }
  • Package __init__.py imports and exports 'open_memories' in __all__, making it available for import from the tools package.
    from . import (
        analyze_for_recall,
        analyze_message,
        auto_recall_tool,
        backfill_embeddings,
        cluster,
        consolidate,
        create_relation,
        gc,
        open_memories,
        promote,
        read_graph,
        save,
        search,
        search_unified,
        touch,
    )
    
    __all__ = [
        "analyze_message",
        "analyze_for_recall",
        "auto_recall_tool",
        "backfill_embeddings",
        "save",
        "search",
        "touch",
        "gc",
        "promote",
        "cluster",
        "consolidate",
        "read_graph",
        "open_memories",
        "create_relation",
        "search_unified",
    ]
  • Server entrypoint imports 'open_memories' from tools package to trigger automatic registration via the @mcp.tool() decorator during module initialization.
    # Import tools to register them with the decorator
    from .tools import (
        analyze_for_recall,
        analyze_message,
        auto_recall_tool,
        cluster,
        consolidate,
        create_relation,
        gc,
        open_memories,
        performance,
        promote,
        read_graph,
        save,
        search,
        search_unified,
        touch,
    )
    
    # Explicitly reference imports to satisfy linters (these register MCP tools via decorators)
    _TOOL_MODULES = (
        analyze_for_recall,
        analyze_message,
        auto_recall_tool,
        cluster,
        consolidate,
        create_relation,
        gc,
        open_memories,
        performance,
        promote,
        read_graph,
        save,
        search,
        search_unified,
        touch,
    )
Behavior3/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. It discloses that the tool retrieves memories and returns detailed information with optional relations and scores, which covers basic behavior. However, it lacks details on potential side effects (e.g., whether this is a read-only operation), error handling, or performance aspects like rate limits. The description doesn't contradict annotations, but it's not comprehensive for a tool with no 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.

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose. The sentences are efficient, with no wasted words, and it includes a structured 'Args' and 'Returns' section for clarity. However, the reference to 'open_nodes functionality' could be considered slightly extraneous if not widely understood.

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 the tool has an output schema (which handles return values), no annotations, and 3 parameters with 0% schema coverage, the description does a good job of covering the basics. It explains the purpose, parameters, and return intent, making it largely complete for a retrieval tool. Minor gaps include lack of sibling differentiation and deeper behavioral context.

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?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'memory_ids' can be a single ID or list, 'include_relations' adds relations from/to memories, and 'include_scores' includes decay scores and age. This compensates well for the schema's lack of descriptions, though it doesn't fully detail all parameter nuances (e.g., format of IDs).

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 tool's purpose as 'Retrieve specific memories by their IDs' and 'Returns detailed information about the requested memories including their relations to other memories.' This specifies the verb (retrieve) and resource (memories) with scope (by IDs, with relations). However, it doesn't explicitly differentiate from sibling tools like 'read_graph' or 'search_memory' which might also retrieve memory information.

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 minimal usage guidance. It mentions 'Similar to the reference MCP memory server's open_nodes functionality,' which offers some context but is vague. There's no explicit guidance on when to use this tool versus alternatives like 'search_memory' or 'read_graph,' nor any mention of prerequisites or exclusions for usage.

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/prefrontal-systems/mnemex'

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