Skip to main content
Glama

mlb-api-mcp

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 filters
  • GET /mlb/schedule - Game schedules for specific dates, ranges, or teams
  • GET /mlb/team/{team_id} - Detailed team information
  • GET /mlb/player/{player_id} - Player biographical information
  • GET /mlb/boxscore - Complete game boxscores
  • GET /mlb/linescore - Inning-by-inning game scores
  • GET /mlb/game_highlights - Video highlights for games
  • 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 games
  • GET /mlb/player_stats - Traditional player statistics
  • GET /mlb/sabermetrics - Advanced sabermetric statistics (WAR, wOBA, etc.)
  • GET /mlb/roster - Team rosters with various roster types
  • GET /mlb/search_players - Search players by name
  • GET /mlb/search_teams - Search teams by name
  • GET /mlb/players - All players for a sport/season
  • GET /mlb/teams - All teams for a sport/season
  • GET /mlb/draft/{year} - Draft information by year
  • GET /mlb/awards/{award_id} - Award recipients
Generic Endpoints
  • GET /current_date - Current date
  • GET /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

  1. Clone the repository:
git clone https://github.com/guillochon/mlb-api-mcp.git cd mlb-api-mcp
  1. Install dependencies:
pip install -e .

Option 2: Docker Installation

  1. Clone the repository:
git clone https://github.com/guillochon/mlb-api-mcp.git cd mlb-api-mcp
  1. Build the Docker image:
docker build -t mlb-api-mcp .
  1. 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.

-
security - not tested
A
license - permissive license
-
quality - not tested

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.

  1. Overview
    1. Features
      1. MLB Data Access
      2. API Endpoints
      3. MCP Integration
    2. Installation
      1. Option 1: Local Installation
      2. Option 2: Docker Installation
    3. Usage
      1. Starting the Server
      2. MCP Client Integration
    4. API Documentation
      1. Dependencies
        1. Development
          1. Contributing
            1. License

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                This 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
              • A
                security
                A
                license
                A
                quality
                An MCP Server implementation that integrates the Balldontlie API, to provide information about players, teams and games for the NBA, NFL and MLB.
                Last updated -
                4
                22
                4
                JavaScript
                MIT License
              • -
                security
                F
                license
                -
                quality
                A 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 -
                1
                Python
              • -
                security
                F
                license
                -
                quality
                An 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

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/guillochon/mlb-api-mcp'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server