Odel
mcp server espn

mcp server espn

Local
@christianclaudioPythonApache-2.0Updated 2 days ago

Model Context Protocol server for live & historical sports stats and odds via ESPN.

๐Ÿˆ mcp-server-espn

CI PyPI Python License: Apache-2.0 Coverage CodeRabbit Reviews

Enterprise-grade Model Context Protocol (MCP) server for live and historical sports analytics, consensus betting odds, and predictions via ESPN.
Equips AI agents with real-time sports intelligence, live win probabilities, in-depth boxscore statistics, roster hierarchies, and matchup analytics.


โš ๏ธ Disclaimers & Fair Use Notice

[!IMPORTANT] Community Project Disclaimer
mcp-server-espn is an independent open-source community project. It is not affiliated with, sponsored by, endorsed by, or supported by ESPN Inc. or The Walt Disney Company. "ESPN" is a trademark of ESPN Inc. All data provided via ESPN's public REST endpoints is intended for educational, research, and personal non-commercial use.


๐Ÿ’ก Why This Exists

Autonomous sports analysis requires high-velocity, structured, and resilient data feeds:

  1. Live Game State & Win Probability: Real-time game events (turnovers, scoring plays, pitching changes) shift momentum and expected outcomes dynamically.
  2. Key Player Injuries & Depth Chart Swaps: An in-game injury or substitution fundamentally alters team efficiency and tactical matchups.
  3. Consensus Odds & Predictive Models: Aggregating consensus sportsbook lines (DraftKings, Caesars, ESPN BET) alongside predictive metrics (FPI, BPI) powers deep statistical game evaluations.

mcp-server-espn provides a unified, hardened Model Context Protocol interface directly to ESPN's public sports data endpoints.


๐ŸŸ๏ธ System Architecture

graph LR
    Agent["AI Agent / MCP Client<br>(Antigravity, Claude, Hermes)"]
    Server["FastMCP Server<br>(stdio / Streamable HTTP)"]
    ClientHandler["Hardened ESPN AsyncClient<br>(Connection Pool & 429 Jitter Backoff)"]
    ESPN["ESPN Public REST CDN<br>(https://site.web.api.espn.com)"]

    Agent <-->|"JSON-RPC / stdio"| Server
    Server <-->|"Validated Tool Calls"| ClientHandler
    ClientHandler <-->|"HTTPS REST Mirror"| ESPN

๐Ÿ“ˆ Sports Intelligence Workflows

Workflow 1: Live In-Game Win Probability & Injury Impact

  1. Poll Active Games: Agent calls get_scoreboard(sport="football", league="nfl") to identify close games in the 2nd half.
  2. Fetch Matchup Predictor & Injuries: Call get_game_summary(sport="football", league="nfl", event_id="401547432") to retrieve ESPN's live win probability curve, consensus spread, and active injury reports.
  3. Inspect Player Boxscore Metrics: Use get_player_stats(sport="football", league="nfl", event_id="401547432") to analyze key individual performances (passing yards, completion rates, defensive stops).

Workflow 2: Pre-Game Roster & Depth Chart Matchup Preview

  1. Analyze Lineups: Call get_team_depth_chart(sport="baseball", league="mlb", team_id="10") to verify probable starters and positional depth.
  2. Review Recent Momentum: Pull get_team_schedule(sport="baseball", league="mlb", team_id="10") and get_standings(sport="baseball", league="mlb") to evaluate streaks and divisional standing.
  3. Compare Consensus Betting Lines: Query get_game_summary to evaluate consensus moneyline and over/under spreads across major sportsbooks.

๐ŸŸ๏ธ Supported Sports & Leagues Reference Matrix

The server supports canonical sport/league slug pairs and auto-normalizes popular shortcuts:

Sport SlugLeague SlugRecognized Shortcuts / AliasesCommon Display Name
footballnflnflNational Football League
footballcollege-footballcfb, ncaa-football, fbsNCAA College Football
basketballnbanbaNational Basketball Association
basketballmens-college-basketballcbb, ncaa-basketballNCAA Men's College Basketball
basketballwomens-college-basketballwbb, ncaa-womens-basketballNCAA Women's Basketball
basketballwnbawnbaWomen's National Basketball Association
baseballmlbmlbMajor League Baseball
hockeynhlnhlNational Hockey League
soccereng.1epl, premier-leagueEnglish Premier League
soccerusa.1mlsMajor League Soccer
socceruefa.championsucl, champions-leagueUEFA Champions League
socceresp.1la-ligaSpanish La Liga
soccerita.1serie-aItalian Serie A
soccerger.1bundesligaGerman Bundesliga
soccerfra.1ligue-1French Ligue 1

