Skip to main content
Glama
guillochon

mlb-api-mcp

get_mlb_players

Retrieve comprehensive MLB player data by sport ID and optional season filter for baseball statistics integration.

Instructions

Get all players for a specific sport.

Args: sport_id (int): Sport ID (default: 1 for MLB). season (Optional[int]): Filter players by a specific season (year).

Returns: dict: All players for the specified sport.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sport_idNo
seasonNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get_mlb_players' MCP tool. Decorated with @mcp.tool() which registers the tool and infers the schema from type annotations and docstring. Fetches all MLB players using mlbstatsapi.Mlb().get_people().
    @mcp.tool()
    def get_mlb_players(sport_id: int = 1, season: Optional[int] = None) -> dict:
        """
        Get all players for a specific sport.
    
        Args:
            sport_id (int): Sport ID (default: 1 for MLB).
            season (Optional[int]): Filter players by a specific season (year).
    
        Returns:
            dict: All players for the specified sport.
        """
        try:
            params = {}
            if season is not None:
                params["season"] = season
            players = mlb.get_people(sport_id=sport_id, **params)
            return {"players": players}
        except Exception as e:
            return {"error": str(e)}
  • main.py:21-23 (registration)
    Top-level registration of MLB tools (including get_mlb_players) by invoking setup_mlb_tools(mcp) in the main MCP server initialization.
    # Setup all MLB and generic tools
    setup_mlb_tools(mcp)
    setup_generic_tools(mcp)
  • main.py:12-12 (registration)
    Import of the MLB tools setup function used for registration.
    from mlb_api import setup_mlb_tools
Behavior2/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 of behavioral disclosure. It mentions the tool 'Get all players' but doesn't describe key behaviors: whether it's paginated, rate-limited, requires authentication, returns structured data, or handles errors. The description is minimal and lacks operational context, leaving significant gaps for a tool with parameters and output.

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 well-structured and concise. It starts with a clear purpose statement, followed by 'Args' and 'Returns' sections that efficiently document parameters and output. Every sentence earns its place, with no redundant or vague language, making it easy to parse quickly.

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

Completeness3/5

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

Given the tool has an output schema (returns dict), the description doesn't need to detail return values. However, with no annotations and 2 parameters, the description is minimal—it covers basic parameter semantics but lacks behavioral context (e.g., pagination, error handling). For a simple read operation, this might be adequate, but it falls short of being fully informative for reliable agent use.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaningful context: 'sport_id' is explained with a default value (1 for MLB) and 'season' is clarified as an optional filter by year. This goes beyond the schema's basic types and defaults, providing practical usage hints. However, it doesn't cover all potential semantics like valid sport_id ranges or season format.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get all players for a specific sport.' It specifies the verb ('Get') and resource ('players'), and while it doesn't explicitly differentiate from siblings like 'get_mlb_roster' or 'get_mlb_player_info', the focus on 'all players' provides some distinction. However, it could be more specific about scope or data granularity compared to similar tools.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_mlb_roster' (which might list players by team) or 'get_mlb_player_info' (which might provide detailed individual data), leaving the agent to guess based on names alone. The only implied usage is for retrieving player lists, but no context or exclusions are provided.

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/guillochon/mlb-api-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server