Skip to main content
Glama
niondigital

MoCo MCP Server

by niondigital

get_user_presences

Retrieve aggregated user presence data for time tracking by specifying start and end dates to analyze daily attendance and total calculations.

Instructions

Get user presences within a date range with daily aggregation and total calculations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startDateYesStart date in ISO 8601 format (YYYY-MM-DD)
endDateYesEnd date in ISO 8601 format (YYYY-MM-DD)

Implementation Reference

  • Main tool handler for 'get_user_presences': validates dates, fetches presences via API, aggregates by day, calculates totals and formats output as a readable summary with statistics.
    export const getUserPresencesTool = {
      name: 'get_user_presences',
      description: 'Get user presences within a date range with daily aggregation and total calculations',
      inputSchema: zodToJsonSchema(GetUserPresencesSchema),
      handler: async (params: z.infer<typeof GetUserPresencesSchema>): Promise<string> => {
        const { startDate, endDate } = params;
    
        // Validate date format and range
        if (!validateDateRange(startDate, endDate)) {
          return createValidationErrorMessage({
            field: 'dateRange',
            value: `${startDate} to ${endDate}`,
            reason: 'invalid_date_range'
          });
        }
    
        try {
          const apiService = new MocoApiService();
          const presences = await apiService.getUserPresences(startDate, endDate);
    
          if (presences.length === 0) {
            return createEmptyResultMessage({
              type: 'presences',
              startDate,
              endDate
            });
          }
    
          const summary = aggregatePresences(presences, startDate, endDate);
          return formatPresencesSummary(summary);
    
        } catch (error) {
          return `Error retrieving presences: ${error instanceof Error ? error.message : 'Unknown error'}`;
        }
      }
    };
  • Zod schema defining input parameters: startDate and endDate as ISO date strings.
    const GetUserPresencesSchema = z.object({
      startDate: z.string().describe('Start date in ISO 8601 format (YYYY-MM-DD)'),
      endDate: z.string().describe('End date in ISO 8601 format (YYYY-MM-DD)')
    });
  • src/index.ts:34-42 (registration)
    Registration of getUserPresencesTool in the AVAILABLE_TOOLS array used by MCP server for tool listing and execution dispatching.
    const AVAILABLE_TOOLS = [
      getActivitiesTool,
      getUserProjectsTool,
      getUserProjectTasksTool,
      getUserHolidaysTool,
      getUserPresencesTool,
      getUserSickDaysTool,
      getPublicHolidaysTool
    ];
  • MocoApiService method to fetch raw user presences data from MoCo API endpoint '/users/presences' with automatic pagination.
    async getUserPresences(startDate: string, endDate: string): Promise<UserPresence[]> {
      return this.fetchAllPages<UserPresence>('/users/presences', {
        from: startDate,
        to: endDate
      });
    }
  • Helper function to aggregate presences: groups by date, creates daily summaries with total hours, sorts dates and computes grand total.
    function aggregatePresences(presences: UserPresence[], startDate: string, endDate: string): PresenceRangeSummary {
      // Group presences by date and calculate daily totals
      const presencesByDate = new Map<string, UserPresence[]>();
      
      presences.forEach(presence => {
        if (!presencesByDate.has(presence.date)) {
          presencesByDate.set(presence.date, []);
        }
        presencesByDate.get(presence.date)!.push(presence);
      });
    
      // Create daily summaries
      const dailySummaries: DailyPresenceSummary[] = [];
      
      // Sort dates for consistent output
      const sortedDates = Array.from(presencesByDate.keys()).sort();
      
      sortedDates.forEach(date => {
        const dayPresences = presencesByDate.get(date)!;
        const dailySummary = createDailyPresenceSummary(date, dayPresences);
        dailySummaries.push(dailySummary);
      });
    
      // Calculate grand total
      const grandTotalHours = sumHours(dailySummaries.map(day => day.totalHours));
    
      return {
        startDate,
        endDate,
        dailySummaries,
        grandTotal: createTimeFormat(grandTotalHours)
      };
    }
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 mentions 'daily aggregation and total calculations,' which adds some context about output behavior, but fails to address critical aspects like whether this is a read-only operation, potential rate limits, authentication requirements, or error conditions. For a data retrieval tool, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/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. It avoids redundancy and wastes no words, though it could be slightly more structured by separating purpose from behavioral details for clarity.

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 (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and hints at aggregation behavior, but lacks details on output format, error handling, or integration with sibling tools, leaving room for improvement in completeness.

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?

Schema description coverage is 100%, so the input schema fully documents both parameters (startDate and endDate) with their formats. The description adds no additional parameter semantics beyond what's in the schema, such as date range constraints or handling of invalid dates, meeting 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 tool's purpose: 'Get user presences within a date range with daily aggregation and total calculations.' It specifies the verb ('Get'), resource ('user presences'), and scope ('date range'), but doesn't explicitly differentiate from sibling tools like get_user_holidays or get_user_sick_days, which might also retrieve user-related data within date ranges.

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, exclusions, or compare it to sibling tools such as get_user_holidays or get_user_sick_days, leaving the agent to infer usage based on tool names alone.

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/niondigital/moco-mcp'

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