get-routines
Retrieve a paginated list of routines with details such as title, creation date, folder assignment, and exercise configurations. Supports both default and custom routines for efficient fitness data management.
Instructions
Get a paginated list of routines. Returns routine details including title, creation date, folder assignment, and exercise configurations. Results include both default and custom routines.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | ||
| pageSize | No |
Implementation Reference
- src/tools/routines.ts:81-104 (handler)Handler function for the 'get-routines' tool. Fetches paginated list of routines from Hevy API using hevyClient.getRoutines, formats each routine using formatRoutine, and returns JSON response or empty response if none found.withErrorHandling(async (args) => { if (!hevyClient) { throw new Error( "API client not initialized. Please provide HEVY_API_KEY.", ); } const { page, pageSize } = args as { page: number; pageSize: number }; const data = await hevyClient.getRoutines({ page, pageSize, }); // Process routines to extract relevant information const routines = data?.routines?.map((routine: Routine) => formatRoutine(routine)) || []; if (routines.length === 0) { return createEmptyResponse( "No routines found for the specified parameters", ); } return createJsonResponse(routines); }, "get-routines"),
- src/tools/routines.ts:77-80 (schema)Input schema using Zod for the 'get-routines' tool, defining optional parameters 'page' (min 1, default 1) and 'pageSize' (1-10, default 5).{ page: z.coerce.number().int().gte(1).default(1), pageSize: z.coerce.number().int().gte(1).lte(10).default(5), },
- src/tools/routines.ts:75-105 (registration)Registration of the 'get-routines' MCP tool using server.tool, including name, description, input schema, and wrapped handler."get-routines", "Get a paginated list of your workout routines, including custom and default routines. Useful for browsing or searching your available routines.", { page: z.coerce.number().int().gte(1).default(1), pageSize: z.coerce.number().int().gte(1).lte(10).default(5), }, withErrorHandling(async (args) => { if (!hevyClient) { throw new Error( "API client not initialized. Please provide HEVY_API_KEY.", ); } const { page, pageSize } = args as { page: number; pageSize: number }; const data = await hevyClient.getRoutines({ page, pageSize, }); // Process routines to extract relevant information const routines = data?.routines?.map((routine: Routine) => formatRoutine(routine)) || []; if (routines.length === 0) { return createEmptyResponse( "No routines found for the specified parameters", ); } return createJsonResponse(routines); }, "get-routines"), );