Skip to main content
Glama

toggl_workspace_summary

Retrieve total hours tracked per workspace for a specified date range using Toggl Track integration.

Instructions

Get total hours per workspace 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)

Implementation Reference

  • Main handler for toggl_workspace_summary tool. Fetches time entries for specified or default period, hydrates with cache, groups by workspace, generates summaries using helpers, sorts descending by total hours, and returns structured JSON response.
    case 'toggl_workspace_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);
      }
      
      const hydrated = await cache.hydrateTimeEntries(entries);
      const byWorkspace = groupEntriesByWorkspace(hydrated);
      
      const summaries: any[] = [];
      byWorkspace.forEach((wsEntries, wsName) => {
        const wsId = wsEntries[0]?.workspace_id || 0;
        summaries.push(generateWorkspaceSummary(wsName, wsId, wsEntries));
      });
      
      // Sort by total hours descending
      summaries.sort((a, b) => b.total_seconds - a.total_seconds);
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify({ 
            workspace_count: summaries.length,
            total_hours: secondsToHours(summaries.reduce((t, s) => t + s.total_seconds, 0)),
            workspaces: summaries 
          }, null, 2)
        }]
      };
    }
  • Schema definition for the tool including name, description, and input parameters (period, start_date, end_date). Used for registration and validation.
    {
      name: 'toggl_workspace_summary',
      description: 'Get total hours per workspace 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)'
          }
        }
      },
    },
  • Helper function that generates a detailed WorkspaceSummary from time entries, computing totals, billable amounts, unique project count, and entry count.
    export function generateWorkspaceSummary(
      workspaceName: string,
      workspaceId: number,
      entries: HydratedTimeEntry[]
    ): WorkspaceSummary {
      const totalSeconds = calculateTotalDuration(entries);
      const billableSeconds = entries
        .filter(e => e.billable)
        .reduce((total, e) => total + (e.duration < 0 ? 0 : e.duration), 0);
      
      const projectIds = new Set(entries.map(e => e.project_id).filter(Boolean));
      
      return {
        workspace_id: workspaceId,
        workspace_name: workspaceName,
        total_hours: secondsToHours(totalSeconds),
        total_seconds: totalSeconds,
        billable_hours: secondsToHours(billableSeconds),
        billable_seconds: billableSeconds,
        project_count: projectIds.size,
        entry_count: entries.length
      };
    }
  • Utility function to group time entries by workspace name for summary generation.
    export function groupEntriesByWorkspace(entries: HydratedTimeEntry[]): Map<string, HydratedTimeEntry[]> {
      const grouped = new Map<string, HydratedTimeEntry[]>();
      
      entries.forEach(entry => {
        const key = entry.workspace_name;
        if (!grouped.has(key)) {
          grouped.set(key, []);
        }
        grouped.get(key)!.push(entry);
      });
      
      return grouped;
    }
  • src/index.ts:386-388 (registration)
    Registers the listTools handler which exposes all tool schemas including toggl_workspace_summary.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
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 it's a read operation ('Get'), but doesn't mention authentication needs, rate limits, error handling, or what the output format looks like (e.g., structured data vs. raw hours). This is a significant gap for a tool with potential API interactions.

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 with zero waste—it directly states the tool's function without redundancy. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is minimally adequate but incomplete. It covers the basic purpose but lacks behavioral context and usage guidelines, which are important for an agent to operate effectively in a server with multiple time-tracking tools.

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 all parameters, so the baseline is 3. The description adds no additional parameter semantics beyond implying date-range usage, which is already covered in the schema. It doesn't clarify parameter interactions (e.g., using 'period' vs. 'start_date/end_date').

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 verb 'Get' and resource 'total hours per workspace' with scope 'for a date range', making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'toggl_daily_report' or 'toggl_weekly_report' which might provide similar time-based summaries, so it doesn't reach the highest score.

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 like 'toggl_daily_report' or 'toggl_weekly_report' from the sibling list. It mentions a date range but doesn't specify use cases, prerequisites, or exclusions, leaving the agent to infer usage context.

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