Skip to main content
Glama
niondigital

MoCo MCP Server

by niondigital

get_user_sick_days

Retrieve all sick days for a specific year with daily breakdown and total calculations from MoCo time tracking systems.

Instructions

Get all user sick days for a specific year with daily breakdown and total calculations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYesYear to retrieve sick days for (e.g., 2024)

Implementation Reference

  • The handler function that implements the core logic of the get_user_sick_days tool: validates input year, fetches sick days data from Moco API, processes and summarizes the data, handles empty results and errors.
    handler: async (params: z.infer<typeof GetUserSickDaysSchema>): Promise<string> => {
      const { year } = params;
    
      // Validate year
      if (!validateYear(year)) {
        return createValidationErrorMessage({
          field: 'year',
          value: year,
          reason: 'invalid_year'
        });
      }
    
      try {
        const apiService = new MocoApiService();
        const sickDays = await apiService.getTakenSickDays(year);
    
        // Debug logging
        console.error(`DEBUG: Got ${sickDays.length} sick days for year ${year}`);
        console.error('DEBUG: Sick days data:', JSON.stringify(sickDays.slice(0, 3), null, 2));
    
        if (sickDays.length === 0) {
          return formatSickDaysWithNoData(year);
        }
    
        const summary = createSickDaysSummary(sickDays, year);
        console.error('DEBUG: Sick days summary created:', JSON.stringify(summary, null, 2));
        return formatSickDaysSummary(summary);
    
      } catch (error) {
        return `Error retrieving sick days for ${year}: ${error instanceof Error ? error.message : 'Unknown error'}`;
      }
    }
  • Zod schema defining the input parameters for the get_user_sick_days tool, requiring a single 'year' parameter as an integer.
    const GetUserSickDaysSchema = z.object({
      year: z.number().int().describe('Year to retrieve sick days for (e.g., 2024)')
    });
  • src/index.ts:34-42 (registration)
    Registration of the getUserSickDaysTool in the AVAILABLE_TOOLS array used by the MCP server to list and dispatch tools.
    const AVAILABLE_TOOLS = [
      getActivitiesTool,
      getUserProjectsTool,
      getUserProjectTasksTool,
      getUserHolidaysTool,
      getUserPresencesTool,
      getUserSickDaysTool,
      getPublicHolidaysTool
    ];
  • src/index.ts:25-25 (registration)
    Import statement that brings the getUserSickDaysTool into the main index file for registration.
    import { getUserSickDaysTool } from './tools/userSickDaysTools.js';
  • Helper function that processes raw sick days data into a structured HolidaySummary, calculating total days and preparing formatted output.
    function createSickDaysSummary(sickDays: any[], year: number): HolidaySummary {
      console.error('DEBUG: Processing sick days...');
      
      // Process sick days from schedules endpoint
      const processedSickDays = sickDays
        .map(schedule => ({
          date: schedule.date,
          days: calculateDaysFromSchedule(schedule), // Calculate days from am/pm flags
          status: 'sick', // All schedules are sick days
          note: schedule.comment || ''
        }))
        .sort((a, b) => a.date.localeCompare(b.date)); // Sort by date
    
      console.error('DEBUG: Processed sick days:', processedSickDays);
    
      // Calculate totals
      const totalSickDays = processedSickDays.reduce((total, sickDay) => total + sickDay.days, 0);
    
      return {
        year,
        holidays: processedSickDays, // Reuse the same structure
        totalTakenDays: Math.round(totalSickDays * 100) / 100, // Round to 2 decimal places
        annualEntitlementDays: 0, // Not applicable for sick days
        utilizationPercentage: 0, // Not applicable for sick days
        remainingDays: 0 // Not applicable for sick days
      };
    }

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