Skip to main content
Glama

get_recent_memento_activity

Retrieve recent memory activity summaries including memory counts, recent entries, and unresolved problems for session context analysis.

Instructions

Get summary of recent memento activity for session context.

Returns: memory counts by type, recent memories (up to 20), unresolved problems.

EXAMPLES:

  • get_recent_memento_activity(days=7) - last week's activity

  • get_recent_memento_activity(days=30, project="/app") - last month for specific project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoNumber of days to look back (default: 7)
projectNoOptional: Filter by project path

Implementation Reference

  • The handle_get_recent_memento_activity function retrieves activity data from the memory_db and formats it into a CallToolResult. It includes optional project-based filtering and a timeout-protected project detection mechanism.
    async def handle_get_recent_memento_activity(
        memory_db: SQLiteMemoryDatabase, arguments: Dict[str, Any]
    ) -> CallToolResult:
        """Handle get_recent_activity tool call.
    
        Args:
            memory_db: Database instance for memory operations
            arguments: Tool arguments from MCP call containing:
                - days: Number of days to look back (default: 7)
                - project: Optional project path to filter by
    
        Returns:
            CallToolResult with formatted activity summary or error message
        """
        # Check if database supports get_recent_activity
        if not hasattr(memory_db, "get_recent_activity"):
            return CallToolResult(
                content=[
                    TextContent(
                        type="text",
                        text="Recent activity summary is not supported by this backend",
                    )
                ],
                isError=True,
            )
    
        days = arguments.get("days", 7)
        project = arguments.get("project")
    
        # Auto-detect project only when explicitly not provided.
        # Run in a thread with a hard timeout; on Windows git subprocesses can
        # linger after TimeoutExpired, so we cap the whole operation at 0.5 s
        # and discard the result on any failure — project detection is best-effort.
        if not project:
            try:
                from ..utils.project_detection import detect_project_context
    
                loop = asyncio.get_event_loop()
                executor = ThreadPoolExecutor(max_workers=1)
    
                try:
                    future = loop.run_in_executor(executor, detect_project_context)
                    project_info = await asyncio.wait_for(future, timeout=0.5)
    
                    if project_info:
                        project = project_info.get("project_path")
    
                finally:
                    # Shut down without waiting so zombie git processes don't block
                    executor.shutdown(wait=False, cancel_futures=True)
    
            except Exception:
                # Project detection is best-effort; continue without it
                pass
    
        activity = await memory_db.get_recent_activity(days=days, project=project)
    
        # Format results
        result_text = f"**Recent Activity Summary (Last {days} days)**\n\n"
    
        if project:
            result_text += f"**Project**: {project}\n\n"
    
        # Total count
        result_text += f"**Total Memories**: {activity['total_count']}\n\n"
    
        # Memories by type
        if activity["memories_by_type"]:
            result_text += "**Breakdown by Type**:\n"
    
            for mem_type, count in sorted(
                activity["memories_by_type"].items(), key=lambda x: x[1], reverse=True
            ):
                result_text += f"- {mem_type.replace('_', ' ').title()}: {count}\n"
    
            result_text += "\n"
    
        # Unresolved problems
        if activity["unresolved_problems"]:
            result_text += (
                f"**⚠️ Unresolved Problems ({len(activity['unresolved_problems'])})**:\n"
            )
    
            for problem in activity["unresolved_problems"]:
                title = _get_memory_attr(problem, "title", "Unknown")
                importance = _get_memory_attr(problem, "importance", 0.5)
                summary = _get_memory_attr(problem, "summary")
                result_text += f"- **{title}** (importance: {importance:.1f})\n"
    
                if summary:
                    result_text += f"  {summary}\n"
    
            result_text += "\n"
    
        # Recent memories
        if activity["recent_memories"]:
            result_text += f"**Recent Memories** (showing {min(10, len(activity['recent_memories']))}):\n"
    
            for i, memory in enumerate(activity["recent_memories"][:10], 1):
                title = _get_memory_attr(memory, "title", "Unknown")
                mem_type = _get_memory_attr(memory, "type", "general")
                summary = _get_memory_attr(memory, "summary")
                result_text += f"{i}. **{title}** ({mem_type})\n"
    
                if summary:
                    result_text += f"   {summary}\n"
    
            result_text += "\n"
    
        # Next steps suggestion
        result_text += "**💡 Next Steps**:\n"
    
        if activity["unresolved_problems"]:
            result_text += "- Review unresolved problems and consider solutions\n"
            result_text += '- Use `get_memento(memory_id="...")` for details\n'
        else:
            result_text += "- All problems have been addressed!\n"
    
        return CallToolResult(content=[TextContent(type="text", text=result_text)])
  • The get_recent_memento_activity tool is defined in definitions.py, providing the name and description used for tool registration in the MCP protocol.
    name="get_recent_memento_activity",

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