mcmillan_predict_race_times
Predict race times for standard distances using McMillan methodology based on a single race performance. Input distance and time to get projected finish times.
Instructions
Predict race times for standard distances based on a single race performance using McMillan methodology.
Args: distance: Race distance in meters time: Race time in seconds
Returns: Dictionary containing predicted race times in HH:MM:SS format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| distance | Yes | ||
| time | Yes |
Implementation Reference
- The MCP tool handler function for 'mcmillan_predict_race_times'. Decorated with @mcp.tool for registration. Performs basic error handling and calls the core predict_race_times helper.@mcp.tool def mcmillan_predict_race_times(distance: float, time: float) -> dict: """ Predict race times for standard distances based on a single race performance using McMillan methodology. Args: distance: Race distance in meters time: Race time in seconds Returns: Dictionary containing predicted race times in HH:MM:SS format """ try: return predict_race_times(distance, time) except Exception as e: return {"error": str(e)}
- Core helper function implementing the McMillan race time predictions using pre-trained polynomial models loaded from pickle file. Handles input normalization with Riegel's formula, model selection, and predictions for standard race distances.def predict_race_times(distance_meters: float, time_seconds: float) -> dict: """ Predict race times for all standard distances based on a single race performance using our event-specific functional models. This version normalizes the input time to match the model's base distance using Riegel's formula if the input race distance is not one of the standard distances. Args: distance_meters: Race distance in meters (input for the model). time_seconds: Race time in seconds (input for the model). Returns: dict: Dictionary with distance names as keys and predicted times as values in HH:MM:SS format. Raises: InvalidInputError: If distance or time is not positive or if inputs are unrealistic. """ _assert_inputs(distance_meters, time_seconds) available_input_distances = _available_model_distances("race_times") (normalized_distance, normalized_time) = _normalize_inputs(available_input_distances, distance_meters, time_seconds) predicted_race_times = {} for race_name, output_distance in RACE_DISTANCES.items(): # If the race to predict is the user's input race, just use the original time if output_distance == int(distance_meters): predicted_race_times[race_name] = format_pace_hms(time_seconds) continue model = _get_race_time_model(normalized_distance, race_name) try: predicted_time = _predict_with_model(normalized_time, model) if not np.isnan(predicted_time): predicted_race_times[race_name] = format_pace_hms(predicted_time) except Exception: continue return predicted_race_times
- src/running_formulas_mcp/server.py:211-211 (registration)The @mcp.tool decorator registers the mcmillan_predict_race_times function as an MCP tool.@mcp.tool
- Docstring providing input/output schema description and type hints for the tool.""" Predict race times for standard distances based on a single race performance using McMillan methodology. Args: distance: Race distance in meters time: Race time in seconds Returns: Dictionary containing predicted race times in HH:MM:SS format """