Skip to main content
Glama

star-segment

Mark or unmark a Strava segment as a favorite to track it for future activities and personal goals.

Instructions

Stars or unstars a specific segment for the authenticated athlete.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
segmentIdYesThe unique identifier of the segment to star or unstar.
starredYesSet to true to star the segment, false to unstar it.

Implementation Reference

  • The tool definition and execution logic for 'star-segment'.
    export const starSegment = {
        name: "star-segment",
        description: "Stars or unstars a specific segment for the authenticated athlete.",
        inputSchema: StarSegmentInputSchema,
        execute: async ({ segmentId, starred }: StarSegmentInput) => {
            const token = process.env.STRAVA_ACCESS_TOKEN;
    
            if (!token || token === 'YOUR_STRAVA_ACCESS_TOKEN_HERE') {
                console.error("Missing or placeholder STRAVA_ACCESS_TOKEN in .env");
                return {
                    content: [{ type: "text" as const, text: "❌ Configuration Error: STRAVA_ACCESS_TOKEN is missing or not set in the .env file." }],
                    isError: true,
                };
            }
    
            try {
                const action = starred ? 'starring' : 'unstarring';
                console.error(`Attempting to ${action} segment ID: ${segmentId}...`);
    
                const updatedSegment = await updateStarStatus(token, segmentId, starred);
    
                const successMessage = `Successfully ${action} segment: "${updatedSegment.name}" (ID: ${updatedSegment.id}). Its starred status is now: ${updatedSegment.starred}.`;
                console.error(successMessage);
    
                return { content: [{ type: "text" as const, text: successMessage }] };
    
            } catch (error) {
                const errorMessage = error instanceof Error ? error.message : "An unknown error occurred";
                const action = starred ? 'star' : 'unstar';
                console.error(`Error attempting to ${action} segment ID ${segmentId}:`, errorMessage);
                return {
                    content: [{ type: "text" as const, text: `❌ API Error: Failed to ${action} segment ${segmentId}. ${errorMessage}` }],
                    isError: true,
                };
            }
        }
    };
  • Input validation schema for 'star-segment'.
    const StarSegmentInputSchema = z.object({
        segmentId: z.number().int().positive().describe("The unique identifier of the segment to star or unstar."),
        starred: z.boolean().describe("Set to true to star the segment, false to unstar it."),
    });

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