Skip to main content
Glama

update-routine

Modify workout routines by updating titles, notes, and exercise details. Use this tool to edit and apply changes to existing routines while maintaining folder assignments. Returns the updated routine.

Instructions

Update an existing workout routine by ID. You can modify the title, notes, and exercise data. Returns the updated routine with all changes applied. Note that you cannot change the folder assignment through this method.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exercisesYes
notesNo
routineIdYes
titleYes

Implementation Reference

  • Handler function for 'update-routine' tool. Validates hevyClient availability, destructures input args using UpdateRoutineParams type, maps the exercises and sets to the API request format (PutRoutinesRequestExercise and PutRoutinesRequestSet), calls hevyClient.updateRoutine(routineId, payload), handles no-data case, formats the routine with formatRoutine, and returns a pretty JSON response.
    withErrorHandling(async (args) => {
    	if (!hevyClient) {
    		throw new Error(
    			"API client not initialized. Please provide HEVY_API_KEY.",
    		);
    	}
    	const { routineId, title, notes, exercises } =
    		args as UpdateRoutineParams;
    	const data = await hevyClient.updateRoutine(routineId, {
    		routine: {
    			title,
    			notes: notes ?? null,
    			exercises: exercises.map(
    				(exercise): PutRoutinesRequestExercise => ({
    					exercise_template_id: exercise.exerciseTemplateId,
    					superset_id: exercise.supersetId ?? null,
    					rest_seconds: exercise.restSeconds ?? null,
    					notes: exercise.notes ?? null,
    					sets: exercise.sets.map(
    						(set): PutRoutinesRequestSet => ({
    							type: set.type as PutRoutinesRequestSetTypeEnumKey,
    							weight_kg: set.weightKg ?? null,
    							reps: set.reps ?? null,
    							distance_meters: set.distanceMeters ?? null,
    							duration_seconds: set.durationSeconds ?? null,
    							custom_metric: set.customMetric ?? null,
    						}),
    					),
    				}),
    			),
    		},
    	});
    
    	if (!data) {
    		return createEmptyResponse(
    			`Failed to update routine with ID ${routineId}`,
    		);
    	}
    
    	const routine = formatRoutine(data);
    	return createJsonResponse(routine, {
    		pretty: true,
    		indent: 2,
    	});
    }, "update-routine"),
  • Zod schema defining the input parameters for the 'update-routine' tool: required routineId and title (strings), optional notes (string), and exercises array. Each exercise has exerciseTemplateId (string), optional supersetId, restSeconds, notes, and sets array. Each set has type (enum: warmup/normal/failure/dropset, default normal), and optional weightKg, reps, distanceMeters, durationSeconds, customMetric.
    {
    	routineId: z.string().min(1),
    	title: z.string().min(1),
    	notes: z.string().optional(),
    	exercises: z.array(
    		z.object({
    			exerciseTemplateId: z.string().min(1),
    			supersetId: z.coerce.number().nullable().optional(),
    			restSeconds: z.coerce.number().int().min(0).optional(),
    			notes: z.string().optional(),
    			sets: z.array(
    				z.object({
    					type: z
    						.enum(["warmup", "normal", "failure", "dropset"])
    						.default("normal"),
    					weightKg: z.coerce.number().optional(),
    					reps: z.coerce.number().int().optional(),
    					distanceMeters: z.coerce.number().int().optional(),
    					durationSeconds: z.coerce.number().int().optional(),
    					customMetric: z.coerce.number().optional(),
    				}),
    			),
    		}),
    	),
    },
  • Registration of the 'update-routine' MCP tool using server.tool(). Includes the tool name, description (update existing routine by ID, modify title/notes/exercises), input schema, and error-handling wrapped handler function.
    server.tool(
    	"update-routine",
    	"Update an existing routine by ID. You can modify the title, notes, and exercise configurations. Returns the updated routine with all changes applied.",
    	{
    		routineId: z.string().min(1),
    		title: z.string().min(1),
    		notes: z.string().optional(),
    		exercises: z.array(
    			z.object({
    				exerciseTemplateId: z.string().min(1),
    				supersetId: z.coerce.number().nullable().optional(),
    				restSeconds: z.coerce.number().int().min(0).optional(),
    				notes: z.string().optional(),
    				sets: z.array(
    					z.object({
    						type: z
    							.enum(["warmup", "normal", "failure", "dropset"])
    							.default("normal"),
    						weightKg: z.coerce.number().optional(),
    						reps: z.coerce.number().int().optional(),
    						distanceMeters: z.coerce.number().int().optional(),
    						durationSeconds: z.coerce.number().int().optional(),
    						customMetric: z.coerce.number().optional(),
    					}),
    				),
    			}),
    		),
    	},
    	withErrorHandling(async (args) => {
    		if (!hevyClient) {
    			throw new Error(
    				"API client not initialized. Please provide HEVY_API_KEY.",
    			);
    		}
    		const { routineId, title, notes, exercises } =
    			args as UpdateRoutineParams;
    		const data = await hevyClient.updateRoutine(routineId, {
    			routine: {
    				title,
    				notes: notes ?? null,
    				exercises: exercises.map(
    					(exercise): PutRoutinesRequestExercise => ({
    						exercise_template_id: exercise.exerciseTemplateId,
    						superset_id: exercise.supersetId ?? null,
    						rest_seconds: exercise.restSeconds ?? null,
    						notes: exercise.notes ?? null,
    						sets: exercise.sets.map(
    							(set): PutRoutinesRequestSet => ({
    								type: set.type as PutRoutinesRequestSetTypeEnumKey,
    								weight_kg: set.weightKg ?? null,
    								reps: set.reps ?? null,
    								distance_meters: set.distanceMeters ?? null,
    								duration_seconds: set.durationSeconds ?? null,
    								custom_metric: set.customMetric ?? null,
    							}),
    						),
    					}),
    				),
    			},
    		});
    
    		if (!data) {
    			return createEmptyResponse(
    				`Failed to update routine with ID ${routineId}`,
    			);
    		}
    
    		const routine = formatRoutine(data);
    		return createJsonResponse(routine, {
    			pretty: true,
    			indent: 2,
    		});
    	}, "update-routine"),
    );
  • TypeScript type definition UpdateRoutineParams mirroring the tool input schema, used for type assertion in the handler: routineId, title, optional notes, exercises array with structure matching the Zod schema.
    type UpdateRoutineParams = {
    	routineId: string;
    	title: string;
    	notes?: string;
    	exercises: Array<{
    		exerciseTemplateId: string;
    		supersetId?: number | null;
    		restSeconds?: number;
    		notes?: string;
    		sets: Array<{
    			type: "warmup" | "normal" | "failure" | "dropset";
    			weightKg?: number;
    			reps?: number;
    			distanceMeters?: number;
    			durationSeconds?: number;
    			customMetric?: number;
    		}>;
    	}>;
    };
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that this is a mutation operation ('Update'), specifies a constraint ('cannot change the folder assignment'), and mentions the return behavior ('Returns the updated routine with all changes applied'). However, it lacks details about permissions, error conditions, or side effects that would be important for a mutation tool.

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?

