statcast_batter
Retrieve detailed pitch-level data for MLB batters, including pitch types, velocities, exit velocities, launch angles, and expected batting averages within specified date ranges.
Instructions
Get pitch-level Statcast data for a specific batter in a date range.
Returns every pitch the batter saw — pitch type, velocity, exit velocity, launch angle, expected batting average, and much more.
Args: player_name: Full name of the batter (e.g. 'Aaron Judge'). start_date: Start date in YYYY-MM-DD format. end_date: End date in YYYY-MM-DD format (defaults to start_date).
Great for analyzing a hitter's performance over a specific period.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| player_name | Yes | ||
| start_date | Yes | ||
| end_date | No |
Implementation Reference
- src/statcast_mcp/server.py:409-445 (handler)The MCP tool 'statcast_batter' is defined and implemented here using the @mcp.tool() decorator. It handles player resolution and fetches data using the pybaseball library.
@mcp.tool() def statcast_batter( player_name: str, start_date: str, end_date: str | None = None, ) -> str: """Get pitch-level Statcast data for a specific batter in a date range. Returns every pitch the batter saw — pitch type, velocity, exit velocity, launch angle, expected batting average, and much more. Args: player_name: Full name of the batter (e.g. 'Aaron Judge'). start_date: Start date in YYYY-MM-DD format. end_date: End date in YYYY-MM-DD format (defaults to start_date). Great for analyzing a hitter's performance over a specific period. """ from pybaseball import statcast_batter as _sb try: mlbam_id, name = _resolve_player(player_name) except ValueError as e: return str(e) if end_date is None: end_date = start_date try: data = _sb(start_dt=start_date, end_dt=end_date, player_id=mlbam_id) except Exception as e: return f"Error fetching data for {player_name}: {e}" data = _trim_pitch_cols(data) return ( f"Statcast batting data for {name} (MLBAM ID: {mlbam_id}):\n\n" + _fmt(data, max_rows=100)