Skip to main content
Glama
formatters.ts1.79 kB
import { StravaRoute } from './stravaClient'; /** * Converts meters to kilometers, rounding to 2 decimal places. * @param meters - Distance in meters. * @returns Distance in kilometers as a string (e.g., "10.25 km"). */ function metersToKmString(meters: number): string { if (meters === undefined || meters === null) return 'N/A'; return (meters / 1000).toFixed(2) + ' km'; } /** * Formats elevation gain in meters. * @param meters - Elevation gain in meters. * @returns Elevation gain as a string (e.g., "150 m"). */ function formatElevation(meters: number | null | undefined): string { if (meters === undefined || meters === null) return 'N/A'; return Math.round(meters) + ' m'; } /** * Formats a Strava route object into a concise summary string using metric units. * * @param route - The StravaRoute object. * @returns A formatted string summarizing the route. */ export function formatRouteSummary(route: StravaRoute): string { const distanceKm = metersToKmString(route.distance); const elevation = formatElevation(route.elevation_gain); const date = new Date(route.created_at).toLocaleDateString(); const type = route.type === 1 ? 'Ride' : route.type === 2 ? 'Run' : 'Walk'; // Assuming 3 is Walk based on typical Strava usage let summary = `📍 Route: ${route.name} (#${route.id})\n`; summary += ` - Type: ${type}, Distance: ${distanceKm}, Elevation: ${elevation}\n`; summary += ` - Created: ${date}, Segments: ${route.segments?.length ?? 'N/A'}\n`; if (route.description) { summary += ` - Description: ${route.description.substring(0, 100)}${route.description.length > 100 ? '...' : ''}\n`; } return summary; } // Add other shared formatters here as needed (e.g., formatActivity, formatSegment)

Implementation Reference

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