Skip to main content
Glama
tomekkorbak

Strava MCP Server

by tomekkorbak

get_activities_by_date_range

Retrieve Strava activities within a specified date range using start and end dates in ISO format. Filter and access workout data for analysis or reporting.

Instructions

Get activities within a specific date range.

Args:
    start_date: Start date in ISO format (YYYY-MM-DD)
    end_date: End date in ISO format (YYYY-MM-DD)
    limit: Maximum number of activities to return (default: 30)

Returns:
    Dictionary containing activities data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes
limitNo

Implementation Reference

  • The handler function for the 'get_activities_by_date_range' tool, decorated with @mcp.tool() for registration. Parses input dates, queries Strava API via client, and returns activities or error.
    @mcp.tool()
    def get_activities_by_date_range(start_date: str, end_date: str, limit: int = 30) -> dict[str, Any]:
        """
        Get activities within a specific date range.
    
        Args:
            start_date: Start date in ISO format (YYYY-MM-DD)
            end_date: End date in ISO format (YYYY-MM-DD)
            limit: Maximum number of activities to return (default: 30)
    
        Returns:
            Dictionary containing activities data
        """
        if strava_client is None:
            return {
                "error": "Strava client not initialized. Please provide refresh token, client ID, and client secret."  # noqa: E501
            }
    
        try:
            start = parse_date(start_date)
            end = parse_date(end_date)
    
            # Convert dates to timestamps
            after = int(datetime.combine(start, datetime.min.time()).timestamp())
            before = int(datetime.combine(end, datetime.max.time()).timestamp())
    
            activities = strava_client.get_activities(limit=limit, before=before, after=after)
            return {"data": activities}
        except Exception as e:
            return {"error": str(e)}
  • Helper function to parse ISO date strings, used in the tool handler to convert start_date and end_date.
    def parse_date(date_str: str) -> date:
        """
        Parse a date string in ISO format (YYYY-MM-DD).
    
        Args:
            date_str: Date string in ISO format
    
        Returns:
            Date object
        """
        try:
            return date.fromisoformat(date_str)
        except ValueError as err:
            raise ValueError(f"Invalid date format: {date_str}. Expected format: YYYY-MM-DD") from err
  • StravaClient method called by the tool handler to fetch activities from Strava API using the computed timestamps.
    def get_activities(
        self, limit: int = 10, before: Optional[int] = None, after: Optional[int] = None
    ) -> list:
        """
        Get the authenticated athlete's activities.
    
        Args:
            limit: Maximum number of activities to return
            before: Unix timestamp to filter activities before this time
            after: Unix timestamp to filter activities after this time
    
        Returns:
            List of activities
        """
        params = {"per_page": limit}
    
        if before:
            params["before"] = before
    
        if after:
            params["after"] = after
    
        activities = self._make_request("athlete/activities", params)
        return self._filter_activities(activities)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves activities but doesn't mention critical aspects like whether it's read-only, requires authentication, has rate limits, or pagination behavior. For a tool with 3 parameters and no annotations, this leaves significant gaps in understanding its operation.

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 well-structured with clear sections for Args and Returns, using bullet points for readability. It's front-loaded with the core purpose and efficiently explains parameters without unnecessary details. However, the 'Returns' section is vague ('Dictionary containing activities data'), slightly reducing efficiency.

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 moderate complexity (3 parameters, no output schema, no annotations), the description is partially complete. It excels in parameter semantics but lacks behavioral context and usage guidelines. Without an output schema, the vague return statement ('Dictionary containing activities data') is a minor gap, but overall, it meets a baseline for a read operation tool.

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

Parameters5/5

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

The description adds substantial value beyond the input schema, which has 0% schema description coverage. It explicitly defines each parameter's purpose and format (e.g., 'start_date: Start date in ISO format (YYYY-MM-DD)'), including the default for 'limit.' This fully compensates for the lack of schema descriptions, making parameters clear and actionable.

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 as 'Get activities within a specific date range,' which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'get_activities' or 'get_recent_activities,' which likely have overlapping functionality.

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 like 'get_activities' or 'get_recent_activities.' It mentions date range filtering but doesn't specify scenarios where this is preferred over other tools, leaving the agent without clear usage context.

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

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