Skip to main content
Glama

analyze_activity

Extracts and analyzes Strava activity data by activity ID, returning detailed insights in a structured format for integration and usage.

Instructions

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activity_idYes

Implementation Reference

  • Main handler function for the 'analyze_activity' tool. Fetches the Strava activity data and performs analysis including pace calculation, effort assessment, and stats extraction.
    @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 }
  • Helper function to compute pace: minutes per km for Run activities, km/h for Ride activities.
    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
  • Helper function to categorize effort level based on average heart rate: Легкая (<120), Средняя (120-150), Высокая (>150).
    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 "Высокая"

Other Tools

Related 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