calculate_pace
Calculate running pace, finish time, or distance by providing any two of these three variables for training and race planning.
Instructions
Calculate running pace, finish time, or distance. Provide any two of: distance, time, pace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| distance | No | Distance: "5k", "10k", "half", "marathon", or km value like "15" | |
| time | No | Finish time in H:MM:SS or MM:SS format, e.g. "3:30:00" or "25:00" | |
| pace | No | Pace per km in M:SS format, e.g. "5:00" |
Implementation Reference
- index.js:210-254 (handler)Handler function for the `calculate_pace` tool, performing the math calculations based on provided inputs.
async ({ distance, time, pace }) => { const given = [distance, time, pace].filter(Boolean).length; if (given < 2) throw new Error('Provide at least 2 of: distance, time, pace'); let result = {}; if (distance && time) { const distKm = resolveDistance(distance); const timeSecs = timeToSeconds(time); const paceSecs = timeSecs / distKm; result = { distance: `${distKm} km`, time: secondsToTime(timeSecs), pace: `${secondsToPace(paceSecs)}/km`, speed: `${(distKm / (timeSecs / 3600)).toFixed(2)} km/h`, }; } else if (distance && pace) { const distKm = resolveDistance(distance); const paceSecs = paceToSeconds(pace); const timeSecs = distKm * paceSecs; result = { distance: `${distKm} km`, time: secondsToTime(timeSecs), pace: `${secondsToPace(paceSecs)}/km`, speed: `${(distKm / (timeSecs / 3600)).toFixed(2)} km/h`, }; } else if (time && pace) { const timeSecs = timeToSeconds(time); const paceSecs = paceToSeconds(pace); const distKm = timeSecs / paceSecs; result = { distance: `${distKm.toFixed(2)} km`, time: secondsToTime(timeSecs), pace: `${secondsToPace(paceSecs)}/km`, speed: `${(distKm / (timeSecs / 3600)).toFixed(2)} km/h`, }; } return { content: [{ type: 'text', text: Object.entries(result).map(([k, v]) => `${k}: ${v}`).join('\n'), }], }; } - index.js:202-209 (registration)Registration and schema definition for the `calculate_pace` tool.
server.tool( 'calculate_pace', 'Calculate running pace, finish time, or distance. Provide any two of: distance, time, pace.', { distance: z.string().optional().describe('Distance: "5k", "10k", "half", "marathon", or km value like "15"'), time: z.string().optional().describe('Finish time in H:MM:SS or MM:SS format, e.g. "3:30:00" or "25:00"'), pace: z.string().optional().describe('Pace per km in M:SS format, e.g. "5:00"'), },