Skip to main content
Glama

get-segment

Retrieve detailed information about a Strava segment using its unique ID to analyze route data, elevation profiles, and performance metrics.

Instructions

Fetches detailed information about a specific segment using its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
segmentIdYesThe unique identifier of the segment to fetch.

Implementation Reference

  • The execute function for the 'get-segment' tool, which fetches segment details using a Strava access token and formats them.
    execute: async ({ segmentId }: GetSegmentInput) => {
        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 ID: ${segmentId}...`);
            // Removed getAuthenticatedAthlete call
            const segment = await fetchSegmentById(token, segmentId);
            const segmentDetailsText = formatSegmentDetails(segment); // Use metric formatter
    
            console.error(`Successfully fetched details for segment: ${segment.name}`);
            return { content: [{ type: "text" as const, text: segmentDetailsText }] };
        } catch (error) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            console.error(`Error fetching segment ${segmentId}: ${errorMessage}`);
            // Removed call to handleApiError
            const userFriendlyMessage = errorMessage.includes("Record Not Found") || errorMessage.includes("404")
                ? `Segment with ID ${segmentId} not found.`
                : `An unexpected error occurred while fetching segment details for ID ${segmentId}. Details: ${errorMessage}`;
            return {
                content: [{ type: "text" as const, text: `❌ ${userFriendlyMessage}` }],
                isError: true
            };
        }
    }
  • Zod schema defining the input requirements for the 'get-segment' tool.
    const GetSegmentInputSchema = z.object({
        segmentId: z.number().int().positive().describe("The unique identifier of the segment to fetch.")
    });
  • The export object defining the 'get-segment' tool, including its name, description, schema, and execute handler.
    export const getSegmentTool = {
        name: "get-segment",
        description: "Fetches detailed information about a specific segment using its ID.",
        inputSchema: GetSegmentInputSchema,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a fetch operation, implying it's likely read-only, but doesn't confirm safety aspects like whether it requires authentication, has rate limits, or what happens if the ID is invalid. This leaves significant gaps for a tool that interacts with external data.

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 directly states the tool's function without any fluff. It's front-loaded with the core action and resource, 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. It doesn't explain what 'detailed information' includes (e.g., fields returned), error conditions, or authentication needs. For a tool fetching data from an external service like Strava, this leaves the agent under-informed about behavioral expectations.

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 input schema has 100% description coverage, with the 'segmentId' parameter well-documented in the schema itself. The description adds no additional meaning beyond implying the ID is used to fetch details, which is already clear from the schema. This meets the baseline for high schema coverage.

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 resource ('detailed information about a specific segment'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'get-segment-leaderboard' or 'get-segment-effort', which also fetch segment-related data, so it doesn't reach the highest score.

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 like 'explore-segments' or 'list-starred-segments'. It mentions using a segment ID but doesn't specify prerequisites (e.g., needing an ID from another operation) or exclusions, leaving the agent with minimal context for selection.

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