get_live_game_play_by_play
Retrieve play-by-play data for a specific NBA game by providing its unique game ID. Access detailed information about each play, including sequences and events, for analysis or integration.
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-189 (handler)The handler function for the 'get_live_game_play_by_play' tool, registered via @mcp.tool decorator. It fetches play-by-play data using playbyplay.PlayByPlay(game_id), extracts actions from the dict, and handles errors.@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)}]