heart_rate_zones
Calculate heart rate training zones using the Karvonen method. Input age, resting heart rate, and optionally max heart rate to get personalized zones for guided workouts.
Instructions
Calculate heart rate training zones using the Karvonen method
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| age | Yes | Your age in years | |
| resting_hr | No | Resting heart rate in bpm (default: 60) | |
| max_hr | No | Known max heart rate in bpm (auto-calculated if omitted) |
Implementation Reference
- index.js:89-108 (handler)Core handler function `heartRateZones` that calculates heart rate training zones using the Karvonen method. Computes max heart rate (207 - 0.7*age if not provided), heart rate reserve (HRR), and five zones (Recovery, Aerobic, Tempo, Threshold, VO2max) with BPM ranges.
function heartRateZones(age, restingHR, maxHR) { const mhr = maxHR || Math.round(207 - 0.7 * age); const hrr = mhr - restingHR; const zones = [ { zone: 1, name: 'Recovery', low: 0.50, high: 0.60 }, { zone: 2, name: 'Aerobic', low: 0.60, high: 0.70 }, { zone: 3, name: 'Tempo', low: 0.70, high: 0.80 }, { zone: 4, name: 'Threshold', low: 0.80, high: 0.90 }, { zone: 5, name: 'VO2max', low: 0.90, high: 1.00 }, ]; return { maxHR: mhr, restingHR, zones: zones.map(z => ({ ...z, bpmLow: Math.round(restingHR + hrr * z.low), bpmHigh: Math.round(restingHR + hrr * z.high), })), }; } - index.js:303-321 (registration)Tool registration of 'heart_rate_zones' using server.tool(). Defines schema (age required, resting_hr and max_hr optional) and async handler that calls heartRateZones() and formats output text.
// Tool: heart_rate_zones server.tool( 'heart_rate_zones', 'Calculate heart rate training zones using the Karvonen method', { age: z.number().min(10).max(99).describe('Your age in years'), resting_hr: z.number().min(30).max(120).optional().describe('Resting heart rate in bpm (default: 60)'), max_hr: z.number().min(100).max(220).optional().describe('Known max heart rate in bpm (auto-calculated if omitted)'), }, async ({ age, resting_hr, max_hr }) => { const result = heartRateZones(age, resting_hr || 60, max_hr); let text = `Heart Rate Training Zones (Karvonen Method)\n\nAge: ${age} | Resting HR: ${result.restingHR} bpm | Max HR: ${result.maxHR} bpm\n\n`; result.zones.forEach(z => { text += `Zone ${z.zone} (${z.name}): ${z.bpmLow}-${z.bpmHigh} bpm\n`; }); text += `\nFor more options: ${BASE_URL}/tools/heart-rate-zones/`; return { content: [{ type: 'text', text }] }; } ); - index.js:307-311 (schema)Input schema for the heart_rate_zones tool: age (z.number, 10-99, required), resting_hr (z.number, 30-120, optional, default 60), max_hr (z.number, 100-220, optional, auto-calculated).
{ age: z.number().min(10).max(99).describe('Your age in years'), resting_hr: z.number().min(30).max(120).optional().describe('Resting heart rate in bpm (default: 60)'), max_hr: z.number().min(100).max(220).optional().describe('Known max heart rate in bpm (auto-calculated if omitted)'), },