statcast_batter_expected_stats
Calculate expected batting statistics (xBA, xSLG, xwOBA) to identify hitters whose performance aligns with or deviates from their quality of contact.
Instructions
Get expected batting stats (xBA, xSLG, xwOBA vs actual) from Statcast.
Returns xBA, xSLG, xwOBA and the gap from actual stats — what a batter deserves based on quality of contact.
Args: year: Season year (e.g. 2024). min_plate_appearances: Minimum PA to qualify (default 50). player_name: Optional. If set (e.g. 'Aaron Judge'), returns only that player's row — use this so a star is not cut off by the 50-row leaderboard limit.
Great for identifying lucky/unlucky hitters or a single player's expected line.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | ||
| min_plate_appearances | No | ||
| player_name | No |
Implementation Reference
- src/statcast_mcp/server.py:721-750 (handler)The handler function 'statcast_batter_expected_stats' which retrieves expected batting statistics by delegating to the 'pybaseball' library.
def statcast_batter_expected_stats( year: int, min_plate_appearances: int = 50, player_name: str | None = None, ) -> str: """Get expected batting stats (xBA, xSLG, xwOBA vs actual) from Statcast. Returns xBA, xSLG, xwOBA and the gap from actual stats — what a batter *deserves* based on quality of contact. Args: year: Season year (e.g. 2024). min_plate_appearances: Minimum PA to qualify (default 50). player_name: Optional. If set (e.g. 'Aaron Judge'), returns only that player's row — use this so a star is not cut off by the 50-row leaderboard limit. Great for identifying lucky/unlucky hitters or a single player's expected line. """ from pybaseball import statcast_batter_expected_stats as _fn try: data = _fn(year, minPA=min_plate_appearances) except Exception as e: return f"Error fetching expected batting stats: {e}" if player_name: try: data = _filter_player_rows(data, player_name) except ValueError as e: