Skip to main content
Glama
alex-rimerman

Statcast MCP Server

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

TableJSON Schema
NameRequiredDescriptionDefault
yearYes
min_plate_appearancesNo
player_nameNo

Implementation Reference

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

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