Skip to main content
Glama

list_activities_tool

Retrieve recent workout sessions from Strava to track athletic performance and training history.

Instructions

List recent activities for the authenticated athlete.

Args: limit: Number of activities to return (default 5)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:38-51 (handler)
    Main MCP tool handler for list_activities_tool. Decorated with @mcp.tool() for registration. Validates limit parameter (clamps to MAX_LIMIT=200), gets Strava client, calls list_activities service function, and returns list of dictionaries.
    @mcp.tool()
    def list_activities_tool(limit: int = 5) -> list[dict]:
        """
        List recent activities for the authenticated athlete.
    
        Args:
            limit: Number of activities to return (default 5)
        """
        if limit > MAX_LIMIT:
            limit = MAX_LIMIT
    
        client = get_client()
        activities = list_activities(client, limit)
        return [activity.to_dict() for activity in activities]
  • Service function that fetches activities from Strava API using client.get_activities(). Handles safe extraction of moving_time and creates ActivitySummary dataclass instances with all relevant activity fields.
    def list_activities(client: Client, limit: int) -> list[ActivitySummary]:
        """List recent activities for the authenticated athlete."""
        activities = client.get_activities(limit=limit)
    
        result = []
        for activity in activities:
            # Handle moving_time safely
            moving_time = (
                getattr(activity.moving_time, "seconds", 0) if activity.moving_time else 0
            )
    
            summary = ActivitySummary(
                id=activity.id or 0,
                name=activity.name or "",
                type=str(activity.type),
                start_date=activity.start_date.isoformat() if activity.start_date else None,
                distance=float(activity.distance) if activity.distance else 0.0,
                moving_time=moving_time,
                total_elevation_gain=float(activity.total_elevation_gain)
                if activity.total_elevation_gain
                else 0.0,
                average_speed=float(activity.average_speed or 0.0),
                max_speed=float(activity.max_speed or 0.0),
            )
            result.append(summary)
        return result
  • ActivitySummary dataclass schema defining the structure of activity data returned by list_activities_tool. Includes fields like id, name, type, start_date, distance, moving_time, elevation_gain, and speeds. Provides to_dict() method for serialization.
    @dataclass
    class ActivitySummary:
        """Summary of a Strava activity."""
    
        id: int
        name: str
        type: str
        start_date: Optional[str]
        distance: float
        moving_time: int
        total_elevation_gain: float
        average_speed: float = 0.0
        max_speed: float = 0.0
    
        def to_dict(self) -> dict:
            """Convert to dictionary for serialization."""
            return asdict(self)
  • MAX_LIMIT constant (200) and FastMCP initialization. The MAX_LIMIT is used by list_activities_tool to clamp the limit parameter and prevent excessive API requests.
    # Constants
    MAX_LIMIT = 200
    
    # Initialize FastMCP
    mcp = FastMCP("strava-server")
  • Test verifying that list_activities_tool correctly clamps excessive limit values to MAX_LIMIT. Uses mocking to test the limit validation logic without making actual API calls.
    @patch("server.get_client")
    @patch("server.list_activities")
    def test_list_activities_tool_limit_clamping(mock_list_activities, mock_get_client):
        # Setup
        mock_client = MagicMock()
        mock_get_client.return_value = mock_client
        mock_list_activities.return_value = []
    
        # Test with limit > MAX_LIMIT
        excessive_limit = MAX_LIMIT + 100
        list_activities_tool.fn(limit=excessive_limit)
    
        # Verify list_activities was called with MAX_LIMIT
        mock_list_activities.assert_called_once_with(mock_client, MAX_LIMIT)
    
        # Verify list_activities was called with MAX_LIMIT
        mock_list_activities.assert_called_once_with(mock_client, MAX_LIMIT)
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 mentions 'recent activities' but does not specify what 'recent' means (e.g., time range, ordering), whether it requires authentication beyond the athlete context, or any rate limits or pagination behavior. This leaves significant gaps in understanding the tool's behavior.

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, with the main purpose stated first followed by parameter details. It avoids unnecessary verbosity, though the structure could be slightly improved by integrating the parameter explanation more seamlessly rather than as a separate 'Args:' section.

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, the description is somewhat complete but has gaps. It covers the basic purpose and parameter, but lacks behavioral details and usage guidelines. The output schema likely handles return values, so the description's focus on input is acceptable, though more context would enhance completeness.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining that 'limit' is the 'Number of activities to return' with a default of 5, which clarifies the parameter's purpose beyond the schema's type and default. However, it does not cover constraints like minimum/maximum values or other potential parameters, leaving some ambiguity.

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 verb ('List') and resource ('recent activities for the authenticated athlete'), making the purpose specific and understandable. However, it does not explicitly distinguish this tool from sibling tools like 'search_activities_tool' or 'get_activity_details_tool', which limits its differentiation in context.

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 such as 'search_activities_tool' or 'get_activity_details_tool'. It lacks context on use cases, prerequisites, or exclusions, leaving the agent to infer usage based on tool names alone.

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