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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and successfully adds critical behavioral context: it explains the metric scale ('0–100 where higher is better') and qualifying criteria ('~2.1 PA per team game'). It does not mention rate limits or error behaviors, but covers the essential data interpretation rules.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with purpose front-loaded, followed by usage guidance, parameter documentation, and qualifying criteria. Every sentence adds unique value—from metric interpretation to filter behavior—with no redundant or wasted text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple 2-parameter schema and existence of an output schema (which removes the need to describe return values), the description is complete. It distinguishes from sibling tools, explains the Statcast-specific qualifying threshold, and provides sufficient context for an agent to invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, but the description fully compensates via the Args block. It documents both parameters with clear semantics and examples ('Season year (e.g. 2024)', 'returns only that player's row'), explaining not just types but the functional effect of the optional filter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the specific verb and resource ('Statcast percentile ranks for hitters vs the league') and provides concrete examples ('exit velo, barrel%, xwOBA'). It clearly distinguishes from the sibling 'pitcher_percentile_ranks' by specifying 'hitters' and noting the comparison is against the league.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit usage guidance ('Use to answer "How elite is this hitter on Statcast?" or compare league-wide'), giving clear context for when to invoke the tool. It lacks explicit exclusions or named alternatives (e.g., not mentioning when to use 'pitcher_percentile_ranks' instead), preventing a perfect score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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