Skip to main content
Glama
SkyBlob12

Strava MCP Server

by SkyBlob12

Analyser l'entraînement

strava_analyze_training

Analyzes recent training load by calculating weekly volume in kilometers and time, sessions count, longest run, average pace per week, and consistency score over a configurable number of weeks.

Instructions

Analyse la charge d'entraînement récente : volume hebdomadaire (km, temps, sorties), longue sortie, allure moyenne par semaine, score de régularité.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
weeksNoNombre de semaines récentes à analyser

Implementation Reference

  • Tool 'strava_analyze_training' is registered in registerAnalysisTools() via server.registerTool at line 15. It accepts a 'weeks' parameter (default 12).
    export function registerAnalysisTools(server: McpServer): void {
      server.registerTool(
        "strava_analyze_training",
        {
          title: "Analyser l'entraînement",
          description:
            "Analyse la charge d'entraînement récente : volume hebdomadaire (km, temps, sorties), " +
            "longue sortie, allure moyenne par semaine, score de régularité.",
          inputSchema: z.object({
            weeks: z
              .number()
              .int()
              .min(1)
              .max(52)
              .default(12)
              .describe("Nombre de semaines récentes à analyser"),
          }),
        },
        async ({ weeks }) => {
          const afterEpoch = Math.floor(Date.now() / 1000) - weeks * 7 * 86400 - 86400;
          const activities = await listAllActivities(afterEpoch);
          const weeklyStats = computeWeeklyStats(activities, weeks);
          const consistency = consistencyScore(weeklyStats);
          const avgKm = averageWeeklyKm(weeklyStats);
    
          const result = {
            periode: `${weeks} dernières semaines`,
            moyenne_hebdo_km: avgKm,
            regularite_pct: consistency,
            semaines: weeklyStats,
            resume: {
              total_sorties: weeklyStats.reduce((s, w) => s + w.runs, 0),
              total_km: Math.round(weeklyStats.reduce((s, w) => s + w.totalDistanceKm, 0) * 10) / 10,
              plus_longue_sortie_km: Math.max(0, ...weeklyStats.map((w) => w.longRunKm)),
              semaine_max_km: Math.max(0, ...weeklyStats.map((w) => w.totalDistanceKm)),
            },
          };
    
          return {
            content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
          };
        }
      );
  • Handler function for strava_analyze_training. Fetches recent Strava activities via listAllActivities, computes weekly stats, consistency score, and average weekly km, then returns a JSON response with period, average weekly km, consistency percentage, weekly breakdown, and summary.
      async ({ weeks }) => {
        const afterEpoch = Math.floor(Date.now() / 1000) - weeks * 7 * 86400 - 86400;
        const activities = await listAllActivities(afterEpoch);
        const weeklyStats = computeWeeklyStats(activities, weeks);
        const consistency = consistencyScore(weeklyStats);
        const avgKm = averageWeeklyKm(weeklyStats);
    
        const result = {
          periode: `${weeks} dernières semaines`,
          moyenne_hebdo_km: avgKm,
          regularite_pct: consistency,
          semaines: weeklyStats,
          resume: {
            total_sorties: weeklyStats.reduce((s, w) => s + w.runs, 0),
            total_km: Math.round(weeklyStats.reduce((s, w) => s + w.totalDistanceKm, 0) * 10) / 10,
            plus_longue_sortie_km: Math.max(0, ...weeklyStats.map((w) => w.longRunKm)),
            semaine_max_km: Math.max(0, ...weeklyStats.map((w) => w.totalDistanceKm)),
          },
        };
    
        return {
          content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
        };
      }
    );
  • src/index.ts:14-14 (registration)
    The tool registration function is called in the main entry point src/index.ts at line 14.
    registerAuthTools(server);
  • Helper function computeWeeklyStats groups run activities by ISO week and returns weekly stats including runs, total distance km, duration, average pace, longest run, and elevation gain.
    export function computeWeeklyStats(
      activities: StravaActivity[],
      weeks = 12
    ): WeeklyStats[] {
      const runs = activities.filter((a) => a.type === "Run" && !a.trainer);
      const byWeek = new Map<string, StravaActivity[]>();
    
      for (const run of runs) {
        const ws = getWeekStart(new Date(run.start_date));
        if (!byWeek.has(ws)) byWeek.set(ws, []);
        byWeek.get(ws)!.push(run);
      }
    
      // Generate last N week starts
      const now = new Date();
      const weekStarts: string[] = [];
      for (let i = weeks - 1; i >= 0; i--) {
        const d = new Date(now);
        d.setDate(d.getDate() - i * 7);
        weekStarts.push(getWeekStart(d));
      }
    
      return weekStarts.map((ws) => {
        const weekRuns = byWeek.get(ws) ?? [];
        const totalDistanceM = weekRuns.reduce((s, r) => s + r.distance, 0);
        const totalTime = weekRuns.reduce((s, r) => s + r.moving_time, 0);
        const longRunM = Math.max(0, ...weekRuns.map((r) => r.distance));
        const avgSpeed =
          weekRuns.length > 0
            ? weekRuns.reduce((s, r) => s + r.average_speed, 0) / weekRuns.length
            : 0;
    
        return {
          weekStart: ws,
          runs: weekRuns.length,
          totalDistanceKm: metersToKm(totalDistanceM),
          totalDurationMin: Math.round(totalTime / 60),
          avgPaceMinPerKm: avgSpeed > 0 ? formatPace(avgSpeed) : "N/A",
          longRunKm: metersToKm(longRunM),
          elevationGainM: Math.round(weekRuns.reduce((s, r) => s + r.total_elevation_gain, 0)),
        };
      });
    }
  • Helper functions consistencyScore and averageWeeklyKm used by the tool handler to compute consistency percentage and average weekly km.
    export function consistencyScore(weeklyStats: WeeklyStats[]): number {
      const activeWeeks = weeklyStats.filter((w) => w.runs > 0).length;
      return Math.round((activeWeeks / weeklyStats.length) * 100);
    }
    
    export function averageWeeklyKm(weeklyStats: WeeklyStats[]): number {
      const active = weeklyStats.filter((w) => w.runs > 0);
      if (active.length === 0) return 0;
      const total = active.reduce((s, w) => s + w.totalDistanceKm, 0);
      return Math.round((total / active.length) * 10) / 10;
    }
Behavior2/5

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

No annotations provided; description does not disclose side effects, auth needs, or whether it's read-only, leaving behavioral transparency insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One concise sentence with all necessary information, no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with no output schema, the description adequately lists output metrics; missing return format is acceptable given low complexity.

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?

Schema coverage is 100% with a clear parameter description; the tool description adds no extra meaning beyond the schema, meeting baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool analyzes recent training load with specific metrics (volume, long run, average pace, regularity), distinguishing it from siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The context is implied but no explicit guidance on when to use this tool versus alternatives like strava_training_load or strava_weekly_workout.

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/SkyBlob12/McpStrava'

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