Skip to main content
Glama
SkyBlob12

Strava MCP Server

by SkyBlob12

Vérifier le statut d'authentification

strava_auth_status

Check if valid Strava tokens exist and when they expire to confirm authentication status before accessing Strava data.

Instructions

Vérifie si des tokens Strava valides existent et quand ils expirent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'strava_auth_status' tool handler: registers the tool with the MCP server. Loads tokens from disk, checks if expired, and returns a status string indicating auth state (not authenticated, token expired, or token valid with expiry time). Input: empty object. Output: text content with authentication status.
    server.registerTool(
      "strava_auth_status",
      {
        title: "Vérifier le statut d'authentification",
        description: "Vérifie si des tokens Strava valides existent et quand ils expirent.",
        inputSchema: z.object({}),
      },
      async () => {
        const tokens = loadTokens(config.tokensFilePath);
        if (!tokens) {
          return {
            content: [
              {
                type: "text",
                text: "Non authentifié. Lance strava_get_auth_url pour démarrer l'authentification.",
              },
            ],
          };
        }
        const expired = isTokenExpired(tokens);
        const expiresIn = Math.round(tokens.expires_at - Date.now() / 1000);
        const status = expired
          ? "Token expiré (sera renouvelé automatiquement à la prochaine requête)"
          : `Token valide (expire dans ${expiresIn}s)`;
        return {
          content: [
            {
              type: "text",
              text: `Authentifié. Athlete ID : ${tokens.athlete_id}.\n${status}`,
            },
          ],
        };
      }
  • Input schema for strava_auth_status: defines the tool title ('Vérifier le statut d'authentification'), description, and an empty inputSchema (z.object({})) meaning no parameters required.
    {
      title: "Vérifier le statut d'authentification",
      description: "Vérifie si des tokens Strava valides existent et quand ils expirent.",
      inputSchema: z.object({}),
    },
  • The registerAuthTools function registers strava_auth_status (and two other tools) on the MCP server. Called from src/index.ts line 14.
    export function registerAuthTools(server: McpServer): void {
      server.registerTool(
        "strava_get_auth_url",
        {
          title: "Obtenir l'URL d'autorisation Strava",
          description:
            "Génère l'URL OAuth2 Strava. Ouvrir cette URL dans un navigateur, " +
            "autoriser l'application, puis copier le paramètre 'code' depuis " +
            "l'URL de redirection et le passer à strava_exchange_token.",
          inputSchema: z.object({}),
        },
        async () => {
          if (!config.clientId) {
            return {
              content: [
                {
                  type: "text",
                  text: "Erreur : STRAVA_CLIENT_ID non configuré. Copie .env.example en .env et renseigne tes credentials.",
                },
              ],
            };
          }
          const redirectUri = config.redirectUri;
          const portMatch = redirectUri.match(/:(\d+)\//);
          const port = portMatch ? parseInt(portMatch[1], 10) : 8080;
          startOAuthCallbackServer(port);
          const url = buildAuthorizationUrl();
          return {
            content: [
              {
                type: "text",
                text: `Ouvre cette URL dans ton navigateur :\n\n${url}\n\nUne fois que tu as autorisé l'application sur Strava, la page affichera "✓ Authentification réussie !" et les tokens seront sauvegardés automatiquement. Tu n'as rien d'autre à faire.`,
              },
            ],
          };
        }
      );
    
      server.registerTool(
        "strava_exchange_token",
        {
          title: "Échanger le code d'autorisation contre des tokens",
          description:
            "Échange le code OAuth2 (depuis l'URL de redirection après autorisation dans le navigateur) " +
            "contre des tokens d'accès et de rafraîchissement. Les tokens sont sauvegardés localement.",
          inputSchema: z.object({
            code: z.string().describe("Le code d'autorisation depuis l'URL de redirection Strava"),
          }),
        },
        async ({ code }) => {
          try {
            const tokens = await exchangeCodeForTokens(code);
            return {
              content: [
                {
                  type: "text",
                  text: `✓ Authentifié avec succès ! Athlete ID : ${tokens.athlete_id}.\nTokens sauvegardés dans ${config.tokensFilePath}.`,
                },
              ],
            };
          } catch (err: unknown) {
            const msg = err instanceof Error ? err.message : String(err);
            return {
              content: [{ type: "text", text: `Erreur lors de l'échange du token : ${msg}` }],
            };
          }
        }
      );
    
      server.registerTool(
        "strava_auth_status",
        {
          title: "Vérifier le statut d'authentification",
          description: "Vérifie si des tokens Strava valides existent et quand ils expirent.",
          inputSchema: z.object({}),
        },
        async () => {
          const tokens = loadTokens(config.tokensFilePath);
          if (!tokens) {
            return {
              content: [
                {
                  type: "text",
                  text: "Non authentifié. Lance strava_get_auth_url pour démarrer l'authentification.",
                },
              ],
            };
          }
          const expired = isTokenExpired(tokens);
          const expiresIn = Math.round(tokens.expires_at - Date.now() / 1000);
          const status = expired
            ? "Token expiré (sera renouvelé automatiquement à la prochaine requête)"
            : `Token valide (expire dans ${expiresIn}s)`;
          return {
            content: [
              {
                type: "text",
                text: `Authentifié. Athlete ID : ${tokens.athlete_id}.\n${status}`,
              },
            ],
          };
        }
      );
    }
  • loadTokens helper: reads tokens from a JSON file path, returns null if file doesn't exist or can't be parsed. Used by the strava_auth_status handler to load stored tokens.
    export function loadTokens(filePath: string): StravaTokens | null {
      if (!existsSync(filePath)) return null;
      try {
        return JSON.parse(readFileSync(filePath, "utf-8")) as StravaTokens;
      } catch {
        return null;
      }
    }
  • isTokenExpired helper: checks if tokens.expires_at (minus 300s buffer) is before the current time. Used by the strava_auth_status handler to determine if the token is expired.
    export function isTokenExpired(tokens: StravaTokens): boolean {
      return Date.now() / 1000 >= tokens.expires_at - 300;
    }
Behavior2/5

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

No annotations exist, so the description bears full responsibility. It only mentions the check for token validity and expiry, lacking details on side effects, permissions, rate limits, or whether it is read-only.

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, clear sentence that efficiently conveys the purpose without wasted words.

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

Completeness3/5

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

The description covers the core function but omits details about the output format (e.g., boolean or expiry timestamp). For a tool with no parameters, it is adequate but not fully explicit.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With zero parameters and full schema coverage, the description adds value by explaining what the tool checks. The baseline for 0 params is 4, and the description meets it.

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 ('Vérifie') and the resource (validité et expiration des tokens), distinguishing this utility tool from siblings that focus on activities, stats, or training plans.

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?

No explicit when-to-use or when-not-to-use guidance is provided. The description implies usage for checking authentication status, but does not compare to alternative tools or state 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