Skip to main content
Glama

timecard_get_summary

Retrieve weekly timesheet statistics including hours worked and project breakdowns for accurate time tracking and reporting.

Instructions

Get summary statistics for the current timesheet week

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYesTarget date in YYYY-MM-DD format

Implementation Reference

  • The handler function for 'timecard_get_summary' that fetches the timesheet HTML, parses it for activities and time entries, aggregates daily totals and project breakdown, and returns the summary statistics.
    handler: async (args, session: TimeCardSession) => {
      const authResult = await session.ensureAuthenticated();
      if (!authResult.success) {
        throw new Error(authResult.message);
      }
    
      const safeArgs = args || {};
      const { date } = safeArgs;
    
      try {
        // Fetch the page
        const html = await session.fetchTimesheetPage(date);
    
        // Calculate week boundaries
        const targetDate = new Date(date);
        const dayOfWeek = targetDate.getDay();
        const monday = new Date(targetDate);
        monday.setDate(targetDate.getDate() - (dayOfWeek === 0 ? 6 : dayOfWeek - 1));
    
        const saturday = new Date(monday);
        saturday.setDate(monday.getDate() + 5);
    
        const weekStart = monday.toISOString().split('T')[0];
        const weekEnd = saturday.toISOString().split('T')[0];
    
        // Parse data
        const activities = parseActivityList(html);
        const timeEntries = parseTimearray(html);
        const projectOptions = parseProjectOptions(html);
        const mapping = buildIndexMapping(activities);
        const projectNameMap = new Map(projectOptions.map(p => [p.id, p.name]));
    
        const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
    
        const dailyTotals: Record<string, number> = {
          monday: 0, tuesday: 0, wednesday: 0,
          thursday: 0, friday: 0, saturday: 0
        };
    
        const projectBreakdown: Record<string, number> = {};
        let totalHours = 0;
    
        // Group entries by (projectIndex, activityIndex)
        const entryGroups = new Map<string, {
          projectIndex: number;
          entries: typeof timeEntries;
        }>();
    
        for (const entry of timeEntries) {
          const key = `${entry.projectIndex}_${entry.activityIndex}`;
          if (!entryGroups.has(key)) {
            entryGroups.set(key, { projectIndex: entry.projectIndex, entries: [] });
          }
          entryGroups.get(key)!.entries.push(entry);
        }
    
        const activeEntries = entryGroups.size;
    
        for (const [, group] of entryGroups) {
          const projectId = mapping.projectIndexToId.get(group.projectIndex) || '';
          const projectName = projectNameMap.get(projectId) || `Project ${projectId}`;
    
          if (!projectBreakdown[projectName]) {
            projectBreakdown[projectName] = 0;
          }
    
          for (const entry of group.entries) {
            if (entry.dayIndex >= 0 && entry.dayIndex < 6) {
              const hours = parseFloat(entry.duration) || 0;
              if (hours > 0) {
                dailyTotals[days[entry.dayIndex]] += hours;
                totalHours += hours;
                projectBreakdown[projectName] += hours;
              }
            }
          }
        }
    
        return {
          week_start: weekStart,
          week_end: weekEnd,
          total_hours: totalHours,
          active_entries: activeEntries,
          daily_totals: dailyTotals,
          project_breakdown: projectBreakdown,
          average_daily_hours: totalHours / 6,
          statistics: {
            max_daily_hours: Math.max(...Object.values(dailyTotals)),
            min_daily_hours: Math.min(...Object.values(dailyTotals)),
            working_days: Object.values(dailyTotals).filter(h => h > 0).length,
            unique_projects: Object.keys(projectBreakdown).length
          }
        };
      } catch (error) {
        throw new Error(`Failed to get summary for ${date}: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • The input schema for 'timecard_get_summary' tool, which requires a date string in YYYY-MM-DD format.
    inputSchema: {
      type: 'object',
      properties: {
        date: {
          type: 'string',
          description: 'Target date in YYYY-MM-DD format'
        }
      },
      required: ['date']
    },
  • Registration of 'timecard_get_summary' within the 'managementTools' array.
    export const managementTools: MCPTool[] = [
      timecardVersion,
      timecardGetSummary
    ];
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 this is a 'Get' operation, implying read-only access, but doesn't clarify if it requires authentication, has rate limits, returns aggregated data, or what 'summary statistics' entails (e.g., totals, averages). This leaves significant gaps for a tool that likely interacts with sensitive timecard data.

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, clear sentence with zero wasted words. It front-loads the key action and resource, making it easy to parse quickly. Every part of the sentence earns its place by conveying essential information without redundancy.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what 'summary statistics' includes (e.g., numeric totals, breakdowns), how the 'current timesheet week' is defined relative to the date parameter, or behavioral aspects like error handling. For a tool with one parameter but potentially complex output, this leaves too much unspecified.

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 the 'date' parameter fully documented in the schema as a required string in YYYY-MM-DD format. The description adds no additional meaning beyond implying the date determines the 'current timesheet week', which is minimal value. This meets the baseline for high schema coverage.

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 action ('Get summary statistics') and the resource ('for the current timesheet week'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from its siblings like 'timecard_get_timesheet' or 'timecard_get_activities', which might also retrieve timecard-related data but with different scopes 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 prerequisites, context for 'current timesheet week', or compare it to sibling tools like 'timecard_get_timesheet' for detailed data or 'timecard_save' for updates, leaving the agent to infer usage scenarios.

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/keith-hung/timecard-mcp'

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