Skip to main content
Glama

get-exercise-templates

Retrieve a paginated list of exercise templates, including default and custom options, with details like title, type, and muscle groups. Supports up to 100 templates per page for efficient workout planning.

Instructions

Get a paginated list of exercise templates available on the account. Returns both default and custom exercise templates with details including title, type, primary muscle group, and secondary muscle groups. Supports up to 100 templates per page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
pageSizeNo

Implementation Reference

  • The main handler function that implements the tool logic: fetches paginated exercise templates from Hevy API, formats them using formatExerciseTemplate, and returns a JSON response or empty response if none found.
    async ({ page, pageSize }: { page: number; pageSize: number }) => { if (!hevyClient) { throw new Error( "API client not initialized. Please provide HEVY_API_KEY.", ); } const data = await hevyClient.getExerciseTemplates({ page, pageSize, }); // Process exercise templates to extract relevant information const templates = data?.exercise_templates?.map((template: ExerciseTemplate) => formatExerciseTemplate(template), ) || []; if (templates.length === 0) { return createEmptyResponse( "No exercise templates found for the specified parameters", ); } return createJsonResponse(templates); },
  • Zod input schema defining pagination parameters: page (default 1) and pageSize (default 5, max 100).
    page: z.coerce.number().int().gte(1).default(1), pageSize: z.coerce.number().int().gte(1).lte(100).default(5), },
  • Registers the 'get-exercise-templates' MCP tool with server.tool, providing name, description, input schema, and error-wrapped handler.
    "get-exercise-templates", "Get a paginated list of exercise templates (default and custom) with details like name, category, equipment, and muscle groups. Useful for browsing or searching available exercises.", { page: z.coerce.number().int().gte(1).default(1), pageSize: z.coerce.number().int().gte(1).lte(100).default(5), }, withErrorHandling( async ({ page, pageSize }: { page: number; pageSize: number }) => { if (!hevyClient) { throw new Error( "API client not initialized. Please provide HEVY_API_KEY.", ); } const data = await hevyClient.getExerciseTemplates({ page, pageSize, }); // Process exercise templates to extract relevant information const templates = data?.exercise_templates?.map((template: ExerciseTemplate) => formatExerciseTemplate(template), ) || []; if (templates.length === 0) { return createEmptyResponse( "No exercise templates found for the specified parameters", ); } return createJsonResponse(templates); }, "get-exercise-templates", ), );
  • Supporting helper that formats raw ExerciseTemplate from API into a standardized response object with key fields like id, title, type, muscle groups, and isCustom flag.
    export function formatExerciseTemplate( template: ExerciseTemplate, ): FormattedExerciseTemplate { return { id: template.id, title: template.title, type: template.type, primaryMuscleGroup: template.primary_muscle_group, secondaryMuscleGroups: template.secondary_muscle_groups, isCustom: template.is_custom, }; }
  • src/index.ts:42-42 (registration)
    Top-level invocation of registerTemplateTools in the main server setup, which registers the get-exercise-templates tool among others.
    registerTemplateTools(server, hevyClient);

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/chrisdoc/hevy-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server