Uses FastAPI as the web framework for building the API, providing automatic API documentation generation, schema validation, and type safety for the MLB data endpoints.
Repository is hosted on GitHub, allowing for version control, collaboration, and distribution of the MCP server code.
Provides comprehensive access to MLB statistics and baseball data, including team standings, game schedules, player statistics, team information, live game data, game highlights, player and team search, draft information, and advanced sabermetrics.
Built with Python 3.10+, utilizing Python's capabilities for data processing and API integration with the MLB Stats API.
MLB API MCP Server
A Model Context Protocol (MCP) server that provides comprehensive access to MLB statistics and baseball data through a FastAPI-based interface.
Overview
This MCP server acts 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.
Features
MLB Data Access
- Current standings for all MLB teams with flexible filtering by league, season, and date
- Game schedules and results with date range support
- Player statistics including traditional and sabermetric stats (WAR, wOBA, wRC+)
- Team information and rosters with various roster types
- Live game data including boxscores, linescores, and play-by-play
- Game highlights and scoring plays
- Player and team search functionality
- Draft information and award recipients
- Game pace statistics and lineup information
API Endpoints
MLB Endpoints (/mlb/
)
GET /mlb/standings
- Current MLB standings with league and season filtersGET /mlb/schedule
- Game schedules for specific dates, ranges, or teamsGET /mlb/team/{team_id}
- Detailed team informationGET /mlb/player/{player_id}
- Player biographical informationGET /mlb/boxscore
- Complete game boxscoresGET /mlb/linescore
- Inning-by-inning game scoresGET /mlb/game_highlights
- Video highlights for gamesGET /mlb/game_scoring_plays
- Play-by-play data with event filteringGET /mlb/game_pace
- Game duration and pace statisticsGET /mlb/game_lineup
- Detailed lineup information for gamesGET /mlb/player_stats
- Traditional player statisticsGET /mlb/sabermetrics
- Advanced sabermetric statistics (WAR, wOBA, etc.)GET /mlb/roster
- Team rosters with various roster typesGET /mlb/search_players
- Search players by nameGET /mlb/search_teams
- Search teams by nameGET /mlb/players
- All players for a sport/seasonGET /mlb/teams
- All teams for a sport/seasonGET /mlb/draft/{year}
- Draft information by yearGET /mlb/awards/{award_id}
- Award recipients
Generic Endpoints
GET /current_date
- Current dateGET /current_time
- Current time
MCP Integration
- Compatible with MCP-enabled AI applications
- Tool-based interaction model with comprehensive endpoint descriptions
- Automatic API documentation generation
- Schema validation and type safety
- Full response schema descriptions for better AI integration
Installation
Option 1: Local Installation
- Clone the repository:
- Install dependencies:
Option 2: Docker Installation
- Clone the repository:
- Build the Docker image:
- Run the container:
The server will be available at http://localhost:8000
.
Docker Options
You can also run the container with additional options:
Usage
Starting the Server
Run the MCP server locally:
The server will start on http://localhost:8000
with interactive API documentation available at http://localhost:8000/docs
.
MCP Client Integration
This server can be integrated into any MCP-compatible application. The server provides tools for:
- Retrieving team standings and schedules
- Getting comprehensive player and team statistics
- Accessing live game data and historical records
- Searching for players and teams
- Fetching sabermetric statistics like WAR
- And much more...
API Documentation
Once the server is running, visit http://localhost:8000/docs
for comprehensive API documentation including:
- Available endpoints with detailed descriptions
- Request/response schemas
- Interactive testing interface
- Parameter descriptions and examples
Dependencies
- FastAPI: Modern web framework for building APIs
- fastapi-mcp: MCP integration for FastAPI
- python-mlb-statsapi: Official MLB Statistics API wrapper
Development
This project uses:
- Python 3.10+
- FastAPI for the web framework
- Hatchling for build management
- MLB Stats API for comprehensive baseball data access
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
This project is open source. Please check the license file for details.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
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 information, player data, and more.
Related MCP Servers
- -securityFlicense-qualityThis is an MCP server that facilitates building tools for interacting with various APIs and workflows, supporting Python-based development with potential for customizable prompts and user configurations.Last updated -Python
- AsecurityAlicenseAqualityAn MCP Server implementation that integrates the Balldontlie API, to provide information about players, teams and games for the NBA, NFL and MLB.Last updated -4224JavaScriptMIT License
- -securityFlicense-qualityA Python implementation of the MCP server that enables AI models to connect with external tools and data sources through a standardized protocol, supporting tool invocation and resource access via JSON-RPC.Last updated -1Python
- -securityFlicense-qualityAn MCP server that enables interaction with MLB (Major League Baseball) v3 projections through the SportsData.io API, allowing access to baseball statistics and projections through natural language.Last updated -Python