Skip to main content
Glama
rbctmz

mcp-server-strava

get_activity_by_id

Retrieve detailed activity information from Strava by providing a specific activity ID. Returns metrics like type, distance, time, and other performance data for analysis.

Instructions

Get activity details from Strava

Args:
    activity_id (Union[str, int]): Activity ID to fetch
    
Returns:
    Dict: Activity details including type, distance, time and other metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activity_idYes

Implementation Reference

  • The main MCP tool handler for 'get_activity_by_id'. Decorated with @mcp.tool() for registration. Fetches activity details via helper function, adds metadata, and handles errors.
    @mcp.tool()  # Убираем name параметр
    async def get_activity_by_id(activity_id: Union[str, int]) -> Dict:
        """Get activity details from Strava
        
        Args:
            activity_id (Union[str, int]): Activity ID to fetch
            
        Returns:
            Dict: Activity details including type, distance, time and other metrics
        """
        try:
            activity_id = str(activity_id)
            activity = get_activity(activity_id)
            
            return {
                "status": "success",
                "data": activity,
                "metadata": {
                    "activity_id": activity_id,
                    "timestamp": datetime.now().isoformat()
                }
            }
        except Exception as e:
            logger.error(f"Error getting activity {activity_id}: {e}")
            return {
                "status": "error",
                "error": str(e),
                "activity_id": activity_id
            }
  • Helper resource function that performs the actual Strava API call to fetch activity details, with caching and error handling. Called by the main tool handler.
    @resource_error_handler
    @mcp.resource("strava://activities/{activity_id}")
    def get_activity(activity_id: str) -> dict:
        """Получить детали конкретной активности"""
        cache_key = f"activity_{activity_id}"
        
        # Проверяем кэш
        cached = strava_cache.get(cache_key)
        if cached:
            logger.debug(f"Возвращаем активность {activity_id} из кэша")
            return cached
        
        try:
            access_token = strava_auth.get_access_token()
            response = strava_auth.make_request(
                "GET",
                f"/activities/{activity_id}",
                headers={"Authorization": f"Bearer {access_token}"},
            )
            
            activity = response.json()
            
            # Сохраняем в кэш
            strava_cache.set(cache_key, activity)
            logger.info(f"Получена и закэширована активность {activity_id}: {activity.get('type')}")
            
            return activity
    
        except Exception as e:
            logger.error(f"Ошибка получения активности {activity_id}: {e}")
            if isinstance(e, requests.exceptions.RequestException):
                raise StravaApiError(f"Ошибка API Strava: {str(e)}")
            raise RuntimeError(f"Не удалось получить активность: {str(e)}")
  • src/server.py:306-306 (registration)
    The @mcp.tool() decorator registers the get_activity_by_id function as an MCP tool.
    @mcp.tool()  # Убираем name параметр
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 fetches activity details but lacks critical information: it doesn't specify if this is a read-only operation, what permissions are required, potential rate limits, error handling, or data freshness. The description is minimal and fails to provide adequate behavioral context for safe and effective use.

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, followed by structured 'Args' and 'Returns' sections. There's no wasted text, and the information is organized efficiently. However, the use of 'Dict' in the return section is vague and could be more precise, slightly reducing clarity.

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 tool's complexity (a read operation with one parameter) and lack of annotations and output schema, the description is incomplete. It doesn't explain the return structure beyond 'Dict' with examples, missing details like error responses, pagination, or data types. For a tool interacting with an external API like Strava, more context on authentication or limitations is needed for reliable 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 some value beyond the input schema by explaining that 'activity_id' is used to fetch activity details, but schema description coverage is 0%, meaning the schema provides no descriptions. The description compensates slightly by clarifying the parameter's role, but it doesn't detail format constraints (e.g., ID sources or validation rules). With one parameter and low schema coverage, this is a baseline adequate explanation.

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 activity details from Strava' specifies the verb (get) and resource (activity details). It distinguishes from siblings like 'analyze_activity' or 'get_activity_recommendations' by focusing on retrieval rather than analysis or recommendations. However, it doesn't explicitly contrast with siblings, keeping it at 4 instead of 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 siblings like 'analyze_activity' or 'get_activity_recommendations', nor does it specify prerequisites or contexts for usage. The only implied usage is fetching details for a specific activity ID, but this is basic and insufficient for effective 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/rbctmz/mcp-server-strava'

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