Skip to main content
Glama
SkyBlob12

Strava MCP Server

by SkyBlob12

Récupérer les activités Strava

strava_get_activities

Get a list of recent Strava activities including distance, time, pace, and heart rate. Filter by activity type or date range to control how many activities to fetch.

Instructions

Récupère la liste des activités récentes de l'athlète avec distance, temps, allure et fréquence cardiaque.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoNombre de jours passés à récupérer (défaut : 90)
activity_typeNoFiltrer par type d'activitéAll
max_resultsNoNombre maximum d'activités à retourner

Implementation Reference

  • The handler function for strava_get_activities. It takes input params (days, activity_type, max_results), calls listActivities, filters by type, formats results with distance/duration/pace/HR, and returns text content.
    async ({ days, activity_type, max_results }) => {
      const afterEpoch = Math.floor(Date.now() / 1000) - days * 86400;
      const activities = await listActivities({ after: afterEpoch, per_page: max_results });
      const filtered =
        activity_type === "All" ? activities : activities.filter((a) => a.type === activity_type);
    
      const summary = filtered.map((a) => ({
        id: a.id,
        name: a.name,
        date: a.start_date.slice(0, 10),
        type: a.type,
        distance_km: metersToKm(a.distance),
        duration: formatDuration(a.moving_time),
        pace: a.distance > 0 ? formatPace(a.average_speed) : "N/A",
        elevation_m: Math.round(a.total_elevation_gain),
        avg_hr: a.average_heartrate ?? null,
        trainer: a.trainer,
      }));
    
      return {
        content: [
          {
            type: "text",
            text: `${filtered.length} activité(s) trouvée(s) sur les ${days} derniers jours :\n\n${JSON.stringify(summary, null, 2)}`,
          },
        ],
      };
    }
  • Input schema for strava_get_activities. Defines three optional fields: days (1-365, default 90), activity_type (Run|Ride|Swim|Walk|All, default All), and max_results (1-200, default 30).
    {
      title: "Récupérer les activités Strava",
      description:
        "Récupère la liste des activités récentes de l'athlète avec distance, temps, allure et fréquence cardiaque.",
      inputSchema: z.object({
        days: z
          .number()
          .int()
          .min(1)
          .max(365)
          .default(90)
          .describe("Nombre de jours passés à récupérer (défaut : 90)"),
        activity_type: z
          .enum(["Run", "Ride", "Swim", "Walk", "All"])
          .default("All")
          .describe("Filtrer par type d'activité"),
        max_results: z
          .number()
          .int()
          .min(1)
          .max(200)
          .default(30)
          .describe("Nombre maximum d'activités à retourner"),
      }),
  • Registration of the strava_get_activities tool via server.registerTool(), within the registerActivityTools function.
    server.registerTool(
      "strava_get_activities",
      {
        title: "Récupérer les activités Strava",
        description:
          "Récupère la liste des activités récentes de l'athlète avec distance, temps, allure et fréquence cardiaque.",
        inputSchema: z.object({
          days: z
            .number()
            .int()
            .min(1)
            .max(365)
            .default(90)
            .describe("Nombre de jours passés à récupérer (défaut : 90)"),
          activity_type: z
            .enum(["Run", "Ride", "Swim", "Walk", "All"])
            .default("All")
            .describe("Filtrer par type d'activité"),
          max_results: z
            .number()
            .int()
            .min(1)
            .max(200)
            .default(30)
            .describe("Nombre maximum d'activités à retourner"),
        }),
      },
      async ({ days, activity_type, max_results }) => {
        const afterEpoch = Math.floor(Date.now() / 1000) - days * 86400;
        const activities = await listActivities({ after: afterEpoch, per_page: max_results });
        const filtered =
          activity_type === "All" ? activities : activities.filter((a) => a.type === activity_type);
    
        const summary = filtered.map((a) => ({
          id: a.id,
          name: a.name,
          date: a.start_date.slice(0, 10),
          type: a.type,
          distance_km: metersToKm(a.distance),
          duration: formatDuration(a.moving_time),
          pace: a.distance > 0 ? formatPace(a.average_speed) : "N/A",
          elevation_m: Math.round(a.total_elevation_gain),
          avg_hr: a.average_heartrate ?? null,
          trainer: a.trainer,
        }));
    
        return {
          content: [
            {
              type: "text",
              text: `${filtered.length} activité(s) trouvée(s) sur les ${days} derniers jours :\n\n${JSON.stringify(summary, null, 2)}`,
            },
          ],
        };
      }
    );
  • The listActivities function called by the handler. Makes an HTTP GET to /athlete/activities via the Strava client with pagination and date filtering.
    export async function listActivities(params: {
      before?: number;
      after?: number;
      page?: number;
      per_page?: number;
    }): Promise<StravaActivity[]> {
      const { data } = await stravaClient.get<StravaActivity[]>("/athlete/activities", { params });
      return data;
    }
  • src/index.ts:15-18 (registration)
    Where registerActivityTools is called from the main entry point, connecting the tool to the MCP server.
    registerActivityTools(server);
    registerAnalysisTools(server);
    registerPredictionTools(server);
    registerPlanTools(server);
Behavior3/5

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

No annotations are provided, so the description must convey behavioral traits. It indicates a read operation (listing recent activities) with specific output fields, but does not mention authentication requirements, rate limits, or whether the data is user-specific. This is adequate but misses opportunities for richer disclosure.

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?

A single, well-structured sentence that front-loads the core purpose and expected output. No unnecessary words or repetition. Every element serves to inform the agent.

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?

Given the tool's low complexity (3 parameters, no output schema, no nested objects), the description provides a reasonable idea of what is returned (list of recent activities with key metrics). It could briefly mention pagination or limits, but it is mostly complete for its purpose.

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 description coverage is 100% with clear parameter descriptions for days, activity_type, and max_results. The description adds that the output includes distance, time, pace, and heart rate, but this does not enhance parameter semantics beyond what the schema already provides.

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 verb 'Récupère' (retrieve), the resource 'liste des activités récentes de l'athlète', and includes specific metrics (distance, temps, allure, fréquence cardiaque). It distinguishes from siblings like strava_get_activity_detail (single activity) and strava_athlete_stats (stats).

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?

No guidance on when to use this tool versus alternatives such as strava_analyze_training or strava_weekly_workout. The description does not mention when not to use or suggest any prerequisites.

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