get_mlb_boxscore
Retrieve detailed boxscore data for a specific MLB game using game_id. Customize results with optional timecode or fields parameters for targeted insights.
Instructions
Get boxscore for a specific game by game_id.
Args: game_id (int): The game ID. timecode (Optional[str]): Specific timecode for the boxscore snapshot. fields (Optional[str]): Comma-separated list of fields to include.
Returns: dict: Boxscore information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | ||
| game_id | Yes | ||
| timecode | No |
Implementation Reference
- mlb_api.py:370-392 (handler)The handler function implementing the logic for the 'get_mlb_boxscore' tool. It retrieves the boxscore data for a given game ID using the mlbstatsapi library, with optional timecode and fields parameters.@mcp.tool() def get_mlb_boxscore(game_id: int, timecode: Optional[str] = None, fields: Optional[str] = None) -> dict: """ Get boxscore for a specific game by game_id. Args: game_id (int): The game ID. timecode (Optional[str]): Specific timecode for the boxscore snapshot. fields (Optional[str]): Comma-separated list of fields to include. Returns: dict: Boxscore information. """ try: params = {} if timecode is not None: params["timecode"] = timecode if fields is not None: params["fields"] = fields boxscore = mlb.get_game_box_score(game_id, **params) return boxscore except Exception as e: return {"error": str(e)}
- main.py:22-22 (registration)The call to setup_mlb_tools(mcp) in the main server setup, which registers all MLB tools including 'get_mlb_boxscore' via their @mcp.tool() decorators.setup_mlb_tools(mcp)
- mlb_api.py:370-370 (registration)The @mcp.tool() decorator on the get_mlb_boxscore function, which registers it as an MCP tool when setup_mlb_tools is called.@mcp.tool()