Skip to main content
Glama

get_activities

Retrieve and summarize activities by date, project, and task within a specified range. Filter results by project ID to focus on specific work data in MoCo MCP Server.

Instructions

Get all activities within a date range with automatic summation by date, project, and task. Optionally filter by project ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endDateYesEnd date in ISO 8601 format (YYYY-MM-DD)
projectIdNoOptional project ID to filter activities for a specific project
startDateYesStart date in ISO 8601 format (YYYY-MM-DD)

Implementation Reference

  • The main handler for the get_activities tool. Fetches activities via MocoApiService, aggregates them by date, project, and task using helper functions, handles validation and errors, and returns a formatted summary string.
    export const getActivitiesTool = { name: 'get_activities', description: 'Get all activities within a date range with automatic summation by date, project, and task. Optionally filter by project ID.', inputSchema: zodToJsonSchema(GetActivitiesSchema), handler: async (params: z.infer<typeof GetActivitiesSchema>): Promise<string> => { const { startDate, endDate, projectId } = 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 activities = await apiService.getActivities(startDate, endDate, projectId); if (activities.length === 0) { return createEmptyResultMessage({ type: 'activities', startDate, endDate, projectId }); } const summary = aggregateActivities(activities, startDate, endDate); return formatActivitiesSummary(summary, projectId); } catch (error) { return `Error retrieving activities: ${error instanceof Error ? error.message : 'Unknown error'}`; } } };
  • Zod schema defining input parameters for the get_activities tool: required startDate and endDate as strings, optional positive projectId number.
    const GetActivitiesSchema = 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)'), projectId: z.number().positive().optional().describe('Optional project ID to filter activities for a specific project') });
  • src/index.ts:34-42 (registration)
    Registration of the getActivitiesTool 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 raw activities data from the MoCo API endpoint '/activities' with date range and optional project filter, handling pagination.
    async getActivities(startDate: string, endDate: string, projectId?: number): Promise<Activity[]> { const params: Record<string, string | number> = { from: startDate, to: endDate }; if (projectId) { params.project_id = projectId; } return this.fetchAllPages<Activity>('/activities', params); }

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