Skip to main content
Glama
rbctmz

mcp-server-strava

analyze_activity

Analyzes Strava activity data to extract performance metrics and insights. Provide an activity ID to receive detailed analysis results.

Instructions

Анализ активности из Strava

Args:
    activity_id: ID активности (строка или число)
Returns:
    dict: Результаты анализа активности

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activity_idYes

Implementation Reference

  • Main MCP tool handler: analyzes Strava activity by ID, computes pace and effort using helpers, returns structured dict with stats and analysis.
    @mcp.tool()
    def analyze_activity(activity_id: Union[str, int]) -> dict:
        """Анализ активности из Strava
    
        Args:
            activity_id: ID активности (строка или число)
        Returns:
            dict: Результаты анализа активности
        """
        activity_id = str(activity_id)
    
        try:
            activity = get_activity(activity_id)
            
            # Calculate pace and zones
            pace = _calculate_pace(activity)
            effort = _calculate_effort(activity)
            
            return {
                "type": activity.get("type"),
                "distance": activity.get("distance"),
                "moving_time": activity.get("moving_time"),
                "average_heartrate": activity.get("average_heartrate"),
                "analysis": {
                    "pace": pace,
                    "effort": effort,
                    "stats": {
                        "elapsed_time": activity.get("elapsed_time"),
                        "elevation_gain": activity.get("total_elevation_gain"),
                        "calories": activity.get("calories"),
                    }
                },
            }
        except Exception as e:
            logger.error(f"Ошибка анализа активности {activity_id}: {e}")
            return {
                "error": f"Не удалось проанализировать активность: {str(e)}",
                "activity_id": activity_id
            }
  • Calculates activity pace: minutes per km for running, km/h for cycling.
    def _calculate_pace(activity: dict) -> float:
        """Расчет темпа активности"""
        try:
            if activity.get("type") == "Run":
                # Для бега: мин/км
                return (activity.get("moving_time", 0) / 60) / (activity.get("distance", 0) / 1000)
            elif activity.get("type") == "Ride":
                # Для велосипеда: км/ч
                return (activity.get("distance", 0) / 1000) / (activity.get("moving_time", 0) / 3600)
            return 0
        except (TypeError, ZeroDivisionError):
            return 0
  • Estimates training effort level ('Легкая', 'Средняя', 'Высокая') based on average heart rate zones.
    def _calculate_effort(activity: dict) -> str:
        """Оценка нагрузки"""
        if "average_heartrate" not in activity:
            return "Неизвестно"
    
        hr = activity["average_heartrate"]
        if hr < 120:
            return "Легкая"
        if hr < 150:
            return "Средняя"
        return "Высокая"
  • src/server.py:336-336 (registration)
    MCP tool decorator that registers the analyze_activity function as a tool.
    @mcp.tool()
  • Docstring providing tool description, input parameter (activity_id: str|int), and output (dict with analysis). Serves as schema for MCP.
    """Анализ активности из Strava
    
    Args:
        activity_id: ID активности (строка или число)
    Returns:
        dict: Результаты анализа активности
    """
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 returns 'Результаты анализа активности' (results of activity analysis), which implies read-only behavior but lacks details on what the analysis entails, potential side effects, or performance considerations. This is insufficient 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 concise and well-structured: it starts with the purpose, lists arguments and returns in a clear format. However, the inclusion of 'Args:' and 'Returns:' sections adds some redundancy, as this information could be inferred from the schema, slightly reducing efficiency.

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 lack of annotations, no output schema, and low schema description coverage (0%), the description is incomplete. It doesn't detail what 'analysis' involves, the return structure, or error handling, making it inadequate for an analysis tool with one parameter and sibling alternatives.

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 specifies that 'activity_id' is 'ID активности (строка или число)' (activity ID, string or number), which matches the schema's 'anyOf' type. With schema description coverage at 0%, this provides basic clarification, but it doesn't explain format, sourcing, or constraints, so it only meets the baseline.

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 states the tool's purpose clearly: 'Анализ активности из Strava' (Analysis of activity from Strava). This specifies the verb ('analyze') and resource ('activity from Strava'), making it understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_activity_by_id' or 'analyze_training_load', which prevents a perfect score.

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 mentions 'activity_id' as an argument but doesn't explain scenarios where analysis is preferred over retrieval (e.g., 'get_activity_by_id') or other analysis tools (e.g., 'analyze_training_load'), leaving usage ambiguous.

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