Skip to main content
Glama

get-workouts

Retrieve a paginated list of workouts with details like title, timing, and exercises, ordered newest first.

Instructions

Get a paginated list of workouts. Returns workout details including title, description, start/end times, and exercises performed. Results are ordered from newest to oldest.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo
pageSizeNo

Implementation Reference

  • Registration and handler of the 'get-workouts' tool with the MCP server, including schema definition, error handling wrapper, and handler logic that calls hevyClient.getWorkouts() and formats results.
    server.tool(
    	"get-workouts",
    	"Get a paginated list of workouts. Returns workout details including title, description, start/end times, and exercises performed. Results are ordered from newest to oldest.",
    	getWorkoutsSchema,
    	withErrorHandling(async (args: GetWorkoutsParams) => {
    		if (!hevyClient) {
    			throw new Error(
    				"API client not initialized. Please provide HEVY_API_KEY.",
    			);
    		}
    		const { page, pageSize } = args;
    		const data: GetV1Workouts200 = await hevyClient.getWorkouts({
    			page,
    			pageSize,
    		});
    
    		const workouts =
    			data?.workouts?.map((workout) => formatWorkout(workout)) || [];
    
    		if (workouts.length === 0) {
    			return createEmptyResponse(
    				"No workouts found for the specified parameters",
    			);
    		}
    
    		return createJsonResponse(workouts);
    	}, "get-workouts"),
    );
  • Zod schema for get-workouts params: page (number >=1, default 1) and pageSize (integer 1-10, default 5).
    const getWorkoutsSchema = {
    	page: z.coerce.number().gte(1).default(1),
    	pageSize: z.coerce.number().int().gte(1).lte(10).default(5),
    } as const;
  • Helper function that transforms raw Hevy API workout data into a formatted structure with camelCase keys, computed duration, and nested exercise/set formatting.
    export function formatWorkout(workout: Workout): FormattedWorkout {
    	return {
    		id: workout.id,
    		title: workout.title,
    		description: workout.description,
    		startTime: workout.start_time,
    		endTime: workout.end_time,
    		createdAt: workout.created_at,
    		updatedAt: workout.updated_at,
    		duration: calculateDuration(workout.start_time, workout.end_time),
    		exercises: workout.exercises?.map((exercise) => {
    			return {
    				index: exercise.index,
    				name: exercise.title,
    				exerciseTemplateId: exercise.exercise_template_id,
    				notes: exercise.notes,
    				supersetsId: exercise.supersets_id,
    				sets: exercise.sets?.map((set) => ({
    					index: set.index,
    					type: set.type,
    					weight: set.weight_kg,
    					reps: set.reps,
    					distance: set.distance_meters,
    					duration: set.duration_seconds,
    					rpe: set.rpe,
    					customMetric: set.custom_metric,
    				})),
    			};
    		}),
    	};
    }
  • Helper function that creates a standardized MCP response with JSON content, used to format the workouts result.
    export function createJsonResponse(
    	data: unknown,
    	options: JsonFormatOptions = { pretty: true, indent: 2 },
    ): McpToolResponse {
    	const jsonString = options.pretty
    		? JSON.stringify(data, null, options.indent)
    		: JSON.stringify(data);
    
    	return {
    		content: [
    			{
    				type: "text" as const,
    				text: jsonString,
    			},
    		],
    	};
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the burden. It clearly discloses pagination behavior (page, pageSize) and ordering (newest to oldest). This adds value beyond the schema. However, it does not mention rate limits or auth requirements, which are typical but omitted.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with purpose, no redundancy. Every sentence adds value without being verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with two optional parameters and no output schema, the description adequately covers functionality, return contents, and ordering. It could mention default pagination values, but overall is sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. While it does not detail each parameter, it uses 'paginated list' to imply page control, and adds ordering info not in schema. This provides meaning beyond the raw schema, though per-parameter explanation is lacking.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses 'Get a paginated list of workouts' which clearly states the action and resource. It lists included fields (title, description, start/end times, exercises) and ordering, distinguishing it from siblings like get-workout (single) and get-workout-count.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing workouts but provides no explicit guidance on when to use this tool versus alternatives, nor does it mention when not to use it or specify prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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