๐Ÿ“Š Tool Suite (10 Domain Tools)

All tools implement explicit MCP 2.0 annotations (readOnlyHint=True, idempotentHint=True):

ToolParametersDescription
get_scoreboardsport, league, date, week, season_type, group, limitLive scores, state (pre/in/post), period/clock, TV broadcasts, starting probables.
get_game_summarysport, league, event_idConsensus betting lines (DraftKings, Caesars, ESPN BET), matchup predictor, live win probability curve, season head-to-head series, momentum (last 5 games), injuries.
get_player_statssport, league, event_idBoxscore statistics for individual athletes (batting, pitching, passing, rushing, receiving, scoring).
get_standingssport, league, seasonDivision, conference, and overall league standings, win-loss records, games back, and win percentages.
get_newssport, league, limitRecent news headlines, injury designations, and breaking roster analysis.
get_rankingssport, leagueTop 25 national polls and rankings (AP Top 25, Coaches Poll, College Football Playoff).
get_team_rostersport, league, team_idFull active roster grouped by position, jersey numbers, experience, and injury status.
get_team_depth_chartsport, league, team_idPositional starter/backup hierarchy (QB1, QB2, RB1, RB2) to model injury substitution impacts.
get_team_schedulesport, league, team_id, seasonFull regular season and postseason schedule with historical game results and scores.
get_athlete_overviewsport, league, athlete_idAthlete biographical info, season/career split statistics, recent game logs, next game, and rotowire notes.

๐Ÿƒ Quickstart & Installation

1. Run Directly via uvx (Zero Install)

uvx mcp-server-espn

2. Install via pip or uv

# Using pip
pip install mcp-server-espn

# Using uv
uv add mcp-server-espn

3. Run via Docker

docker run --rm -i ghcr.io/christianclaudio/mcp-server-espn:latest

๐ŸŽ›๏ธ Engine Configuration

VariableDefaultDescription
ESPN_BASE_URLhttps://site.web.api.espn.comTarget ESPN REST CDN base URL (bypasses Akamai TLS filter)
ESPN_TIMEOUT_SECONDS30.0HTTP request timeout in seconds
ESPN_MAX_RETRIES3Maximum retry attempts with jittered exponential backoff
ESPN_MCP_READONLY0Restrict server strictly to read-only inspection tools

๐ŸŽฎ Client Integration Guides

๐Ÿงก Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "espn": {
      "command": "uvx",
      "args": ["mcp-server-espn"],
      "env": {
        "ESPN_TIMEOUT_SECONDS": "20.0"
      }
    }
  }
}

For Claude Code CLI:

claude mcp add espn -- uvx mcp-server-espn
โ™Š Google Antigravity & Gemini CLI

Add to .agents/mcp_config.json or ~/.gemini/config/mcp_config.json:

{
  "mcpServers": {
    "espn": {
      "command": "uvx",
      "args": ["mcp-server-espn"],
      "env": {
        "ESPN_TIMEOUT_SECONDS": "20.0"
      },
      "lazy": true
    }
  }
}
โšก Cursor IDE

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "espn": {
      "command": "uvx",
      "args": ["mcp-server-espn"]
    }
  }
}
๐Ÿ’ป VS Code (Cline / Roo Code / Copilot Agent Mode)

Add to cline_mcp_settings.json or .vscode/settings.json:

{
  "mcpServers": {
    "espn": {
      "command": "uvx",
      "args": ["mcp-server-espn"]
    }
  }
}
๐ŸŒ Local HTTP / Network Transport Mode

Launch the FastMCP server over modern Streamable HTTP:

python -m espn_mcp.server --transport streamable-http --host 127.0.0.1 --port 8000

Connect your local HTTP client to http://127.0.0.1:8000/sse.


๐Ÿ† Verification & Quality Gates

# Run unit test suite (100% statement coverage enforced)
pytest

# Static type safety & formatting
mypy --strict src/
ruff check --fix .
ruff format .

# Tool contract & drift audits
python scripts/check_tool_contract.py
python scripts/check_openapi_drift.py
python scripts/smoke_test.py

๐Ÿ“œ License

Distributed under the Apache-2.0 License.