Skip to main content
Glama

list_memories

Retrieve stored conversation histories from the MCP MITM Mem0 server to review past interactions and maintain context across sessions.

Instructions

List all stored conversation memories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNo

Implementation Reference

  • The handler function for the list_memories tool, registered via @mcp.tool decorator. It retrieves all memories by calling the memory_service helper.
    @mcp.tool(name="list_memories", description="List all stored conversation memories") async def list_memories(user_id: str | None = None) -> list[dict[str, Any]]: """ List all memories for a user, providing a complete conversation history. ## When to Use - User wants to see their complete conversation history - You need to browse through all memories - Performing a comprehensive review or audit - Search didn't find specific memories - Getting an overview of all stored conversations ## Example Usage ```python # List all memories for default user memories = await list_memories() # List memories for specific user memories = await list_memories(user_id="alice@example.com") ``` ## Example Response ```json [ { "id": "mem_xyz789", "memory": "Discussion about implementing OAuth2 with refresh tokens...", "created_at": "2024-01-20T14:30:00Z", "metadata": {"type": "conversation", "topic": "authentication"} }, { "id": "mem_abc123", "memory": "User mentioned preferring PostgreSQL over MySQL...", "created_at": "2024-01-19T09:15:00Z", "metadata": {"type": "preference"} } ] ``` Note: This returns ALL memories. For large histories, prefer search_memories() for specific topics. Args: user_id: User ID (optional, defaults to DEFAULT_USER_ID from settings) Returns: List of all memories sorted by creation date (newest first), each containing: - id: Unique memory identifier - memory/content: The stored conversation text - created_at: ISO timestamp of memory creation - metadata: Additional context """ try: results = await memory_service.get_all_memories(user_id=user_id) logger.info("Memory list retrieved", memory_count=len(results)) return results except Exception as e: logger.error("List failed", error=str(e)) raise RuntimeError(f"List failed: {str(e)}") from e
  • The MemoryService.get_all_memories method that implements the core logic for listing memories using the Mem0 AsyncMemoryClient.
    async def get_all_memories( self, user_id: str | None = None ) -> list[dict[str, Any]]: """Get all memories for a user asynchronously. Args: user_id: User identifier (defaults to settings.default_user_id) Returns: List of all memories for the user """ user_id = user_id or settings.default_user_id try: self._logger.info("Getting all memories", user_id=user_id) results = await self.async_client.get_all(user_id=user_id, version="v2") self._logger.info( "Retrieved memories", user_id=user_id, memory_count=len(results) ) return results except Exception as e: self._logger.error("Failed to get memories", user_id=user_id, error=str(e)) raise

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/terrymunro/mcp-mitm-mem0'

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