mlb-api-mcp
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.
README
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:
git clone https://github.com/guillochon/mlb-api-mcp.git
cd mlb-api-mcp
- Install dependencies:
pip install -e .
Option 2: Docker Installation
- Clone the repository:
git clone https://github.com/guillochon/mlb-api-mcp.git
cd mlb-api-mcp
- Build the Docker image:
docker build -t mlb-api-mcp .
- Run the container:
docker run -p 8000:8000 mlb-api-mcp
The server will be available at http://localhost:8000.
Docker Options
You can also run the container with additional options:
# Run in detached mode
docker run -d -p 8000:8000 --name mlb-api-server mlb-api-mcp
# Run with custom port mapping
docker run -p 3000:8000 mlb-api-mcp
# View logs
docker logs mlb-api-server
# Stop the container
docker stop mlb-api-server
# Remove the container
docker rm mlb-api-server
Usage
Starting the Server
Run the MCP server locally:
python main.py
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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。