Three sentences with zero waste: first states purpose and modifiable fields, second describes return behavior, third provides important constraint. Each sentence adds value, and the structure is front-loaded with the core functionality.

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

Completeness3/5

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

For a mutation tool with 4 parameters, 0% schema coverage, no annotations, and no output schema, the description provides adequate basic information about what can be modified and a key constraint. However, it lacks details about the response format, error handling, or behavioral nuances that would help an agent use it correctly in complex scenarios.

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?

With 0% schema description coverage for 4 parameters, the description compensates by explaining the meaning of key parameters: 'title, notes, and exercise data' map to the title, notes, and exercises parameters. It also clarifies that routineId identifies 'an existing workout routine by ID'. The only gap is that it doesn't explicitly mention all required parameters or their relationships.

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 clearly states the specific action ('Update an existing workout routine by ID'), identifies the resource ('workout routine'), and distinguishes from siblings by specifying it's for updates rather than creation (vs create-routine) or retrieval (vs get-routine). The mention of modifying title, notes, and exercise data provides concrete scope.

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 context by stating it updates 'an existing workout routine by ID' and mentions what cannot be changed ('folder assignment'), which helps differentiate from create-routine. However, it doesn't explicitly state when to use this vs alternatives like update-workout or provide clear exclusions beyond the folder limitation.

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

Related 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