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;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'fetches' (implying a read operation) but doesn't cover critical aspects like authentication requirements, rate limits, error conditions (e.g., invalid ID), or response format. For a tool with no annotation coverage, this leaves significant gaps in understanding how it behaves.

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 action ('fetches detailed information') and resource ('specific segment effort'). There is no wasted verbiage, repetition, or unnecessary elaboration, 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 the lack of annotations and output schema, the description is incomplete for effective tool use. It doesn't explain what 'detailed information' includes (e.g., effort time, power data), authentication needs, or error handling. For a tool that likely returns structured data (implied by 'detailed information'), more context is needed to guide an agent in interpreting 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?

The schema description coverage is 100%, with the single parameter 'effortId' fully documented in the schema as 'The unique identifier of the segment effort to fetch.' The description adds no additional semantic context beyond implying the ID is used to fetch details. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't detract either.

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 verb 'fetches' and the resource 'detailed information about a specific segment effort using its ID', making the purpose unambiguous. It distinguishes from siblings like 'get-segment' (which fetches segment metadata) and 'list-segment-efforts' (which lists multiple efforts) by specifying retrieval of a single effort by ID. However, it doesn't explicitly mention 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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a valid effort ID from another operation), contrast with 'list-segment-efforts' for multiple efforts, or specify use cases like analyzing performance on a segment. Without such context, an agent might struggle to select this tool appropriately.

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/LimeON-source/Strava-MCP'

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