Skip to main content
Glama

get_mlb_standings

Retrieve current MLB standings for any season with options to filter by league, date, and standings type. Provides team rankings and statistics for American League, National League, or both.

Instructions

Get current MLB standings for a given season (year).

Args: season (Optional[int]): The year for which to retrieve standings. Defaults to current year. standingsTypes (Optional[str]): The type of standings to retrieve (e.g., 'regularSeason', 'wildCard', etc.). date (Optional[str]): Date in 'YYYY-MM-DD' format. hydrate (Optional[str]): Additional data to hydrate in the response. fields (Optional[str]): Comma-separated list of fields to include in the response. league (str): Filter by league. Accepts 'AL', 'NL', or 'both' (default: 'both').

Returns: dict: Standings for the specified league(s) and season.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
seasonNo
standingsTypesNo
dateNo
hydrateNo
fieldsNo
leagueNoboth

Implementation Reference

  • The handler function for the 'get_mlb_standings' tool. It fetches standings data for the American League (league ID 103) and/or National League (league ID 104) using the mlbstatsapi library, based on the provided season, league filter, and other optional parameters.
    @mcp.tool() def get_mlb_standings( season: Optional[int] = None, standingsTypes: Optional[str] = None, date: Optional[str] = None, hydrate: Optional[str] = None, fields: Optional[str] = None, league: str = "both", ) -> dict: """ Get current MLB standings for a given season (year). Args: season (Optional[int]): The year for which to retrieve standings. Defaults to current year. standingsTypes (Optional[str]): The type of standings to retrieve (e.g., 'regularSeason', 'wildCard', etc.). date (Optional[str]): Date in 'YYYY-MM-DD' format. hydrate (Optional[str]): Additional data to hydrate in the response. fields (Optional[str]): Comma-separated list of fields to include in the response. league (str): Filter by league. Accepts 'AL', 'NL', or 'both' (default: 'both'). Returns: dict: Standings for the specified league(s) and season. """ try: if season is None: season = datetime.now().year params = {} if standingsTypes is not None: params["standingsTypes"] = standingsTypes if date is not None: params["date"] = date if hydrate is not None: params["hydrate"] = hydrate if fields is not None: params["fields"] = fields league = league.upper() result = {} if league == "AL" or league == "BOTH": result["AL"] = mlb.get_standings(103, season=str(season), **params) if league == "NL" or league == "BOTH": result["NL"] = mlb.get_standings(104, season=str(season), **params) if not result: return {"error": "Invalid league parameter. Use 'AL', 'NL', or 'both'."} return {"standings": result} except Exception as e: return {"error": str(e)}
  • main.py:22-22 (registration)
    The call to setup_mlb_tools(mcp) which registers all MLB tools, including 'get_mlb_standings', with the FastMCP server instance.
    setup_mlb_tools(mcp)

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