Skip to main content
Glama

list-starred-segments

Retrieve your starred Strava segments to access favorite cycling and running routes for planning activities or analyzing performance.

Instructions

Lists the segments starred by the authenticated athlete.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Execute function that implements the core logic of the 'list-starred-segments' tool: authenticates with Strava, fetches starred segments, formats them based on athlete preferences, and returns a formatted text response.
    execute: async () => { 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 { console.error("Fetching starred segments..."); // Need athlete measurement preference for formatting distance const athlete = await getAuthenticatedAthlete(token); // Use renamed import const segments = await fetchSegments(token); console.error(`Successfully fetched ${segments?.length ?? 0} starred segments.`); if (!segments || segments.length === 0) { return { content: [{ type: "text" as const, text: " MNo starred segments found." }] }; } const distanceFactor = athlete.measurement_preference === 'feet' ? 0.000621371 : 0.001; const distanceUnit = athlete.measurement_preference === 'feet' ? 'mi' : 'km'; // Format the segments into a text response const segmentText = segments.map(segment => { const location = [segment.city, segment.state, segment.country].filter(Boolean).join(", ") || 'N/A'; const distance = (segment.distance * distanceFactor).toFixed(2); return ` ⭐ **${segment.name}** (ID: ${segment.id}) - Activity Type: ${segment.activity_type} - Distance: ${distance} ${distanceUnit} - Avg Grade: ${segment.average_grade}% - Location: ${location} - Private: ${segment.private ? 'Yes' : 'No'} `.trim(); }).join("\n---\n"); const responseText = `**Your Starred Segments:**\n\n${segmentText}`; return { content: [{ type: "text" as const, text: responseText }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : "An unknown error occurred"; console.error("Error in list-starred-segments tool:", errorMessage); return { content: [{ type: "text" as const, text: `❌ API Error: ${errorMessage}` }], isError: true, }; } }
  • src/server.ts:81-86 (registration)
    Registers the 'list-starred-segments' tool on the MCP server using the imported tool definition.
    server.tool( listStarredSegments.name, listStarredSegments.description, {}, listStarredSegments.execute );
  • Defines the input schema for the tool as undefined (no input parameters required).
    inputSchema: undefined,

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/r-huijts/strava-mcp'

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