Skip to main content
Glama
tomekkorbak

Strava MCP Server

by tomekkorbak

get_activity_by_id

Retrieve detailed information about a specific Strava activity using its unique ID to access performance metrics, route data, and workout statistics.

Instructions

Get detailed information about a specific activity.

Args:
    activity_id: ID of the activity to retrieve

Returns:
    Dictionary containing activity details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activity_idYes

Implementation Reference

  • The primary handler for the 'get_activity_by_id' MCP tool. It is registered via the @mcp.tool() decorator, which also infers the input schema from the function signature and docstring. The function retrieves the activity using the StravaClient instance.
    @mcp.tool()
    def get_activity_by_id(activity_id: int) -> dict[str, Any]:
        """
        Get detailed information about a specific activity.
    
        Args:
            activity_id: ID of the activity to retrieve
    
        Returns:
            Dictionary containing activity details
        """
        if strava_client is None:
            return {
                "error": "Strava client not initialized. Please provide refresh token, client ID, and client secret."  # noqa: E501
            }
    
        try:
            activity = strava_client.get_activity(activity_id)
            return {"data": activity}
        except Exception as e:
            return {"error": str(e)}
  • Supporting method in the StravaClient class that performs the actual Strava API request for a specific activity ID and applies field filtering via _filter_activity.
    def get_activity(self, activity_id: int) -> dict:
        """
        Get detailed information about a specific activity.
    
        Args:
            activity_id: ID of the activity to retrieve
    
        Returns:
            Activity details
        """
        activity = self._make_request(f"activities/{activity_id}")
        return self._filter_activity(activity)
  • Helper method that filters and renames fields in the raw Strava activity data to include units and selected keys only.
    def _filter_activity(self, activity: dict) -> dict:
        """Filter activity to only include specific keys and rename with units."""
        # Define field mappings with units
        field_mappings = {
            "calories": "calories",
            "distance": "distance_metres",
            "elapsed_time": "elapsed_time_seconds",
            "elev_high": "elev_high_metres",
            "elev_low": "elev_low_metres",
            "end_latlng": "end_latlng",
            "average_speed": "average_speed_mps",  # metres per second
            "max_speed": "max_speed_mps",  # metres per second
            "moving_time": "moving_time_seconds",
            "sport_type": "sport_type",
            "start_date": "start_date",
            "start_latlng": "start_latlng",
            "total_elevation_gain": "total_elevation_gain_metres",
            "name": "name",  # Keep name for display purposes
        }
    
        # Create a new dictionary with renamed fields
        filtered_activity = {}
        for old_key, new_key in field_mappings.items():
            if old_key in activity:
                filtered_activity[new_key] = activity[old_key]
    
        return filtered_activity
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 information, implying it is read-only, but does not specify authentication needs, rate limits, error handling, or what 'detailed information' entails. The description lacks behavioral context beyond the basic 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 appropriately sized and front-loaded with the purpose in the first sentence. The 'Args' and 'Returns' sections add structure, but the return description ('Dictionary containing activity details') is vague and could be more informative. Overall, it is concise with little waste.

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 no annotations, no output schema, and low schema coverage, the description is incomplete. It does not explain what 'detailed information' includes, potential errors, or how this tool fits with siblings. For a retrieval tool with undocumented behavior and output, more context is needed to guide effective use.

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: it names the parameter ('activity_id') and states it is 'ID of the activity to retrieve,' which clarifies the parameter's role. However, with 0% schema description coverage and only one parameter, the baseline is 4, but the description does not fully compensate by explaining format constraints or examples, so it scores slightly lower.

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 detailed information about a specific activity.' It specifies the verb ('Get') and resource ('activity'), but does not differentiate from sibling tools like 'get_activities' or 'get_activities_by_date_range' beyond implying retrieval of a single activity by ID.

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 does not mention sibling tools or contexts where this tool is preferred, such as for retrieving a single known activity versus listing multiple activities. Usage is implied by the parameter name but not explicitly stated.

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