get_team_year_by_year_stats
Retrieve historical performance data for NBA teams by entering their ID to analyze trends and statistics across multiple seasons.
Instructions
Get year-by-year stats for a team by their ID.
Args: team_id: str The id of the team.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| team_id | Yes |
Implementation Reference
- server.py:82-96 (handler)The handler function decorated with @mcp.tool, which registers and implements the get_team_year_by_year_stats tool. It retrieves year-by-year stats for a given team ID using the nba_api library.@mcp.tool def get_team_year_by_year_stats(team_id: str) -> dict: """ Get year-by-year stats for a team by their ID. Args: team_id: str The id of the team. """ try: stats = teamyearbyyearstats.TeamYearByYearStats(team_id=team_id) return stats.get_dict() except Exception as e: return {"error": str(e)}
- server.py:82-82 (registration)The @mcp.tool decorator registers the function as an MCP tool.@mcp.tool
- server.py:83-90 (schema)Input schema defined by type hints (team_id: str) and output (dict), with docstring describing args.def get_team_year_by_year_stats(team_id: str) -> dict: """ Get year-by-year stats for a team by their ID. Args: team_id: str The id of the team. """
- server.py:3-3 (helper)Import of teamyearbyyearstats endpoint used by the tool.from nba_api.stats.endpoints import playercareerstats, playerawards, playergamelog, teamyearbyyearstats, teamdetails, teamgamelog, leaguestandingsv3