get_player_career_stats
Retrieve NBA player career statistics by inputting their unique player ID using the NBA MCP Server for accurate and detailed data analysis.
Instructions
Get career stats for a player by their ID.
Args: player_id: str The id of the player.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| player_id | Yes |
Implementation Reference
- server.py:13-25 (handler)The main handler function for the 'get_player_career_stats' tool. It takes a player_id, fetches career stats using nba_api.stats.endpoints.playercareerstats.PlayerCareerStats, and returns the data as a dict or an error message.def get_player_career_stats(player_id: str) -> dict: """ Get career stats for a player by their ID. Args: player_id: str The id of the player. """ try: stats = playercareerstats.PlayerCareerStats(player_id=player_id) return stats.get_dict() except Exception as e: return {"error": str(e)}
- server.py:12-12 (registration)The @mcp.tool decorator registers the get_player_career_stats function as an MCP tool.@mcp.tool
- server.py:14-20 (schema)The docstring provides the schema description, including the player_id argument of type str.""" Get career stats for a player by their ID. Args: player_id: str The id of the player. """