get_mlb_teams
Retrieve all MLB teams for a specific sport using sport ID and optional season filter. Returns a dictionary of teams for easy integration with baseball data applications.
Instructions
Get all teams for a specific sport.
Args: sport_id (int): Sport ID (default: 1 for MLB). season (Optional[int]): Filter teams by a specific season (year).
Returns: dict: All teams for the specified sport.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| season | No | ||
| sport_id | No |
Implementation Reference
- mlb_api.py:692-712 (handler)The handler function decorated with @mcp.tool() that implements the logic for retrieving MLB teams using the mlbstatsapi.Mlb().get_teams() method. This is the core implementation of the tool.@mcp.tool() def get_mlb_teams(sport_id: int = 1, season: Optional[int] = None) -> dict: """ Get all teams for a specific sport. Args: sport_id (int): Sport ID (default: 1 for MLB). season (Optional[int]): Filter teams by a specific season (year). Returns: dict: All teams for the specified sport. """ try: params = {} if season is not None: params["season"] = season teams = mlb.get_teams(sport_id=sport_id, **params) return {"teams": teams} except Exception as e: return {"error": str(e)}
- main.py:22-22 (registration)The call to setup_mlb_tools(mcp) in the main server initialization, which defines and registers all MLB tools including get_mlb_teams via the @mcp.tool() decorators.setup_mlb_tools(mcp)