Skip to main content
Glama
alex-rimerman

Statcast MCP Server

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

TableJSON Schema
NameRequiredDescriptionDefault
player_nameYes
start_dateYes
end_dateNo

Implementation Reference

  • 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)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alex-rimerman/statcast-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server