Skip to main content
Glama
alex-rimerman

Statcast MCP Server

statcast_batter_expected_stats

Calculate expected batting statistics (xBA, xSLG, xwOBA) to identify hitters whose performance aligns with or deviates from their quality of contact.

Instructions

Get expected batting stats (xBA, xSLG, xwOBA vs actual) from Statcast.

Returns xBA, xSLG, xwOBA and the gap from actual stats — what a batter deserves based on quality of contact.

Args: year: Season year (e.g. 2024). min_plate_appearances: Minimum PA to qualify (default 50). player_name: Optional. If set (e.g. 'Aaron Judge'), returns only that player's row — use this so a star is not cut off by the 50-row leaderboard limit.

Great for identifying lucky/unlucky hitters or a single player's expected line.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes
min_plate_appearancesNo
player_nameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function 'statcast_batter_expected_stats' which retrieves expected batting statistics by delegating to the 'pybaseball' library.
    def statcast_batter_expected_stats(
        year: int,
        min_plate_appearances: int = 50,
        player_name: str | None = None,
    ) -> str:
        """Get expected batting stats (xBA, xSLG, xwOBA vs actual) from Statcast.
    
        Returns xBA, xSLG, xwOBA and the gap from actual stats — what a batter
        *deserves* based on quality of contact.
    
        Args:
            year: Season year (e.g. 2024).
            min_plate_appearances: Minimum PA to qualify (default 50).
            player_name: Optional. If set (e.g. 'Aaron Judge'), returns only that
                player's row — use this so a star is not cut off by the 50-row
                leaderboard limit.
    
        Great for identifying lucky/unlucky hitters or a single player's expected line.
        """
        from pybaseball import statcast_batter_expected_stats as _fn
    
        try:
            data = _fn(year, minPA=min_plate_appearances)
        except Exception as e:
            return f"Error fetching expected batting stats: {e}"
    
        if player_name:
            try:
                data = _filter_player_rows(data, player_name)
            except ValueError as e:
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses the critical 50-row leaderboard limit, default 50 PA threshold, and explains what the gap represents ('deserves based on quality of contact'). Missing safety profile (implied read-only) and error behavior.

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?

Well-structured with purpose front-loaded, followed by return value explanation, Args documentation, and use-case summary. Every sentence adds value; no repetition or filler despite covering 3 parameters and behavioral constraints.

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

Completeness4/5

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

Appropriately complete given the output schema exists (so return values need less description). Covers the key constraint (50-row limit) that would affect agent planning. Minor gap: assumes familiarity with 'Statcast' without domain context (MLB).

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?

With 0% schema description coverage, the Args section fully compensates by documenting all three parameters: year includes example (2024), min_plate_appearances explains meaning and default (50), and player_name details the filtering behavior and use case (avoiding row limit cutoff).

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?

Description explicitly states 'Get expected batting stats (xBA, xSLG, xwOBA vs actual) from Statcast' with specific metrics and distinguishes from siblings by noting the 50-row leaderboard limit and expected-vs-actual focus, differentiating it from raw statcast_batter or batch tools.

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?

Provides clear use-case guidance ('Great for identifying lucky/unlucky hitters') and explicitly advises when to use player_name filter ('so a star is not cut off by the 50-row leaderboard limit'). Lacks explicit naming of sibling alternatives like expected_stats_batch.

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