Skip to main content
Glama

get_user_holidays

Retrieve user holidays for a specific year, including utilization calculations and remaining vacation days, via the MoCo MCP Server integration.

Instructions

Get all user holidays for a specific year with utilization calculations and remaining vacation days

Input Schema

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

Implementation Reference

  • The main handler function that validates the year input, fetches holiday entitlements and taken holidays using MocoApiService, processes the data into a summary, and returns a formatted string response.
    handler: async (params: z.infer<typeof GetUserHolidaysSchema>): Promise<string> => { const { year } = params; // Validate year if (!validateYear(year)) { return createValidationErrorMessage({ field: 'year', value: year, reason: 'invalid_year' }); } try { const apiService = new MocoApiService(); // Get both entitlements and actual taken holidays let entitlements: any[] = []; let takenHolidays: any[] = []; try { entitlements = await apiService.getUserHolidays(year); } catch (error) { console.error('DEBUG: Failed to get entitlements:', error); } try { console.error('DEBUG: About to call getTakenHolidays...'); takenHolidays = await apiService.getTakenHolidays(year); console.error('DEBUG: getTakenHolidays returned:', takenHolidays.length, 'items'); } catch (error) { console.error('DEBUG: Failed to get taken holidays:', error); console.error('DEBUG: Error details:', error instanceof Error ? error.message : 'Unknown error'); } // Debug logging console.error(`DEBUG: Got ${entitlements.length} entitlements and ${takenHolidays.length} taken holidays for year ${year}`); console.error('DEBUG: Entitlements:', JSON.stringify(entitlements, null, 2)); console.error('DEBUG: Taken holidays:', JSON.stringify(takenHolidays, null, 2)); if (takenHolidays.length === 0) { // Show entitlement info if available, otherwise just empty return formatHolidaysWithNoData(year, entitlements); } const summary = createHolidaySummary(takenHolidays, entitlements, year); console.error('DEBUG: Summary created:', JSON.stringify(summary, null, 2)); return formatHolidaysSummary(summary); } catch (error) { return `Error retrieving holidays for ${year}: ${error instanceof Error ? error.message : 'Unknown error'}`; } }
  • Zod schema defining the input validation for the tool, requiring a single 'year' parameter as an integer.
    // Schema for get_user_holidays tool const GetUserHolidaysSchema = z.object({ year: z.number().int().describe('Year to retrieve holidays for (e.g., 2024)') });
  • src/index.ts:34-42 (registration)
    Registers the getUserHolidaysTool in the AVAILABLE_TOOLS array, which is used by the MCP server for tool listing and execution dispatching.
    const AVAILABLE_TOOLS = [ getActivitiesTool, getUserProjectsTool, getUserProjectTasksTool, getUserHolidaysTool, getUserPresencesTool, getUserSickDaysTool, getPublicHolidaysTool ];
  • Helper method in MocoApiService that fetches user holiday entitlements for the specified year from the MoCo API endpoint '/users/holidays', handling 404 errors gracefully by returning an empty array.
    async getUserHolidays(year: number): Promise<UserHoliday[]> { try { return await this.makeRequest<UserHoliday[]>('/users/holidays', { year: year }); } catch (error) { // If 404 error (Resource not found), return empty array instead of throwing error // This happens when no holiday data exists for the year yet if (error instanceof Error && error.message.includes('Resource not found')) { return []; } // Re-throw other errors throw error; }

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