statcast_pitcher_expected_stats
Analyze pitcher performance by comparing expected stats (xBA, xSLG, xwOBA, xERA) against actual results to evaluate contact quality versus outcomes.
Instructions
Get expected stats allowed by pitchers from Statcast.
Returns xBA, xSLG, xwOBA, xERA allowed vs actual — contact quality vs results.
Args: year: Season year (e.g. 2024). min_plate_appearances: Minimum PA against to qualify (default 50). player_name: Optional. If set (e.g. 'Gerrit Cole'), returns only that pitcher's row (avoids missing them in the truncated leaderboard).
Great for finding pitchers who outperformed or underperformed their contact quality.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | ||
| min_plate_appearances | No | ||
| player_name | No |
Implementation Reference
- src/statcast_mcp/server.py:762-798 (handler)The handler function 'statcast_pitcher_expected_stats' which retrieves expected pitching stats using the pybaseball library and performs optional filtering by player name.
@mcp.tool() def statcast_pitcher_expected_stats( year: int, min_plate_appearances: int = 50, player_name: str | None = None, ) -> str: """Get expected stats allowed by pitchers from Statcast. Returns xBA, xSLG, xwOBA, xERA allowed vs actual — contact quality vs results. Args: year: Season year (e.g. 2024). min_plate_appearances: Minimum PA against to qualify (default 50). player_name: Optional. If set (e.g. 'Gerrit Cole'), returns only that pitcher's row (avoids missing them in the truncated leaderboard). Great for finding pitchers who outperformed or underperformed their contact quality. """ from pybaseball import statcast_pitcher_expected_stats as _fn try: data = _fn(year, minPA=min_plate_appearances) except Exception as e: return f"Error fetching expected pitching stats: {e}" if player_name: try: data = _filter_player_rows(data, player_name) except ValueError as e: return str(e) if data.empty: return ( f"No expected-stats row for {player_name} in {year} at " f"{min_plate_appearances}+ PA faced. Try a lower min_plate_appearances." ) return _fmt(data, max_rows=50)