MLB Stats MCP Server

by etweisberg

28 stars
372 downloads
Not rated
GitHub

About

MCP server for advanced baseball analytics (statcast, fangraphs, baseball reference, mlb stats API)

Details

Author
etweisberg
GitHub stars
28
Downloads
372
Categories
Other

- Combines MLB Stats API, Statcast, FanGraphs, and Baseball Reference data.
- Generates matplotlib plots returned as base64-encoded images.
- Configurable logging via environment variables (MLB_STATS_LOG_LEVEL, MLB_STATS_LOG_FILE).
- Comprehensive test suite using pytest and pytest-asyncio.
- Linting and code formatting enforced by Ruff and pre-commit hooks.
- Option to install automatically via Smithery for Claude Desktop.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MLB Stats MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install uv, create a virtual environment (uv venv), activate it, and install dependencies (uv pip install -e .). Set the ANTHROPIC_API_KEY environment variable and optionally configure logging. Then add the server to your MCP client (e.g., Claude Desktop) using the provided JSON configuration.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mlb stats mcp server": {
            "mlb-mcp": {
                "command": "uv",
                "args": [
                    "venv"
                ]
            }
        }
    }
}

McpServers

{
    "mlb-mcp": {
        "command": "uv",
        "args": [
            "venv"
        ]
    }
}

MLB Stats MCP Server

Tests
Pre-commit
smithery badge

A Python project that creates a Model Context Protocol (MCP) server for accessing MLB statistics data through the MLB Stats API and pybaseball library for statcast, fangraphs, and baseball reference statistics. This server provides structured API access to baseball statistics that can be used with MCP-compatible clients.

Project Structure

- mlb_stats_mcp/ - Main package directory
- server.py - Core MCP server implementation
- tools/ - MCP tool implementations
- mlb_statsapi_tools.py - MLB StatsAPI tool definitions
- statcast_tools.py - Statcast data tool definitions
- pybaseball_plotting_tools.py - Additional pybaseball tools provided for generating matplotlib plots and returning base64 encoded images
- pybaseball_supp_tools.py - Supplemental pybaseball functions for interfacing with fangraphs, baseball reference, and other data sources
- utils/ - Utility modules
- logging_config.py - Logging configuration
- images.py - functions related to handling plot images
- tests/ - Test suite for verifying server functionality
- pyproject.toml - Project configuration and dependencies
- .pre-commit-config.yaml - Pre-commit hooks configuration
- .github/ - GitHub Actions workflows

Tools

Setup

1. Install uv if you haven't already:

curl -LsSf https://astral.sh/uv/install.sh | sh

2. Create and activate a virtual environment:

```bash
uv venv
source .venv/bin/activate # On Unix/macOS

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.