Skip to main content
Glama

create-routine

Design and save a personalized workout routine in Hevy by specifying title, exercises, sets, and optional folder assignment. Returns the complete routine details with a unique ID for tracking.

Instructions

Create a new workout routine in your Hevy account. Requires title and at least one exercise with sets. Optionally assign to a specific folder. Returns the complete routine details upon successful creation including the newly assigned routine ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exercisesYes
folderIdNo
notesNo
titleYes

Implementation Reference

  • The execution logic for the 'create-routine' tool. Handles input parameters, maps them to the Hevy API request format, calls the API to create the routine, formats the response, and returns it as JSON.
    withErrorHandling(async (args) => {
    	if (!hevyClient) {
    		throw new Error(
    			"API client not initialized. Please provide HEVY_API_KEY.",
    		);
    	}
    	const { title, folderId, notes, exercises } = args as CreateRoutineParams;
    	const data = await hevyClient.createRoutine({
    		routine: {
    			title,
    			folder_id: folderId ?? null,
    			notes: notes ?? "",
    			exercises: exercises.map(
    				(exercise): PostRoutinesRequestExercise => ({
    					exercise_template_id: exercise.exerciseTemplateId,
    					superset_id: exercise.supersetId ?? null,
    					rest_seconds: exercise.restSeconds ?? null,
    					notes: exercise.notes ?? null,
    					sets: exercise.sets.map(
    						(set): PostRoutinesRequestSet => ({
    							type: set.type as PostRoutinesRequestSetTypeEnumKey,
    							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 create routine: Server returned no data",
    		);
    	}
    
    	const routine = formatRoutine(data);
    	return createJsonResponse(routine, {
    		pretty: true,
    		indent: 2,
    	});
    }, "create-routine"),
  • Zod input schema defining the parameters for the 'create-routine' tool: title, optional folderId, notes, and array of exercises with sets.
    {
    	title: z.string().min(1),
    	folderId: z.coerce.number().nullable().optional(),
    	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(),
    				}),
    			),
    		}),
    	),
    },
  • The server.tool() call that registers the 'create-routine' tool with the MCP server, providing name, description, input schema, and handler function.
    server.tool(
    	"create-routine",
    	"Create a new workout routine in your Hevy account. Requires a title and at least one exercise with sets. Optionally assign to a folder. Returns the full routine details including the new routine ID.",
    	{
    		title: z.string().min(1),
    		folderId: z.coerce.number().nullable().optional(),
    		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 { title, folderId, notes, exercises } = args as CreateRoutineParams;
    		const data = await hevyClient.createRoutine({
    			routine: {
    				title,
    				folder_id: folderId ?? null,
    				notes: notes ?? "",
    				exercises: exercises.map(
    					(exercise): PostRoutinesRequestExercise => ({
    						exercise_template_id: exercise.exerciseTemplateId,
    						superset_id: exercise.supersetId ?? null,
    						rest_seconds: exercise.restSeconds ?? null,
    						notes: exercise.notes ?? null,
    						sets: exercise.sets.map(
    							(set): PostRoutinesRequestSet => ({
    								type: set.type as PostRoutinesRequestSetTypeEnumKey,
    								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 create routine: Server returned no data",
    			);
    		}
    
    		const routine = formatRoutine(data);
    		return createJsonResponse(routine, {
    			pretty: true,
    			indent: 2,
    		});
    	}, "create-routine"),
  • TypeScript type definition for CreateRoutineParams used in the handler to type-check the input arguments.
    type CreateRoutineParams = {
    	title: string;
    	folderId?: number | null;
    	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 creation 'returns the complete routine details including the newly assigned routine ID', which is valuable behavioral information. However, it doesn't mention authentication requirements, rate limits, error conditions, or whether this operation is idempotent - significant gaps for a creation 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?

Two efficient sentences that are front-loaded with the core purpose, followed by requirements and optional features, then behavioral outcome. Every word earns its place with no redundancy or unnecessary elaboration.

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 creation tool with 4 parameters, 0% schema coverage, no annotations, and no output schema, the description does an adequate job covering the basics but has significant gaps. It explains what gets created and the return format, but doesn't address error handling, authentication, or provide complete parameter guidance. The output description partially compensates for missing output schema.

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, the description must compensate. It explains that 'title' and 'exercises' are required, mentions 'at least one exercise with sets', and notes optional 'folder' assignment. This covers 3 of 4 parameters at a high level, though it doesn't explain the 'notes' parameter or provide details about exercise/set structure beyond what's obvious from parameter names.

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 ('Create a new workout routine'), resource ('in your Hevy account'), and scope ('requires title and at least one exercise with sets'). It distinguishes from siblings like 'create-routine-folder' (which creates folders) and 'create-workout' (which creates workout instances rather than routines).

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 requirements ('requires title and at least one exercise'), but doesn't explicitly guide when to use this versus alternatives like 'update-routine' or 'create-workout'. It mentions optional folder assignment but doesn't explain when that would be appropriate versus using folder management tools.

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