Skip to main content
Glama

get-workout

Retrieve detailed workout information by ID, including title, description, start/end times, and exercise data, using the Hevy MCP server.

Instructions

Get complete details of a specific workout by ID. Returns all workout information including title, description, start/end times, and detailed exercise data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workoutIdYes

Implementation Reference

  • Handler for the 'get-workout' tool: validates input, checks hevyClient availability, fetches workout by ID, formats it, and returns JSON or empty response if not found.
    server.tool(
    	"get-workout",
    	"Get complete details of a specific workout by ID. Returns all workout information including title, description, start/end times, and detailed exercise data.",
    	{
    		workoutId: z.string().min(1),
    	},
    	withErrorHandling(async ({ workoutId }) => {
    		if (!hevyClient) {
    			throw new Error(
    				"API client not initialized. Please provide HEVY_API_KEY.",
    			);
    		}
    		const data = await hevyClient.getWorkout(workoutId);
    
    		if (!data) {
    			return createEmptyResponse(`Workout with ID ${workoutId} not found`);
    		}
    
    		const workout = formatWorkout(data);
    		return createJsonResponse(workout);
    	}, "get-workout"),
    );
  • Input schema for 'get-workout' tool: requires 'workoutId' as non-empty string.
    {
    	workoutId: z.string().min(1),
    },
  • src/index.ts:40-40 (registration)
    Top-level call to register all workout tools, including 'get-workout'.
    registerWorkoutTools(server, hevyClient);
  • Supporting helper function formatWorkout used in the handler to standardize workout data structure, including computed duration and flattened exercise/set details.
    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,
    				})),
    			};
    		}),
    	};
    }

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