# MLB Stats Server

MLB Stats Server — an MCP server that gives your agent MLB data: schedules, box scores, Statcast, FanGraphs and Baseball Reference stats. Useful for questions about games and players.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · 4958 installs · ★ 34 repo stars
- Author: etweisberg
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/etweisberg/mlb-mcp
- Updated: 2026-09-20
- Security check: automated, 2026-11-16 (text) — warning: a command downloads a script from astral.sh and runs it right away. Do not run such commands without an explicit yes from the human.
- HTML: https://affpapa.org/en/nevibecode/mcp/mlb-stats-server

## What it does

The server exposes baseball data as agent tools. The MLB Stats API side covers schedules, standings, rosters, box scores, line scores and league leaders, and `lookup_player` finds a player. Statcast comes through `pybaseball`: single-game pulls, batter and pitcher data, exit velocity and barrels, expected stats, percentile ranks and pitch arsenals.

Some tools draw matplotlib plots and hand them back as base64 images. It is a Python project built on `mcp[cli]`, `mlb-statsapi` and `httpx`. To run it yourself you need uv, then `uv pip install -e .` and `python -m mlb_stats_mcp.server`. Logs go to stderr unless `MLB_STATS_LOG_FILE` points at a file.

With `--http` the server listens on `$PORT` (8081 by default) and serves MCP at `/mcp`. It accepts any Host and Origin out of the box, so a public deployment stays open until you restrict it. Set `MLB_STATS_ALLOWED_HOSTS` and `MLB_STATS_ALLOWED_ORIGINS` together, because hosts alone make the server reject every browser-based client.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Remote server: `https://mlb-mcp--etweisberg.run.tools`

## Install

### Claude Code (native platform)

**Platform CLI: remote server**
```bash
claude mcp add --transport http mlb-mcp https://mlb-mcp--etweisberg.run.tools
```

### Codex

**Platform CLI: remote server**
```bash
codex mcp add mlb-stats-server --url https://mlb-mcp--etweisberg.run.tools
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "mlb-stats-server": {
            "url": "https://mlb-mcp--etweisberg.run.tools"
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "mlb-stats-server": {
            "type": "http",
            "url": "https://mlb-mcp--etweisberg.run.tools"
        }
    }
}
```

### Gemini CLI

**Platform CLI: remote server**
```bash
gemini mcp add -t http mlb-stats-server https://mlb-mcp--etweisberg.run.tools
```

## When to use it
- look up the score and date of a team's last or next game
- read the box score and line score of a specific game
- compare two pitchers by Statcast pitch arsenal
- check a batter's exit velocity and barrels
- plot `pybaseball` data and get the chart back as an image

## Example prompts
- Use MLB Stats Server to show the standings and my team's next game
- Call `get_statcast_pitcher_pitch_arsenal` and compare the arsenals of two pitchers
- Find the player with `lookup_player`, then pull his Statcast expected stats

## Similar
- [mlb-data](https://affpapa.org/en/nevibecode/skills/mlb-data.md) — skill · 791 installs
- [fantasy-lineup-optimizer](https://affpapa.org/en/nevibecode/skills/fantasy-lineup-optimizer.md) — skill · 426 installs
- [quick-stats](https://affpapa.org/en/nevibecode/skills/quick-stats.md) — skill · 2100 installs
- [baseball-trend](https://affpapa.org/en/nevibecode/skills/baseball-trend.md) — skill · 1700 installs
- [youtube-stats](https://affpapa.org/en/nevibecode/skills/youtube-stats.md) — skill · 354 installs
- [Stats Compass](https://affpapa.org/en/nevibecode/mcp/stats-compass.md) — MCP server · ★ 16 repo stars

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
