get_live_game_boxscore
Retrieve live NBA game statistics including scores, player performance data, and game events using a specific game identifier.
Instructions
Get the box score for a specific game by its ID. The box score includes live data for the game, such as scores, player stats, timeouts, and more.
Args: game_id: str The ID of the game.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_id | Yes |
Implementation Reference
- server.py:154-170 (handler)The main handler function decorated with @mcp.tool, which defines and registers the get_live_game_boxscore tool. It fetches live boxscore data using nba_api.@mcp.tool def get_live_game_boxscore(game_id: str) -> dict: """ Get the box score for a specific game by its ID. The box score includes live data for the game, such as scores, player stats, timeouts, and more. Args: game_id: str The ID of the game. """ try: box = boxscore.BoxScore(game_id) if not box.game or not box.game.get_dict(): raise ValueError(f"No box score found for game ID: {game_id}") return box.game.get_dict() except Exception as e: return {"error": str(e)}
- server.py:154-154 (registration)The @mcp.tool decorator registers the tool with the MCP server.@mcp.tool
- server.py:156-163 (schema)Docstring defining the tool's input schema (game_id: str) and description.""" Get the box score for a specific game by its ID. The box score includes live data for the game, such as scores, player stats, timeouts, and more. Args: game_id: str The ID of the game. """
- server.py:4-4 (helper)Import of boxscore endpoint used in the handler.from nba_api.live.nba.endpoints import scoreboard, boxscore, playbyplay