get_mlb_teams
Retrieve MLB team data by specifying sport ID and optional season year for comprehensive baseball statistics integration.
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 |
|---|---|---|---|
| sport_id | No | ||
| season | No |
Implementation Reference
- mlb_api.py:692-711 (handler)The handler function decorated with @mcp.tool(), which registers and implements the get_mlb_teams tool. It retrieves MLB teams data using the mlb library, supporting optional season filtering, and returns teams or error.@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)}