Skip to main content
Glama

get_productivity_trend

Analyze productivity trends over time by retrieving daily productivity pulse data for the last N days. Identify patterns and calculate averages to understand time usage patterns.

Instructions

Get productivity pulse trend for the last N days.

Args: days: Number of days to look back (default: 7, max 14)

Shows the daily productivity pulse with visual bars and calculates averages. Useful for identifying patterns and trends over time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo

Implementation Reference

  • The async handler function decorated with @mcp.tool() that implements the core logic of the get_productivity_trend tool. It fetches recent daily summaries, generates visual bars for productivity pulses, computes averages, and returns a formatted trend report.
    @mcp.tool() async def get_productivity_trend(days: int = 7) -> str: """Get productivity pulse trend for the last N days. Args: days: Number of days to look back (default: 7, max 14) Shows the daily productivity pulse with visual bars and calculates averages. Useful for identifying patterns and trends over time. """ try: client = RescueTimeClient() summaries = await client.get_daily_summary() if not summaries: return "No productivity data available." # Limit to requested days summaries = summaries[:min(days, len(summaries))] lines = [f"Productivity Trend (last {len(summaries)} days):", ""] for day in summaries: pulse = day.productivity_pulse bar = productivity_bar(pulse) date_short = day.date[5:] # MM-DD lines.append(f"{date_short}: {bar} {pulse:.0f} ({day.total_duration_formatted})") # Calculate averages if summaries: avg_pulse = sum(d.productivity_pulse for d in summaries) / len(summaries) avg_productive = sum(d.all_productive_percentage for d in summaries) / len(summaries) total_hours = sum(d.total_hours for d in summaries) lines.append("") lines.append(f"Average: {avg_pulse:.0f} pulse, {avg_productive:.0f}% productive") lines.append(f"Total logged: {format_hours_minutes(total_hours)}") return "\n".join(lines) except RescueTimeAuthError as e: return f"Authentication error: {e}" except RescueTimeAPIError as e: return f"API error: {e}"
  • Utility function to create visual progress bars for productivity scores, directly used in the tool's output formatting.
    def productivity_bar(score: float, width: int = 10) -> str: """Create a visual bar for productivity score (0-100).""" filled = int(score * width / 100) return "\u2588" * filled + "\u2591" * (width - filled)
  • Helper function to format total hours into human-readable 'Xh Ym' string, used for total logged time in the trend summary.
    def format_hours_minutes(hours: float) -> str: """Format hours as 'Xh Ym'.""" h = int(hours) m = int((hours - h) * 60) if h > 0: return f"{h}h {m}m" return f"{m}m"
  • Pydantic model defining the structure of daily summary data used by the tool's client.get_daily_summary() method, providing fields like productivity_pulse and duration formatters accessed in the handler.
    class DailySummary(BaseModel): """Daily summary from the Daily Summary Feed API.""" date: str productivity_pulse: float very_productive_percentage: float productive_percentage: float neutral_percentage: float distracting_percentage: float very_distracting_percentage: float all_productive_percentage: float all_distracting_percentage: float total_hours: float very_productive_hours: float productive_hours: float neutral_hours: float distracting_hours: float very_distracting_hours: float all_productive_hours: float all_distracting_hours: float total_duration_formatted: str very_productive_duration_formatted: str productive_duration_formatted: str neutral_duration_formatted: str distracting_duration_formatted: str very_distracting_duration_formatted: str all_productive_duration_formatted: str all_distracting_duration_formatted: str

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/JasonBates/rescuetime-mcp'

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