Skip to main content
Glama

get-segment-effort

Retrieve detailed performance data for a specific Strava segment effort using its unique identifier to analyze workout metrics and track fitness progress.

Instructions

Fetches detailed information about a specific segment effort using its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
effortIdYesThe unique identifier of the segment effort to fetch.

Implementation Reference

  • The handler logic for the 'get-segment-effort' tool, which fetches segment effort details from the Strava API and formats them for display.
    export const getSegmentEffortTool = {
        name: "get-segment-effort",
        description: "Fetches detailed information about a specific segment effort using its ID.",
        inputSchema: GetSegmentEffortInputSchema,
        execute: async ({ effortId }: GetSegmentEffortInput) => {
            const token = process.env.STRAVA_ACCESS_TOKEN;
    
            if (!token) {
                console.error("Missing STRAVA_ACCESS_TOKEN environment variable.");
                return {
                    content: [{ type: "text" as const, text: "Configuration error: Missing Strava access token." }],
                    isError: true
                };
            }
    
            try {
                console.error(`Fetching details for segment effort ID: ${effortId}...`);
                // Removed getAuthenticatedAthlete call
                const effort = await fetchSegmentEffort(token, effortId);
                const effortDetailsText = formatSegmentEffort(effort); // Use metric formatter
    
                console.error(`Successfully fetched details for effort: ${effort.name}`);
                return { content: [{ type: "text" as const, text: effortDetailsText }] };
            } catch (error) {
                const errorMessage = error instanceof Error ? error.message : String(error);
                console.error(`Error fetching segment effort ${effortId}: ${errorMessage}`);
    
                let userFriendlyMessage;
                if (errorMessage.startsWith("SUBSCRIPTION_REQUIRED:")) {
                    userFriendlyMessage = `🔒 Accessing this segment effort (ID: ${effortId}) requires a Strava subscription. Please check your subscription status.`;
                } else if (errorMessage.includes("Record Not Found") || errorMessage.includes("404")) {
                    userFriendlyMessage = `Segment effort with ID ${effortId} not found.`;
                } else {
                    userFriendlyMessage = `An unexpected error occurred while fetching segment effort ${effortId}. Details: ${errorMessage}`;
                }
    
                return {
                    content: [{ type: "text" as const, text: `❌ ${userFriendlyMessage}` }],
                    isError: true
                };
            }
        }
    };
  • Input schema validation for 'get-segment-effort' tool using Zod.
    const GetSegmentEffortInputSchema = z.object({
        effortId: z.number().int().positive().describe("The unique identifier of the segment effort to fetch.")
    });
  • Helper function to format the segment effort data into a readable string.
    function formatSegmentEffort(effort: StravaDetailedSegmentEffort): string {
        const movingTime = formatDuration(effort.moving_time);
        const elapsedTime = formatDuration(effort.elapsed_time);
        const distance = formatDistance(effort.distance);
        // Remove speed/pace calculations as fields are not available on effort object
        // const avgSpeed = formatSpeed(effort.average_speed);
        // const maxSpeed = formatSpeed(effort.max_speed);
        // const avgPace = formatPace(effort.average_speed);
    
        let details = `⏱️ **Segment Effort: ${effort.name}** (ID: ${effort.id})\n`;
        details += `   - Activity ID: ${effort.activity.id}, Athlete ID: ${effort.athlete.id}\n`;
        details += `   - Segment ID: ${effort.segment.id}\n`;
        details += `   - Date: ${new Date(effort.start_date_local).toLocaleString()}\n`;
        details += `   - Moving Time: ${movingTime}, Elapsed Time: ${elapsedTime}\n`;
        if (effort.distance !== undefined) details += `   - Distance: ${distance}\n`;
        // Remove speed/pace display lines
        // if (effort.average_speed !== undefined) { ... }
        // if (effort.max_speed !== undefined) { ... }
        if (effort.average_cadence !== undefined && effort.average_cadence !== null) details += `   - Avg Cadence: ${effort.average_cadence.toFixed(1)}\n`;
        if (effort.average_watts !== undefined && effort.average_watts !== null) details += `   - Avg Watts: ${effort.average_watts.toFixed(1)}\n`;
        if (effort.average_heartrate !== undefined && effort.average_heartrate !== null) details += `   - Avg Heart Rate: ${effort.average_heartrate.toFixed(1)} bpm\n`;
        if (effort.max_heartrate !== undefined && effort.max_heartrate !== null) details += `   - Max Heart Rate: ${effort.max_heartrate.toFixed(0)} bpm\n`;
        if (effort.kom_rank !== null) details += `   - KOM Rank: ${effort.kom_rank}\n`;
        if (effort.pr_rank !== null) details += `   - PR Rank: ${effort.pr_rank}\n`;
        details += `   - Hidden: ${effort.hidden ? 'Yes' : 'No'}\n`;
    
        return details;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.1

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states it 'fetches' information, implying a read-only operation, but doesn't disclose behavioral traits such as authentication requirements, rate limits, error handling, or what 'detailed information' entails (e.g., fields returned, format). This leaves gaps for safe and effective use.

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?

The description is a single, efficient sentence that front-loads the core purpose ('fetches detailed information') without unnecessary words. Every part earns its place, making it easy to parse quickly.

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 no annotations and no output schema, the description is incomplete. It doesn't explain what 'detailed information' includes (e.g., fields like time, distance, athlete details), which is critical for a tool with one parameter and no structured output documentation. This leaves significant gaps for an agent to understand the tool's behavior and results.

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 the parameter 'effortId' well-documented in the schema. The description adds minimal value beyond the schema by mentioning 'using its ID', which aligns with but doesn't expand on the schema's description. Baseline 3 is appropriate as the schema does the heavy lifting.

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 clearly states the action ('fetches detailed information') and resource ('about a specific segment effort using its ID'), which distinguishes it from siblings like 'list-segment-efforts' (plural listing) and 'get-segment' (segment vs. segment effort). However, it doesn't specify what 'detailed information' includes, leaving some ambiguity.

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 explicit guidance on when to use this tool versus alternatives is provided. It doesn't mention prerequisites (e.g., needing an effort ID from 'list-segment-efforts'), contrast with 'get-segment' (which fetches segment metadata), or specify use cases like retrieving performance data for analysis.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.