Skip to main content
Glama

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

Implementation Reference

  • 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()

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/guillochon/mlb-api-mcp'

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