pitcher_percentile_ranks
Compare pitcher performance metrics like spin rate, whiff percentage, and xERA against league averages using percentile rankings from 0-100.
Instructions
Statcast percentile ranks for pitchers vs the league (spin, whiff%, xERA, etc.).
Each metric is 0–100. Use for "How does this pitcher's stuff compare?"
Args: year: Season year (e.g. 2024). player_name: Optional. Filter to one pitcher (e.g. "Gerrit Cole").
Qualifying pitchers: Statcast minimum innings/appearance thresholds.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | ||
| player_name | No |
Implementation Reference
- src/statcast_mcp/server.py:1221-1251 (handler)The pitcher_percentile_ranks MCP tool handler, which utilizes pybaseball to fetch and optionally filter statcast percentile data.
@mcp.tool() def pitcher_percentile_ranks(year: int, player_name: str | None = None) -> str: """Statcast percentile ranks for pitchers vs the league (spin, whiff%, xERA, etc.). Each metric is 0–100. Use for "How does this pitcher's stuff compare?" Args: year: Season year (e.g. 2024). player_name: Optional. Filter to one pitcher (e.g. "Gerrit Cole"). Qualifying pitchers: Statcast minimum innings/appearance thresholds. """ from pybaseball import statcast_pitcher_percentile_ranks as _fn try: data = _fn(year) except Exception as e: return f"Error fetching pitcher 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) # ---------------------------------------------------------------------------