Skip to main content
Glama
baseball-mcp

baseball-mcp

by mpizza

baseball-mcp: An MLB Stats API Wrapper for MCP

This project provides an MCP (Model Context Protocol) that acts as a wrapper for the MLB Stats API. It allows you to easily access and process various MLB data points, including schedules, game results, and team information. This server is designed for efficient data retrieval and processing within an MCP framework.

Demo Videos

Here are a couple of demo videos showcasing the capabilities of mcp_mlb_statsapi:

  • Demo 1: MCP MLB Stats API - Quick Overview

  • Quick Overview

  • Demo 2: MCP MLB Stats API - 輸入中文也可以

  • 輸入中文也可以

Related MCP server: Formula One MCP Server

Features

  • Game Schedules: Retrieve MLB game schedules for specified date ranges, optionally filtering by team.

  • Game Results: Fetch daily game results, including scores, winning/losing teams, and winning pitcher.

  • Team Results: Get detailed results for a specific team's most recent game, including scoring plays and highlights.

  • Player Lookup: Look up player IDs using last name, first name, or a combination of both. Supports fuzzy matching.

Installation

Prerequisites

  • Python 3.10 or newer

  • uv package manager:

If you're on Mac, please install uv as

brew install uv

On Windows

powershell -c "irm https://astral.sh/uv/install.ps1 | iex" 

Otherwise installation instructions are on their website: Install uv

Install via PyPI

The mcp_mlb_statsapi package is available on PyPI and can be installed using pip:

pip install mcp_mlb_statsapi

Install via Github

or you can clone this repo, run it with soruce code.

uv venv
source .venv/bin/activate
uv pip install -r requirements.txt

Claude for Desktop Integration

Go to Claude > Settings > Developer > Edit Config > claude_desktop_config.json to include the following:

    {
      "mcpServers": {
        "mcp_mlb_statsapi": {
           "command": "{YOUR_PYTHON_EXECUTABLE_PATH}/python",
            "args": ["-m",
            "mcp_mlb_statsapi"]
          }
        }
    }

If you install it via source code

{
  "mcpServers": {
    "mcp_mlb_statsapi": {
        "command": "{YOUR_UV_EXECUTABLE_PATH}/uv",
        "args": [
            "--directory",
            "{YOUR_PROJECT_PATH}/src/mcp_mlb_statsapi",
            "run",
            "mcp_mlb_statsapi"
        ]
    }
  }
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

References

This project utilizes the following external libraries and resources:

Available Tools

3 tools
get_daily_resultsB

Fetch MLB game results for a given date (default is today) Args: date (str): The date for fetching game results. Returns: list: A list of dictionaries containing game details.

Inputs: date.

get_mlb_scheduleA
Retrieves the MLB game schedule for a specified date range, optionally for a specific team.

Args:
    start_date (str, optional): The start date for the schedule (YYYY-MM-DD). Defaults to today.
    end_date (str, optional): The end date for the schedule (YYYY-MM-DD). Defaults to today.
    team_id (int, optional): The ID of the team to get the schedule for. Defaults to None (all teams).

Returns:
    list: A list of dictionaries, where each dictionary represents a game in the schedule.
          Each game dictionary contains details like game ID, date, time, home team, away team, etc.

Inputs: start_date, end_date, team_id.

mlb_team_resultA
Retrieves the results (scoring plays and highlights) for a specific MLB team's most recent game.

Args:
    team_name (str): The name of the MLB team (e.g., "Los Angeles Dodgers").
    date (str, optional): The date for the schedule (YYYY-MM-DD). Defaults to today.
Returns:
    dict or None: A dictionary containing the scoring plays and game highlights for the team's most recent game,
                  or None if no game is found for the team.
                  The dictionary has the following structure:
                  {
                      "scoring_plays": list,  # List of scoring plays
                      "game_highlights": list  # List of game highlights
                  }

Inputs: team_name (required), date.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 3 tools

    Disambiguation4/5

    The three tools have distinct primary purposes: get_daily_results focuses on game outcomes for all teams on a date, get_mlb_schedule provides scheduling information across a date range, and mlb_team_result delivers detailed scoring/highlights for a specific team's recent game. However, there is some overlap between get_daily_results and mlb_team_result in that both can return game results for a date, which could cause minor confusion for an agent.

    Naming Consistency3/5

    The naming is mixed: get_daily_results and get_mlb_schedule follow a consistent verb_noun pattern, but mlb_team_result deviates by placing the domain prefix first and using a noun_verb structure. This inconsistency reduces predictability, though the names remain readable and descriptive.

    Tool Count3/5

    With only 3 tools, the server feels thin for covering the MLB domain comprehensively. While the tools address key aspects like results, schedules, and team details, the limited count may hinder complex agent workflows, such as accessing player stats, standings, or historical data, making it borderline appropriate.

    Completeness2/5

    The tool set has significant gaps for a baseball server. It lacks essential operations like retrieving team standings, player statistics, game box scores, or live scores, and there is no CRUD coverage for user interactions (e.g., favorites or predictions). This incompleteness will likely cause agent failures when handling common baseball queries beyond basic scheduling and results.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Provides Formula One data and statistics through a Model Context Protocol interface, allowing users to access race calendars, session results, driver statistics, telemetry data, and championship standings.
      8
      11
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Provides structured access to NHL data including teams, players, standings, schedules, and statistics through the Model-Context Protocol pattern.
      25
      5
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides real-time access to football (soccer) data including fixtures, standings, teams, players, transfers, and injuries through the API-Football service via the Model Context Protocol.
      4
      ISC