Skip to main content
Glama
stevenyuser

NBA MCP Server

by stevenyuser

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
NameRequiredDescriptionDefault
game_idYes

Implementation Reference

  • 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)}]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/stevenyuser/nba_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server