MLB API

v1.0.0Analyticsstable

Python MCP server that provides comprehensive access to MLB statistics and baseball data through a FastAPI-based interface. Acts as a bridge between AI applications and MLB data sources, enabling seamless integration of baseball statistics, game info

mcp-server
Share:
51
Stars
0
Downloads
0
Weekly
0/5

What is MLB API?

MLB API is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to python mcp server that provides comprehensive access to mlb statistics and baseball data through a fastapi-based interface. acts as a bridge between ai applications and mlb data sources, enabling seam...

Python MCP server that provides comprehensive access to MLB statistics and baseball data through a FastAPI-based interface. Acts as a bridge between AI applications and MLB data sources, enabling seamless integration of baseball statistics, game info

This server falls under the Analytics category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Python MCP server that provides comprehensive access to MLB

Use Cases

Query comprehensive MLB statistics and game data. Get baseball scores, player stats, and historical information. Access sports analytics through AI.
guillochon

Maintainer

LicenseMIT License
Languagepython
Versionv1.0.0
UpdatedMay 18, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mlb-api

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use MLB API

The MLB API MCP Server is a Python-based server that provides comprehensive access to Major League Baseball statistics, game data, and historical records by wrapping the official MLB Stats API behind an MCP interface. It exposes over 20 tools covering standings, schedules, player stats, sabermetrics, box scores, game highlights, rosters, draft data, and awards — making it easy for AI assistants to answer detailed baseball questions without needing to call raw APIs. Sports analysts, fantasy baseball enthusiasts, and developers building baseball-aware applications can use it to query live and historical MLB data in natural language.

Prerequisites

  • Python 3.10+ and the `uv` package manager installed (pip install uv)
  • Git to clone the repository (no separate MLB API key required — the MLB Stats API is public)
  • Claude Desktop, Claude Code CLI, or another MCP-compatible client
  • Optional: Docker if you prefer a containerised deployment
1

Clone the repository

Clone the mlb-api-mcp repository to your local machine.

git clone https://github.com/guillochon/mlb-api-mcp.git
cd mlb-api-mcp
2

Create a virtual environment and install dependencies

Use uv to create an isolated Python environment and install all required packages.

uv venv
source .venv/bin/activate
uv pip install -e .
3

Start the server in stdio mode

For use with Claude Desktop or Claude Code, run the server in the default stdio transport mode.

uv run python main.py
4

Configure Claude Desktop

Add the mlb-api server to your claude_desktop_config.json, pointing to the absolute path of your cloned repository.

{
  "mcpServers": {
    "mlb-api": {
      "command": "uv",
      "args": ["run", "python", "main.py"],
      "cwd": "/absolute/path/to/mlb-api-mcp",
      "env": {
        "TZ": "America/New_York"
      }
    }
  }
}
5

Restart Claude Desktop and test

Fully quit and relaunch Claude Desktop. Open a conversation and ask a baseball question to verify the MLB data tools are available and returning results.

MLB API Examples

Client configuration

Complete claude_desktop_config.json block for the MLB API MCP Server using uv.

{
  "mcpServers": {
    "mlb-api": {
      "command": "uv",
      "args": ["run", "python", "main.py"],
      "cwd": "/absolute/path/to/mlb-api-mcp",
      "env": {
        "TZ": "America/New_York"
      }
    }
  }
}

Prompts to try

Example baseball questions that use the MLB API MCP Server's 20+ tools.

- "What are the current MLB standings by division?"
- "Show me the box score from last night's Yankees game."
- "What are Shohei Ohtani's career batting stats and advanced sabermetrics?"
- "Who is on the Boston Red Sox 26-man roster right now?"
- "What games are scheduled for this weekend and what time do they start?"
- "Which players won the Cy Young award in the last five years?"

Troubleshooting MLB API

Server fails to start with 'uv: command not found'

Install uv via 'pip install uv' or 'curl -LsSf https://astral.sh/uv/install.sh | sh'. After installation, open a new terminal session so the PATH update takes effect.

MLB API returns empty results or 404 errors

The MLB Stats API is a public API with no key required, but it may have occasional downtime or rate limits. Verify network access and try a direct test: 'curl https://statsapi.mlb.com/api/v1/teams'. Game data is only available for scheduled or completed games within the current season.

Incorrect timestamps or schedule times are off by hours

Set the TZ environment variable in your MCP config to your local timezone (e.g. 'America/New_York', 'America/Los_Angeles'). The server defaults to UTC, which shifts displayed game times from local broadcast times.

Frequently Asked Questions about MLB API

What is MLB API?

MLB API is a Model Context Protocol (MCP) server that python mcp server that provides comprehensive access to mlb statistics and baseball data through a fastapi-based interface. acts as a bridge between ai applications and mlb data sources, enabling seamless integration of baseball statistics, game info It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MLB API?

Follow the installation instructions on the MLB API GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with MLB API?

MLB API works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is MLB API free to use?

Yes, MLB API is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Analytics MCP Servers

Explore all analytics servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mlb-api": { "command": "npx", "args": ["-y", "mlb-api"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use MLB API?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides