Skip to main content
Glama
alex-rimerman

Statcast MCP Server

batter_percentile_ranks

Analyze MLB hitter performance using Statcast percentile ranks for metrics like exit velocity and barrel rate. Compare players against league averages to evaluate their elite status in specific statistical categories.

Instructions

Statcast percentile ranks for hitters vs the league (exit velo, barrel%, xwOBA, etc.).

Each metric is 0–100 where higher is better for that stat. Use to answer "How elite is this hitter on Statcast?" or compare league-wide.

Args: year: Season year (e.g. 2024). player_name: Optional. If set, returns only that player's row (e.g. "Aaron Judge").

Qualifying batters: ~2.1 PA per team game (Statcast default).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes
player_nameNo

Implementation Reference

  • Implementation of the batter_percentile_ranks MCP tool, which fetches data from pybaseball and formats it.
    @mcp.tool()
    def batter_percentile_ranks(year: int, player_name: str | None = None) -> str:
        """Statcast percentile ranks for hitters vs the league (exit velo, barrel%, xwOBA, etc.).
    
        Each metric is 0–100 where higher is better for that stat. Use to answer
        "How elite is this hitter on Statcast?" or compare league-wide.
    
        Args:
            year: Season year (e.g. 2024).
            player_name: Optional. If set, returns only that player's row (e.g. "Aaron Judge").
    
        Qualifying batters: ~2.1 PA per team game (Statcast default).
        """
        from pybaseball import statcast_batter_percentile_ranks as _fn
    
        try:
            data = _fn(year)
        except Exception as e:
            return f"Error fetching batter percentile ranks: {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 percentile data found for {player_name} in {year}."
    
        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