Skip to main content
Glama

update_routine

Update an existing workout routine by providing its ID and the modified routine details.

Instructions

Update an existing routine in place.

Same payload shape as create_routine.routine, with one important caveat: Hevy's PUT endpoint does NOT accept folder_id, and there is no public API endpoint for moving a routine between folders. If folder_id is present in the payload it is silently stripped and a warning is included in the response. To 'move' a routine, create a new copy in the target folder and delete the old one in the Hevy app.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
routine_idYes
routineYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core execution function for update_routine: validates routine dict via Pydantic, sanitizes out server-managed fields (folder_id, id, created_at, updated_at, index), makes PUT /routines/{id} call to Hevy API, and surfaces a warning if folder_id was ignored.
    async def _do_update_routine(
        client, routine_id: str, routine: dict[str, Any],
    ) -> dict[str, Any]:
        """Module-level body of the update_routine tool — kept testable without FastMCP.
    
        Sanitizes the payload (drops folder_id and a few server-managed fields) and
        surfaces a `warning` field to the caller if folder_id was explicitly set, so
        users notice the silent no-op rather than thinking the move worked.
        """
        validated = Routine.model_validate(routine).model_dump(exclude_none=True)
        sanitized, folder_id_was_present = _sanitize_routine_for_put(validated)
        data = await client.put(f"/routines/{routine_id}", json={"routine": sanitized})
        out: dict[str, Any] = {"text": "Routine updated.", "data": data}
        if folder_id_was_present:
            out["warning"] = _FOLDER_MOVE_WARNING
        return out
  • MCP tool registration of update_routine: decorated with @mcp.tool() and @tool_guard, accepts routine_id and routine dict, delegates to _do_update_routine.
    @mcp.tool()
    @tool_guard
    async def update_routine(routine_id: str, routine: dict[str, Any]) -> dict[str, Any]:
        """Update an existing routine in place.
    
        Same payload shape as `create_routine.routine`, with one important caveat:
        Hevy's PUT endpoint does NOT accept `folder_id`, and there is no public API
        endpoint for moving a routine between folders. If `folder_id` is present in
        the payload it is silently stripped and a `warning` is included in the
        response. To 'move' a routine, create a new copy in the target folder and
        delete the old one in the Hevy app.
        """
        return await _do_update_routine(client, routine_id, routine)
  • Tool registration via @mcp.tool() decorator inside the register() function of routines.py. The register() function is called from tools/__init__.py which is called from server.py.
    @mcp.tool()
    @tool_guard
    async def update_routine(routine_id: str, routine: dict[str, Any]) -> dict[str, Any]:
        """Update an existing routine in place.
    
        Same payload shape as `create_routine.routine`, with one important caveat:
        Hevy's PUT endpoint does NOT accept `folder_id`, and there is no public API
        endpoint for moving a routine between folders. If `folder_id` is present in
        the payload it is silently stripped and a `warning` is included in the
        response. To 'move' a routine, create a new copy in the target folder and
        delete the old one in the Hevy app.
        """
        return await _do_update_routine(client, routine_id, routine)
  • Pydantic model for Routine used by _do_update_routine for validation (Routine.model_validate). Defines the accepted input shape.
    class Routine(_Base):
        id: str | None = None
        title: str
        folder_id: int | None = None
        notes: str | None = None
        exercises: list[RoutineExercise] = Field(default_factory=list)
  • Helper that strips fields (id, folder_id, created_at, updated_at, index) from the routine dict before sending to Hevy's PUT endpoint, and reports whether folder_id was present for warning purposes.
    def _sanitize_routine_for_put(routine: dict[str, Any]) -> tuple[dict[str, Any], bool]:
        """Strip fields that PUT /routines/{id} rejects.
    
        Returns ``(cleaned, folder_id_was_explicitly_set)``. The boolean lets the
        caller surface a warning to the user that folder reassignment is not
        supported by Hevy's API.
        """
        folder_id_was_present = routine.get("folder_id") is not None
        cleaned = {k: v for k, v in routine.items() if k not in _PUT_ROUTINE_DROP_TOP}
        return cleaned, folder_id_was_present
Behavior3/5

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

The description discloses the important behavioral trait that folder_id is silently stripped with a warning, but it does not mention other potential side effects, partial update behavior, or return value specifics. With no annotations, the burden is higher, and the coverage is partial.

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

Conciseness4/5

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

The description is concise with a clear main statement followed by a focused caveat. It front-loads the purpose and appends necessary details without extraneous information.

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

Completeness2/5

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

Given the absence of annotations and 0% schema description coverage, the description leaves significant gaps, such as not explaining return values, required permissions, or other behavioral nuances beyond the folder_id quirk. It relies on external references (create_routine) that are not fully available here.

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

Parameters3/5

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

The description adds meaning by referencing the payload shape from create_routine and noting the folder_id behavior, which supplements the schema (which has 0% description coverage). However, it does not explain the structure of the routine parameter in detail.

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

Purpose4/5

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

The description clearly states the tool updates an existing routine and references the payload shape from create_routine, making the purpose evident. However, it does not explicitly distinguish from create_routine beyond the folder_id caveat, which slightly reduces clarity.

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

Usage Guidelines4/5

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

The description provides a specific workaround for moving routines (create new copy and delete old), which serves as an alternative usage scenario. However, it lacks general guidance on when to use this tool versus create_routine or other siblings.

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

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