get_race_predictions
Predict race times for 5K, 10K, half marathon, and marathon distances using current fitness data from Garmin health metrics.
Instructions
Get predicted race times for 5K, 10K, half marathon, and marathon based on current fitness
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:208-232 (handler)The handler function for get_race_predictions tool. Fetches the latest 5 race predictions from Supabase 'race_predictions' table, formats times with formatTime helper, returns latest predictions for common distances and a brief history.async function getRacePredictions() { const { data, error } = await supabase .from("race_predictions") .select("*") .order("calendar_date", { ascending: false }) .limit(5); if (error) throw error; const latest = data?.[0]; return { latest_date: latest?.calendar_date || null, predictions: { "5k": formatTime(latest?.race_time_5k), "10k": formatTime(latest?.race_time_10k), half_marathon: formatTime(latest?.race_time_half), marathon: formatTime(latest?.race_time_marathon), }, history: data?.map((r) => ({ date: r.calendar_date, "5k": formatTime(r.race_time_5k), "10k": formatTime(r.race_time_10k), })), }; }
- src/index.ts:368-373 (schema)Schema definition for the get_race_predictions tool in the listTools response, including name, description, and empty input schema (no parameters required).{ name: "get_race_predictions", description: "Get predicted race times for 5K, 10K, half marathon, and marathon based on current fitness", inputSchema: { type: "object", properties: {} }, },
- src/index.ts:417-419 (registration)Registration of the get_race_predictions tool in the CallToolRequestHandler switch statement, mapping the tool name to the handler function.case "get_race_predictions": result = await getRacePredictions(); break;
- src/index.ts:28-39 (helper)Helper function used by getRacePredictions to format seconds into readable time strings (e.g., "1:23:45").function formatTime(seconds: number | null): string { if (!seconds) return "N/A"; const hrs = Math.floor(seconds / 3600); const mins = Math.floor((seconds % 3600) / 60); const secs = Math.round(seconds % 60); if (hrs > 0) { return `${hrs}:${mins.toString().padStart(2, "0")}:${secs .toString() .padStart(2, "0")}`; } return `${mins}:${secs.toString().padStart(2, "0")}`; }