Skip to main content
Glama

get_activity_laps_tool

Retrieve lap breakdowns for Strava activities to analyze workout segments and performance metrics.

Instructions

Get lap breakdowns for a specific activity.

Args: activity_id: The ID of the activity to retrieve laps for

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activity_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool registration and handler for get_activity_laps_tool. Decorated with @mcp.tool(), this function accepts activity_id parameter, authenticates the client, calls get_activity_laps service function, and returns lap data as list of dictionaries.
    @mcp.tool()
    def get_activity_laps_tool(activity_id: int) -> list[dict]:
        """
        Get lap breakdowns for a specific activity.
    
        Args:
            activity_id: The ID of the activity to retrieve laps for
        """
        client = get_client()
        laps = get_activity_laps(client, activity_id)
        return [lap.to_dict() for lap in laps]
  • Core implementation of get_activity_laps. Fetches lap data from Strava API using client.get_activity_laps(), processes each lap's attributes (moving_time, elapsed_time, distance, speed, cadence, watts, heartrate, elevation), and converts them to LapSummary objects.
    def get_activity_laps(client: Client, activity_id: int) -> list[LapSummary]:
        """Get lap breakdowns for a specific activity."""
        laps = client.get_activity_laps(activity_id)
    
        result = []
        for lap in laps:
            moving_time = getattr(lap.moving_time, "seconds", 0) if lap.moving_time else 0
            elapsed_time = (
                getattr(lap.elapsed_time, "seconds", 0) if lap.elapsed_time else 0
            )
    
            summary = LapSummary(
                id=lap.id or 0,
                activity_id=getattr(lap, "activity_id", 0) or 0,
                lap_index=getattr(lap, "lap_index", 0),
                name=lap.name or "",
                elapsed_time=elapsed_time,
                moving_time=moving_time,
                distance=float(lap.distance) if lap.distance else 0.0,
                average_speed=float(lap.average_speed) if lap.average_speed else 0.0,
                max_speed=float(lap.max_speed) if lap.max_speed else 0.0,
                average_cadence=float(lap.average_cadence) if lap.average_cadence else None,
                average_watts=float(lap.average_watts) if lap.average_watts else None,
                average_heartrate=float(lap.average_heartrate)
                if lap.average_heartrate
                else None,
                max_heartrate=float(lap.max_heartrate) if lap.max_heartrate else None,
                total_elevation_gain=float(lap.total_elevation_gain)
                if lap.total_elevation_gain
                else 0.0,
            )
            result.append(summary)
        return result
  • LapSummary dataclass schema defining the structure of lap data returned by get_activity_laps_tool. Contains fields: id, activity_id, lap_index, name, elapsed_time, moving_time, distance, average_speed, max_speed, average_cadence, average_watts, average_heartrate, max_heartrate, total_elevation_gain. Includes to_dict() method for serialization.
    @dataclass
    class LapSummary:
        """Summary of a lap in a Strava activity."""
    
        id: int
        activity_id: int
        lap_index: int
        name: str
        elapsed_time: int
        moving_time: int
        distance: float
        average_speed: float
        max_speed: float
        average_cadence: Optional[float]
        average_watts: Optional[float]
        average_heartrate: Optional[float]
        max_heartrate: Optional[float]
        total_elevation_gain: float
    
        def to_dict(self) -> dict:
            """Convert to dictionary for serialization."""
            return asdict(self)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read operation, but doesn't cover critical aspects like authentication requirements, rate limits, error handling, or what 'lap breakdowns' entail (e.g., format, data fields). This is a significant gap for a tool with no annotation coverage.

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 appropriately sized and front-loaded: the first sentence states the purpose clearly, and the 'Args' section is brief. However, the 'Args' formatting is slightly redundant since the schema already defines the parameter, but it doesn't add unnecessary length. Overall, it's efficient with minimal waste.

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?

Given the tool's low complexity (1 parameter) and the presence of an output schema (which handles return values), the description is somewhat complete. However, it lacks usage guidelines and behavioral details, which are important for effective tool invocation. This makes it minimally viable but with clear gaps in context.

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 minimal semantics beyond the input schema. It explains that 'activity_id' is 'The ID of the activity to retrieve laps for,' which clarifies the parameter's purpose but doesn't provide format details (e.g., integer type, source). With 0% schema description coverage and only 1 parameter, this is adequate but not comprehensive, aligning with the baseline for low coverage.

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's purpose: 'Get lap breakdowns for a specific activity.' This includes a specific verb ('Get') and resource ('lap breakdowns'), and it distinguishes the tool from siblings like 'get_activity_details_tool' or 'get_activity_streams_tool' by focusing on laps. However, it doesn't explicitly contrast with siblings, so it's not a perfect 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an activity ID from another tool), exclusions, or comparisons to siblings like 'get_activity_details_tool' or 'get_activity_streams_tool'. This leaves the agent without context for tool selection.

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/saxenanurag/strava-mcp'

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