Skip to main content
Glama

timecard_get_timesheet

Retrieve saved weekly timesheet data including daily hours, approval status, and notes for a specific date. Use to view existing entries without making changes.

Instructions

Get timesheet data for a specific week. Read-only, no side effects.

Returns for each entry:

  • daily_hours: Hours worked each day (monday-saturday)

  • daily_status: Approval status each day (draft/submitted/approved/rejected)

  • daily_notes: Notes for each day

Status values:

  • draft: Saved but not submitted

  • submitted: Submitted for approval

  • approved: Approved by manager

  • rejected: Rejected by manager

This retrieves SAVED data from the server. Use timecard_save to make changes.

Input Schema

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

Implementation Reference

  • Implementation of the timecard_get_timesheet tool handler. It fetches the timesheet page for a given date, parses it, groups entries by activity, and returns the formatted data.
    const timecardGetTimesheet: MCPTool = {
      name: 'timecard_get_timesheet',
      description: `Get timesheet data for a specific week. Read-only, no side effects.
    
    Returns for each entry:
    - daily_hours: Hours worked each day (monday-saturday)
    - daily_status: Approval status each day (draft/submitted/approved/rejected)
    - daily_notes: Notes for each day
    
    Status values:
    - draft: Saved but not submitted
    - submitted: Submitted for approval
    - approved: Approved by manager
    - rejected: Rejected by manager
    
    This retrieves SAVED data from the server. Use timecard_save to make changes.`,
      inputSchema: {
        type: 'object',
        properties: {
          date: {
            type: 'string',
            description: 'Target date in YYYY-MM-DD format'
          }
        },
        required: ['date']
      },
      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 (also sets session attributes for save)
          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 from HTML
          const activities = parseActivityList(html);
          const timeEntries = parseTimearray(html);
          const mapping = buildIndexMapping(activities);
    
          const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
    
          // Group time entries by (projectIndex, activityIndex)
          const entryGroups = new Map<string, {
            projectIndex: number;
            activityIndex: 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,
                activityIndex: entry.activityIndex,
                entries: [],
              });
            }
            entryGroups.get(key)!.entries.push(entry);
          }
    
          // Build output entries
          const entriesWithStatus: Array<{
            index: number;
            project: { id: string; name: string };
            activity: { id: string; name: string };
            daily_hours: Record<string, number>;
            daily_status: Record<string, string>;
            daily_notes: Record<string, string>;
          }> = [];
    
          // Get project names from project options
          const projectOptions = await session.getProjectOptions(date);
          const projectNameMap = new Map(projectOptions.map(p => [p.id, p.name]));
    
          let entryIndex = 0;
          for (const [key, group] of entryGroups) {
            const projectId = mapping.projectIndexToId.get(group.projectIndex) || '';
            const actEntry = mapping.activityByIndex.get(key);
    
            const projectName = projectNameMap.get(projectId) || `Project ${projectId}`;
            const activityId = actEntry?.uid || '';
            const activityName = actEntry
              ? actEntry.name.replace(/<<.*?>>/, '').trim()
              : '';
    
            const dailyHours: Record<string, number> = {};
            const dailyStatus: Record<string, string> = {};
            const dailyNotes: Record<string, string> = {};
    
            // Initialize all days
            for (let d = 0; d < 6; d++) {
              dailyHours[days[d]] = 0;
              dailyStatus[days[d]] = 'draft';
              dailyNotes[days[d]] = '';
            }
    
            // Fill in data from timearray entries
            for (const entry of group.entries) {
              if (entry.dayIndex >= 0 && entry.dayIndex < 6) {
                const dayName = days[entry.dayIndex];
                dailyHours[dayName] = parseFloat(entry.duration) || 0;
                dailyNotes[dayName] = entry.note;
    
                // Map status values
                if (entry.status === 'approve') {
                  dailyStatus[dayName] = 'approved';
                } else if (entry.status === 'submit') {
                  dailyStatus[dayName] = 'submitted';
                } else if (entry.status === 'reject') {
                  dailyStatus[dayName] = 'rejected';
                } else {
                  dailyStatus[dayName] = 'draft';
                }
              }
            }
    
            entriesWithStatus.push({
              index: entryIndex++,
              project: { id: projectId, name: projectName },
              activity: { id: activityId, name: activityName },
              daily_hours: dailyHours,
              daily_status: dailyStatus,
              daily_notes: dailyNotes,
            });
          }
    
          // Determine overall status
          let overallStatus = 'draft';
          const statusPriority: Record<string, number> = {
            'draft': 0, 'approved': 1, 'submitted': 2, 'rejected': 3
          };
    
          for (const entry of entriesWithStatus) {
            for (const day of Object.keys(entry.daily_status)) {
              const dayStatus = entry.daily_status[day];
              if (entry.daily_hours[day] > 0 && statusPriority[dayStatus] > statusPriority[overallStatus]) {
                overallStatus = dayStatus;
              }
            }
          }
    
          return {
            week_start: weekStart,
            week_end: weekEnd,
            entries: entriesWithStatus,
            status: overallStatus
          };
        } catch (error) {
          throw new Error(`Failed to get timesheet for ${date}: ${error instanceof Error ? error.message : 'Unknown error'}`);
        }
      }
    };
  • Registration of the timecard_get_timesheet tool within the exported dataTools array.
    export const dataTools: MCPTool[] = [
      timecardGetProjects,
      timecardGetActivities,
      timecardGetTimesheet,
Behavior4/5

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

With no annotations provided, the description carries the full burden and does so well by disclosing key behavioral traits: it's read-only with no side effects, retrieves saved data from the server, and describes the return structure including status values. It doesn't mention rate limits or auth needs, but covers essential operational context.

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 appropriately sized and front-loaded, starting with the core purpose and key behavioral notes. Each sentence adds value, such as explaining return values and statuses, and it avoids redundancy. The structure is logical and efficient.

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

Completeness4/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 (1 parameter, no output schema, no annotations), the description is largely complete: it explains the purpose, usage, behavior, and return structure. However, it lacks details on error handling or edge cases, which could be useful for an agent. With no output schema, the description compensates well by detailing return values.

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%, so the schema already documents the single parameter 'date' with its format. The description does not add any parameter-specific details beyond what the schema provides, such as clarifying the date's role in determining the week. Baseline 3 is appropriate as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/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 with a specific verb ('Get') and resource ('timesheet data for a specific week'), and it distinguishes from sibling tools by explicitly mentioning 'timecard_save' for making changes. It avoids tautology by not just restating the name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit guidance on when to use this tool (to retrieve saved data) and when not to use it (for making changes, directing to 'timecard_save' instead). This clearly differentiates it from alternatives like 'timecard_save' and other siblings.

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