get_mlb_game_scoring_plays
Retrieve scoring plays and game events from MLB games by game ID, with options to filter by event type, timecode, or specific fields.
Instructions
Get plays for a specific game by game_id, with optional filtering by eventType.
Args: game_id (int): The game ID. eventType (Optional[str]): Filter plays by this event type (e.g., 'scoring_play', 'home_run'). timecode (Optional[str]): Specific timecode for the play-by-play snapshot. fields (Optional[str]): Comma-separated list of fields to include.
Returns: dict: Game plays, optionally filtered by eventType.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_id | Yes | ||
| eventType | No | ||
| timecode | No | ||
| fields | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tests/test_mlb_api.py:28-30 (registration)In tests, registers tools via setup_mlb_tools(mcp) for testing the get_mlb_game_scoring_plays tool.
mcp = MagicMock() patch_mcp_tool(mcp) mlb_api.setup_mlb_tools(mcp) - tests/test_mlb_api.py:127-140 (handler)Test confirming the handler works, retrieves via get_tool and tests filtering by eventType."
def test_get_mlb_game_scoring_plays(mcp): get_mlb_game_scoring_plays = get_tool(mcp, "get_mlb_game_scoring_plays") assert get_mlb_game_scoring_plays is not None # Corrected: Each play should be a MagicMock with .result.eventType mock_play1 = MagicMock() mock_play1.result.eventType = "scoring_play" mock_play2 = MagicMock() mock_play2.result.eventType = "other" mock_plays = MagicMock() mock_plays.allplays = [mock_play1, mock_play2] with patch("mlb_api.mlb.get_game_play_by_play", return_value=mock_plays): result = get_mlb_game_scoring_plays(game_id=1, eventType="scoring_play") assert "plays" in result