Skip to main content
Glama

toggl_project_summary

Generate project time summaries from Toggl Track data. Calculate total hours per project for specified date ranges to analyze time allocation and track project progress.

Instructions

Get total hours per project for a date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodNoPredefined period
start_dateNoStart date (YYYY-MM-DD format)
end_dateNoEnd date (YYYY-MM-DD format)
workspace_idNoFilter by workspace ID

Implementation Reference

  • Main handler logic for the 'toggl_project_summary' tool. Fetches time entries based on input parameters, hydrates them using cache, groups by project using helper, generates summaries, sorts by total hours descending, and returns formatted JSON response.
    case 'toggl_project_summary': {
      await ensureCache();
      
      let entries: TimeEntry[];
      
      if (args?.period) {
        const range = getDateRange(args.period as any);
        entries = await api.getTimeEntriesForDateRange(range.start, range.end);
      } else if (args?.start_date && args?.end_date) {
        const start = new Date(args.start_date as string);
        const end = new Date(args.end_date as string);
        entries = await api.getTimeEntriesForDateRange(start, end);
      } else {
        // Default to current week
        entries = await api.getTimeEntriesForWeek(0);
      }
      
      if (args?.workspace_id) {
        entries = entries.filter(e => e.workspace_id === args.workspace_id);
      }
      
      const hydrated = await cache.hydrateTimeEntries(entries);
      const byProject = groupEntriesByProject(hydrated);
      
      const summaries: any[] = [];
      byProject.forEach((projectEntries, projectName) => {
        summaries.push(generateProjectSummary(projectName, projectEntries));
      });
      
      // Sort by total hours descending
      summaries.sort((a, b) => b.total_seconds - a.total_seconds);
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify({ 
            project_count: summaries.length,
            total_hours: secondsToHours(summaries.reduce((t, s) => t + s.total_seconds, 0)),
            projects: summaries 
          }, null, 2)
        }]
      };
    }
  • Tool schema definition including name, description, and input schema for parameters like period, start_date, end_date, and workspace_id.
    {
      name: 'toggl_project_summary',
      description: 'Get total hours per project for a date range',
      inputSchema: {
        type: 'object',
        properties: {
          period: {
            type: 'string',
            enum: ['week', 'lastWeek', 'month', 'lastMonth'],
            description: 'Predefined period'
          },
          start_date: {
            type: 'string',
            description: 'Start date (YYYY-MM-DD format)'
          },
          end_date: {
            type: 'string',
            description: 'End date (YYYY-MM-DD format)'
          },
          workspace_id: {
            type: 'number',
            description: 'Filter by workspace ID'
          }
        }
      },
    },
  • Helper function to group hydrated time entries by project name, used in project summary generation.
    // Group time entries by project
    export function groupEntriesByProject(entries: HydratedTimeEntry[]): Map<string, HydratedTimeEntry[]> {
      const grouped = new Map<string, HydratedTimeEntry[]>();
      
      entries.forEach(entry => {
        const key = entry.project_name || 'No Project';
        if (!grouped.has(key)) {
          grouped.set(key, []);
        }
        grouped.get(key)!.push(entry);
      });
      
      return grouped;
    }
  • Core helper function that generates a ProjectSummary object from project name and entries, calculating total and billable hours.
    // Generate project summary
    export function generateProjectSummary(
      projectName: string,
      entries: HydratedTimeEntry[]
    ): ProjectSummary {
      const totalSeconds = calculateTotalDuration(entries);
      const billableSeconds = entries
        .filter(e => e.billable)
        .reduce((total, e) => total + (e.duration < 0 ? 0 : e.duration), 0);
      
      return {
        project_id: entries[0]?.project_id,
        project_name: projectName,
        client_name: entries[0]?.client_name,
        workspace_name: entries[0]?.workspace_name || 'Unknown',
        total_hours: secondsToHours(totalSeconds),
        total_seconds: totalSeconds,
        billable_hours: secondsToHours(billableSeconds),
        billable_seconds: billableSeconds,
        entry_count: entries.length
      };
    }
  • Utility function to convert total seconds to decimal hours, used in summaries.
    // Convert seconds to hours with decimal precision
    export function secondsToHours(seconds: number): number {
      return Math.round((seconds / 3600) * 100) / 100;
    }
Behavior2/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 of behavioral disclosure. It states the tool retrieves data ('Get total hours'), implying a read-only operation, but doesn't clarify aspects like authentication requirements, rate limits, error handling, or the format of the returned data (e.g., whether it's a list, summary object, or includes pagination). For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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: 'Get total hours per project for a date range.' It is front-loaded with the core purpose, has no redundant words, and every part earns its place by specifying the action, resource, and scope concisely.

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 tool's complexity (4 parameters, no output schema, and no annotations), the description is incomplete. It lacks details on behavioral traits (e.g., authentication needs, data format), usage guidelines compared to siblings, and output specifics. While the schema covers parameters well, the overall context for an AI agent to correctly invoke this tool is insufficient, especially without annotations or an output schema to clarify results.

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 input schema has 100% description coverage, so the schema already documents all parameters ('period', 'start_date', 'end_date', 'workspace_id') with details like formats and enums. The description adds minimal value beyond the schema by implying date-range filtering but doesn't explain parameter interactions (e.g., that 'period' might override 'start_date'/'end_date') or provide usage examples. With high schema coverage, 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: 'Get total hours per project for a date range.' It specifies the verb ('Get'), resource ('total hours per project'), and scope ('date range'). However, it doesn't explicitly distinguish this from sibling tools like 'toggl_daily_report' or 'toggl_weekly_report,' which also involve time reporting but with different aggregations or formats.

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' or 'toggl_workspace_summary,' which might offer similar time-tracking summaries but with different scopes or outputs. There's no indication of prerequisites, such as authentication or workspace selection, beyond what the parameters imply.

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