Skip to main content
Glama
mpizza

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
dateNo

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool fetches results but doesn't describe important behavioral traits such as error handling (e.g., what happens for invalid dates), rate limits, authentication needs, or whether it's a read-only operation. The description is too sparse for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise and well-structured. It starts with a clear purpose statement, followed by an 'Args' section explaining the parameter and a 'Returns' section describing the output. Each sentence earns its place, though the formatting could be slightly cleaner (e.g., bullet points instead of plain text sections).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one optional parameter) and lack of annotations/output schema, the description is minimally complete. It covers the basic purpose, parameter, and return type, but misses behavioral details (e.g., error cases, date format) and doesn't leverage sibling context. It's adequate but leaves clear gaps for an agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter 'date', explaining its purpose ('The date for fetching game results') and default behavior ('default is today'). Since schema description coverage is 0% and there's only one parameter, this adequately compensates, though it lacks format details (e.g., expected date string format like 'YYYY-MM-DD').

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Fetch MLB game results for a given date'. It specifies the verb ('fetch'), resource ('MLB game results'), and scope ('for a given date'). However, it doesn't explicitly differentiate from sibling tools like 'get_mlb_schedule' or 'mlb_team_result', which likely serve related but distinct purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal usage guidance. It mentions the default behavior ('default is today') but doesn't explain when to use this tool versus alternatives like 'get_mlb_schedule' (which might fetch future games) or 'mlb_team_result' (which could be team-specific). No explicit when-not-to-use or prerequisite information is included.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.
ParametersJSON Schema
NameRequiredDescriptionDefault
start_dateNo
end_dateNo
team_idNo

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes the tool as a retrieval operation, which implies read-only behavior, and specifies the return format. However, it lacks details on error handling, rate limits, or authentication needs, leaving behavioral gaps for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and front-loaded with the core purpose, followed by clear sections for arguments and returns. Each sentence adds value without redundancy, making it efficient and easy to parse for an AI agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 3 parameters with 0% schema coverage, and no output schema, the description is largely complete for a read-only tool. It covers purpose, parameters, and return format. However, it lacks some behavioral context like error cases or performance hints, which could enhance completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains each parameter's purpose, optional nature, defaults, and formats (e.g., 'YYYY-MM-DD' for dates, team ID as integer), and clarifies that 'team_id' defaults to None for all teams, compensating fully for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('retrieves') and resources ('MLB game schedule'), distinguishing it from sibling tools like 'get_daily_results' and 'mlb_team_result' which likely focus on results rather than schedules. It specifies the scope includes date ranges and optional team filtering.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning optional parameters for date ranges and team filtering, but does not explicitly state when to use this tool versus alternatives like the sibling tools. No exclusions or specific contexts are provided beyond the basic functionality.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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
                  }
ParametersJSON Schema
NameRequiredDescriptionDefault
team_nameYes
dateNo

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: it retrieves data (read-only implied), returns a dictionary with specific structure or None if no game found, and handles an optional date parameter with a default. It doesn't mention rate limits, authentication needs, or data freshness, but covers core behavior adequately for a read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the purpose clearly. The Args and Returns sections are structured efficiently, with each sentence adding value (e.g., examples, defaults, structure details). No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (2 parameters, no annotations, no output schema), the description is complete. It explains purpose, parameters, return values (including structure and None case), and usage context. No output schema exists, so describing the return structure is necessary and well-done.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It fully documents both parameters: team_name (name, example) and date (optional, format, default). It adds meaning beyond the bare schema by explaining usage and format, which is essential given the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'retrieves' and the resource 'results (scoring plays and highlights) for a specific MLB team's most recent game.' It distinguishes from sibling tools by specifying it's for a specific team's most recent game, unlike get_daily_results (likely broader) and get_mlb_schedule (likely schedule-focused).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context: use this to get results for a specific team's most recent game. It doesn't explicitly state when not to use it or name alternatives, but the specificity implies it's not for general results or schedules, which aligns with sibling tool names. No misleading guidance is present.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.4/5.0
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 issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    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
  • F
    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
    6
  • F
    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.
    3

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/mpizza/mcp_mlb_statsapi'

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