Skip to main content
Glama

toggl_weekly_report

Generate weekly time tracking reports with daily breakdowns and project summaries from Toggl Track data. Specify week offset and output format for structured reporting.

Instructions

Generate a weekly report with daily breakdown and project summaries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
week_offsetNoWeek offset from current week (0 = this week, -1 = last week)
formatNoOutput format (default: json)

Implementation Reference

  • The main handler function for the 'toggl_weekly_report' tool. It ensures cache is warm, fetches time entries for the specified week, hydrates them with metadata, calculates week boundaries, generates the report using generateWeeklyReport utility, and returns either JSON or formatted text based on input.
    case 'toggl_weekly_report': {
      await ensureCache();
      
      const weekOffset = (args?.week_offset as number) || 0;
      const entries = await api.getTimeEntriesForWeek(weekOffset);
      const hydrated = await cache.hydrateTimeEntries(entries);
      
      // Calculate week boundaries
      const today = new Date();
      const dayOfWeek = today.getDay();
      const diff = today.getDate() - dayOfWeek + (dayOfWeek === 0 ? -6 : 1);
      const monday = new Date(today.setDate(diff));
      monday.setDate(monday.getDate() + (weekOffset * 7));
      const sunday = new Date(monday);
      sunday.setDate(sunday.getDate() + 6);
      
      const report = generateWeeklyReport(monday, sunday, hydrated);
      
      if (args?.format === 'text') {
        return {
          content: [{
            type: 'text',
            text: formatReportForDisplay(report)
          }]
        };
      }
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(report, null, 2)
        }]
      };
    }
  • Schema definition for the 'toggl_weekly_report' tool, including name, description, and input schema for parameters like week_offset and format.
    {
      name: 'toggl_weekly_report',
      description: 'Generate a weekly report with daily breakdown and project summaries',
      inputSchema: {
        type: 'object',
        properties: {
          week_offset: {
            type: 'number',
            description: 'Week offset from current week (0 = this week, -1 = last week)'
          },
          format: {
            type: 'string',
            enum: ['json', 'text'],
            description: 'Output format (default: json)'
          }
        }
      },
    },
  • Core utility function generateWeeklyReport that generates the structured weekly report from hydrated time entries, including daily breakdowns, project summaries, and workspace summaries.
    export function generateWeeklyReport(
      weekStart: Date,
      weekEnd: Date,
      entries: HydratedTimeEntry[]
    ): WeeklyReport {
      const totalSeconds = calculateTotalDuration(entries);
      
      // Group by date for daily breakdown
      const byDate = groupEntriesByDate(entries);
      const dailyBreakdown: DailyReport[] = [];
      byDate.forEach((dateEntries, date) => {
        dailyBreakdown.push(generateDailyReport(date, dateEntries));
      });
      
      // Sort daily reports
      dailyBreakdown.sort((a, b) => a.date.localeCompare(b.date));
      
      // Overall project summaries
      const byProject = groupEntriesByProject(entries);
      const projectSummaries: ProjectSummary[] = [];
      byProject.forEach((projectEntries, projectName) => {
        projectSummaries.push(generateProjectSummary(projectName, projectEntries));
      });
      
      // Overall workspace summaries
      const byWorkspace = groupEntriesByWorkspace(entries);
      const workspaceSummaries: WorkspaceSummary[] = [];
      byWorkspace.forEach((wsEntries, wsName) => {
        const wsId = wsEntries[0]?.workspace_id || 0;
        workspaceSummaries.push(generateWorkspaceSummary(wsName, wsId, wsEntries));
      });
      
      return {
        week_start: weekStart.toISOString().split('T')[0],
        week_end: weekEnd.toISOString().split('T')[0],
        total_hours: secondsToHours(totalSeconds),
        total_seconds: totalSeconds,
        daily_breakdown: dailyBreakdown,
        by_project: projectSummaries,
        by_workspace: workspaceSummaries
      };
    }
  • Utility function formatReportForDisplay used by the handler to format the weekly report as human-readable text when format='text' is requested.
    export function formatReportForDisplay(report: DailyReport | WeeklyReport): string {
      const lines: string[] = [];
      
      if ('week_start' in report) {
        // Weekly report
        lines.push(`📊 Weekly Report (${report.week_start} to ${report.week_end})`);
        lines.push(`Total: ${report.total_hours} hours`);
        lines.push('');
        
        lines.push('📅 Daily Breakdown:');
        report.daily_breakdown.forEach(day => {
          lines.push(`  ${day.date}: ${day.total_hours}h`);
        });
      } else {
        // Daily report
        lines.push(`📊 Daily Report for ${report.date}`);
        lines.push(`Total: ${report.total_hours} hours`);
      }
      
      lines.push('');
      lines.push('🏢 By Workspace:');
      report.by_workspace.forEach(ws => {
        lines.push(`  ${ws.workspace_name}: ${ws.total_hours}h (${ws.project_count} projects)`);
      });
      
      lines.push('');
      lines.push('📁 By Project:');
      report.by_project.forEach(proj => {
        const client = proj.client_name ? ` (${proj.client_name})` : '';
        lines.push(`  ${proj.project_name}${client}: ${proj.total_hours}h`);
      });
      
      return lines.join('\n');
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool generates a report but doesn't cover critical aspects like whether it requires authentication, has rate limits, modifies data, or what the output looks like (e.g., format details beyond the schema). This leaves significant gaps for an AI agent to understand how to use it effectively.

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?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. It directly communicates what the tool does, making it easy to parse and understand quickly.

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

Completeness2/5

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

Given the complexity of a report-generation tool with no annotations and no output schema, the description is incomplete. It lacks details on authentication needs, output structure, error handling, or how it differs from siblings. This makes it inadequate for an AI agent to fully grasp the tool's behavior and usage context.

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

Parameters3/5

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

The schema description coverage is 100%, with clear descriptions for both parameters ('week_offset' and 'format'). The description adds no additional parameter semantics beyond what the schema provides, such as default behaviors or usage examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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: 'Generate a weekly report with daily breakdown and project summaries.' It specifies the verb ('generate') and resource ('weekly report') with details about content ('daily breakdown and project summaries'). However, it doesn't explicitly differentiate from sibling tools like 'toggl_daily_report' or 'toggl_project_summary' beyond the weekly scope.

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 no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'toggl_daily_report' for daily reports or 'toggl_project_summary' for project-focused summaries, nor does it specify prerequisites or contexts 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/verygoodplugins/mcp-toggl'

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