get_live_game_play_by_play
Retrieve detailed play-by-play data for NBA games using game IDs to analyze sequences, events, and game flow.
Instructions
Get the play-by-play data for a specific game by its ID. The play-by-play data includes detailed information about each play in the game.
Args: game_id: str The ID of the game.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_id | Yes |
Implementation Reference
- server.py:172-190 (handler)The handler function decorated with @mcp.tool that implements the 'get_live_game_play_by_play' tool. It retrieves live play-by-play data for a given NBA game ID using the nba_api library, extracting actions from the game's dictionary, with error handling.@mcp.tool def get_live_game_play_by_play(game_id: str) -> list: """ Get the play-by-play data for a specific game by its ID. The play-by-play data includes detailed information about each play in the game. Args: game_id: str The ID of the game. """ try: pbp = playbyplay.PlayByPlay(game_id) plays = pbp.get_dict()['game']['actions'] # plays = actions if not plays: raise ValueError(f"No play-by-play data found for game ID: {game_id}") return plays except Exception as e: return [{"error": str(e)}]