Skip to main content
Glama

get_user_presences

Retrieve user presence data within a specified date range, aggregating daily and calculating totals for time tracking and project management insights.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function for the get_user_presences tool. Validates input dates, fetches presences from Moco API, aggregates them daily, formats summary with statistics, and handles errors.
    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 for the get_user_presences tool: startDate and endDate as ISO date strings.
    // Schema for get_user_presences tool 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 the getUserPresencesTool 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 ];
  • src/index.ts:24-24 (registration)
    Import statement bringing the getUserPresencesTool into the main index file for registration.
    import { getUserPresencesTool } from './tools/userPresencesTools.js';
  • API service method that fetches user presences from MoCo API endpoint '/users/presences' with date range parameters, handling pagination.
    async getUserPresences(startDate: string, endDate: string): Promise<UserPresence[]> { return this.fetchAllPages<UserPresence>('/users/presences', { from: startDate, to: endDate }); }

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