Skip to main content
Glama

get_user_sick_days

Retrieve detailed sick day records for a user in a specific year, including daily breakdown and total calculations, using the MoCo MCP Server.

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 getUserSickDaysTool object defining the MCP tool, including name, description, input schema reference, and the async handler function that validates input, fetches sick days from Moco API service, processes data, handles empty results, and returns formatted summary or error.
    export const getUserSickDaysTool = { name: 'get_user_sick_days', description: 'Get all user sick days for a specific year with daily breakdown and total calculations', inputSchema: zodToJsonSchema(GetUserSickDaysSchema), 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 structure for the tool: a required integer year parameter.
    // Schema for get_user_sick_days tool const GetUserSickDaysSchema = z.object({ year: z.number().int().describe('Year to retrieve sick days for (e.g., 2024)') });
  • src/index.ts:34-42 (registration)
    Registers the getUserSickDaysTool in the main AVAILABLE_TOOLS array used by the MCP server for listing available tools and dispatching tool calls.
    const AVAILABLE_TOOLS = [ getActivitiesTool, getUserProjectsTool, getUserProjectTasksTool, getUserHolidaysTool, getUserPresencesTool, getUserSickDaysTool, getPublicHolidaysTool ];
  • src/index.ts:25-25 (registration)
    Imports the getUserSickDaysTool for use in the MCP server.
    import { getUserSickDaysTool } from './tools/userSickDaysTools.js';
  • Helper function that processes raw sick days data into a structured HolidaySummary, calculating partial days from AM/PM flags, sorting by date, and computing totals.
    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 }; }

Other Tools

Related 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