get-athlete-zones
Retrieve your configured heart rate and power zones from Strava to analyze workout intensity and track fitness progress.
Instructions
Retrieves the authenticated athlete's configured heart rate and power zones.
Output includes both a formatted summary and the raw JSON data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/getAthleteZones.ts:63-113 (handler)The 'execute' function implementation for the 'get-athlete-zones' tool. It fetches athlete zones from Strava using the provided token, formats the result, and returns it.
execute: async (_input: GetAthleteZonesInput) => { 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 athlete zones..."); const zonesData = await fetchAthleteZones(token); // Format the summary const formattedText = formatAthleteZones(zonesData); // Prepare the raw data const rawDataText = `\n\nRaw Athlete Zone Data:\n${JSON.stringify(zonesData, null, 2)}`; console.error("Successfully fetched athlete zones."); // Return both summary and raw data return { content: [ { type: "text" as const, text: formattedText }, { type: "text" as const, text: rawDataText } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); console.error(`Error fetching athlete zones: ${errorMessage}`); let userFriendlyMessage; // Check for common errors like missing scope (403 Forbidden) if (errorMessage.includes("403")) { userFriendlyMessage = "π Access denied. This tool requires 'profile:read_all' permission. Please re-authorize with the correct scope."; } else if (errorMessage.startsWith("SUBSCRIPTION_REQUIRED:")) { // In case Strava changes this later userFriendlyMessage = `π Accessing zones might require a Strava subscription. Details: ${errorMessage}`; } else { userFriendlyMessage = `An unexpected error occurred while fetching athlete zones. Details: ${errorMessage}`; } return { content: [{ type: "text" as const, text: `β ${userFriendlyMessage}` }], isError: true }; } } }; - src/tools/getAthleteZones.ts:9-11 (schema)Input schema definition for the 'get-athlete-zones' tool. It currently requires no input parameters.
const inputSchema = z.object({}); type GetAthleteZonesInput = z.infer<typeof inputSchema>; - src/server.ts:166-170 (registration)Registration of the 'get-athlete-zones' tool with the MCP server.
server.tool( getAthleteZonesTool.name, getAthleteZonesTool.description, getAthleteZonesTool.inputSchema?.shape ?? {}, getAthleteZonesTool.execute