get-workout-events
Sync workout updates efficiently by retrieving a paged list of events since a specified date. Enables clients to update local workout caches without fetching full datasets.
Instructions
Retrieve a paged list of workout events (updates or deletes) since a given date. Events are ordered from newest to oldest. The intention is to allow clients to keep their local cache of workouts up to date without having to fetch the entire list of workouts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | ||
| pageSize | No | ||
| since | No | 1970-01-01T00:00:00Z |
Implementation Reference
- src/tools/workouts.ts:133-154 (handler)Handler function that executes the 'get-workout-events' tool logic: validates inputs, calls hevyClient.getWorkoutEvents(page, pageSize, since), processes events, and returns JSON or empty response.withErrorHandling(async ({ page, pageSize, since }) => { if (!hevyClient) { throw new Error( "API client not initialized. Please provide HEVY_API_KEY.", ); } const data = await hevyClient.getWorkoutEvents({ page, pageSize, since, }); const events = data?.events || []; if (events.length === 0) { return createEmptyResponse( `No workout events found for the specified parameters since ${since}`, ); } return createJsonResponse(events); }, "get-workout-events"),
- src/tools/workouts.ts:128-132 (schema)Zod input schema for the tool defining parameters: page (int >=1 default 1), pageSize (int 1-10 default 5), since (string default '1970-01-01T00:00:00Z').{ page: z.coerce.number().int().gte(1).default(1), pageSize: z.coerce.number().int().gte(1).lte(10).default(5), since: z.string().default("1970-01-01T00:00:00Z"), },
- src/tools/workouts.ts:125-155 (registration)MCP server.tool registration for 'get-workout-events' including name, description, input schema, and wrapped handler.server.tool( "get-workout-events", "Retrieve a paged list of workout events (updates or deletes) since a given date. Events are ordered from newest to oldest. The intention is to allow clients to keep their local cache of workouts up to date without having to fetch the entire list of workouts.", { page: z.coerce.number().int().gte(1).default(1), pageSize: z.coerce.number().int().gte(1).lte(10).default(5), since: z.string().default("1970-01-01T00:00:00Z"), }, withErrorHandling(async ({ page, pageSize, since }) => { if (!hevyClient) { throw new Error( "API client not initialized. Please provide HEVY_API_KEY.", ); } const data = await hevyClient.getWorkoutEvents({ page, pageSize, since, }); const events = data?.events || []; if (events.length === 0) { return createEmptyResponse( `No workout events found for the specified parameters since ${since}`, ); } return createJsonResponse(events); }, "get-workout-events"), );
- src/index.ts:40-40 (registration)Top-level call to registerWorkoutTools(server, hevyClient) which registers the 'get-workout-events' tool among others.registerWorkoutTools(server, hevyClient);