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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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

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

No annotations are provided, so the description carries the full burden. It effectively discloses the return values (specific expected stats vs actual), notes the 'truncated leaderboard' behavior (explaining why to use player_name), and mentions the default value for minimum plate appearances. Missing only operational details like rate limits or error handling.

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 in the first sentence, followed by return value specifics, an Args block documenting parameters, and a final use-case sentence. Every sentence adds value; no repetition of schema structure or tautology.

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 existence of an output schema (which handles return value documentation), the description provides complete coverage: it identifies the data source (Statcast), explains the specific metrics returned, documents all parameters (compensating for empty schema descriptions), and provides usage context for the target analysis (over/underperformance detection).

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 description fully compensates by documenting all three parameters in the Args section: year includes an example (2024), min_plate_appearances clarifies 'PA against' (plate appearances against) and default (50), and player_name explains the behavior (avoids missing entries in truncated results) with an example ('Gerrit Cole').

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 clearly states the tool 'Get[s] expected stats allowed by pitchers from Statcast' with specific metrics (xBA, xSLG, xwOBA, xERA), distinguishing it from siblings like `statcast_pitcher` (general data) and `season_pitching_stats` (traditional stats) by emphasizing 'expected' versus 'actual' results and contact quality analysis.

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 context with 'Great for finding pitchers who outperformed or underperformed their contact quality,' indicating the analytical purpose. However, it does not explicitly name sibling alternatives (e.g., when to use this vs `expected_stats_batch` or `statcast_pitcher`), so it lacks explicit when-not guidance.

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