SuperAPIAI Directory

mlb-api-mcp

github.com · AI developer platforms

Proxy to the public MLB API for player info, stats and game information.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

Purpose

MLB API MCP Server is a server based on the Model Context Protocol (MCP) that provides comprehensive access to MLB statistics and baseball data through the FastMCP interface. It serves as a bridge between AI applications and MLB data sources, enabling seamless integration of baseball statistics, game information, player data, and more into AI workflows and applications.

Main Capabilities

The server provides the following MCP tools:

  • get_mlb_standings - Current MLB standings, with support for league and season filtering
  • get_mlb_schedule - Game schedules for a specific date, range, or team
  • get_mlb_team_info - Detailed team information
  • get_mlb_player_info - Player profiles
  • get_mlb_boxscore - Complete game box score
  • get_mlb_linescore - Inning-by-inning game scoring
  • get_mlb_game_highlights - Game video highlights
  • get_mlb_game_scoring_plays - Play-by-play data with event filtering
  • get_mlb_game_pace - Game duration and pace statistics
  • get_mlb_game_lineup - Detailed lineup information for a game
  • get_multiple_mlb_player_stats - Traditional player statistics
  • get_mlb_sabermetrics - Advanced sabermetric statistics (WAR, wOBA, etc.)
  • get_mlb_roster - Team rosters, with support for multiple roster types
  • get_mlb_search_players - Search for players by name
  • get_mlb_search_teams - Search for teams by name
  • get_mlb_players - All players for a sport/season
  • get_mlb_teams - All teams for a sport/season
  • get_mlb_draft - Draft information by year
  • get_mlb_awards - Award winners
  • get_current_date - Current date
  • get_current_time - Current time

It also provides the following HTTP endpoints: / (redirects to /docs), /docs (interactive API documentation and tool list), /health/ (health check), /mcp/info (MCP server information), /tools/ (list of all available MCP tools), /mcp/ (POST, MCP protocol endpoint).

The server is compatible with AI applications that support MCP, uses a tool-based interaction model, has comprehensive endpoint descriptions, automatic API documentation generation, schema validation, and type safety, and provides complete response schema descriptions for better integration with AI.

Usage

It can be automatically installed for Claude Desktop via Smithery. Local installation or Docker installation is also available.

Local installation steps: first install uv; clone the repository; create and activate a virtual environment; install dependencies.

Docker installation: build the Docker image; run the container (the default time zone is UTC, using Python 3.12); the local time zone can be set via the TZ environment variable. The server will be available at http://localhost:8000 and the MCP server address is http://localhost:8000/mcp/,文档地址为 http://localhost:8000/docs。

Start the server: run the MCP server locally, and the server will start at http://localhost:8000/mcp/,交互式 API documentation is located at http://localhost:8000/docs。

Once the server is running, you can access http://localhost:8000/docs View the comprehensive API documentation, including available HTTP endpoints, a list of all MCP tools (/tools/), tool descriptions and parameters, an interactive testing interface, parameter descriptions, and examples.

Tech Stack

  • mcp[cli]: MCP-compatible server framework with CLI support
  • FastAPI: Web framework for HTTP transport
  • python-mlb-statsapi: Official MLB Stats API wrapper
  • uvicorn[standard]: ASGI server for running the application
  • websockets: WebSocket support
  • python-dotenv: Environment variable management
  • httpx: HTTP client for API requests

The project uses Python 3.10+ (Docker uses Python 3.12), FastMCP, uv, Hatchling, MLB Stats API, Ruff.

Use Cases

Suitable for scenarios that require integrating MLB baseball statistics into AI workflows or applications, such as obtaining team standings, game schedules, player statistics, live game data, historical records, player and team searches, sabermetric statistics such as WAR, etc., through MCP-compatible AI applications.

Limitations and Notes

  • All MLB/statistics/game/player/team and other functions are accessed through MCP tools; no RESTful HTTP endpoints are provided.
  • The project includes comprehensive test coverage, currently at 89.91% (exceeding the 80% threshold). The mock test suite protects this repository's own logic, but does not actually call the upstream MLB Stats API / pybaseball services, whose response structures are outside this repository's control. To verify that the tools still work with live data, a one-time scan can be run; the scan writes a complete JSON report to scripts/live_scan_report.json (gitignored). This is a manual verification step and is not part of the automated CI suite.
  • When adding new features, corresponding test cases must be added in tests/test_mlb_api.py, including success and error scenarios, using mocks to avoid external dependencies, ensuring coverage remains above 80%.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools