MLB API
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 info
What is MLB API?
MLB API is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 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 seam...
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 info
This server falls under the Analytics category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Python MCP server that provides comprehensive access to MLB
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx mlb-apiConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use MLB API
The MLB API MCP Server is a Python-based server that provides comprehensive access to Major League Baseball statistics, game data, and historical records by wrapping the official MLB Stats API behind an MCP interface. It exposes over 20 tools covering standings, schedules, player stats, sabermetrics, box scores, game highlights, rosters, draft data, and awards — making it easy for AI assistants to answer detailed baseball questions without needing to call raw APIs. Sports analysts, fantasy baseball enthusiasts, and developers building baseball-aware applications can use it to query live and historical MLB data in natural language.
Prerequisites
- Python 3.10+ and the `uv` package manager installed (pip install uv)
- Git to clone the repository (no separate MLB API key required — the MLB Stats API is public)
- Claude Desktop, Claude Code CLI, or another MCP-compatible client
- Optional: Docker if you prefer a containerised deployment
Clone the repository
Clone the mlb-api-mcp repository to your local machine.
git clone https://github.com/guillochon/mlb-api-mcp.git
cd mlb-api-mcpCreate a virtual environment and install dependencies
Use uv to create an isolated Python environment and install all required packages.
uv venv
source .venv/bin/activate
uv pip install -e .Start the server in stdio mode
For use with Claude Desktop or Claude Code, run the server in the default stdio transport mode.
uv run python main.pyConfigure Claude Desktop
Add the mlb-api server to your claude_desktop_config.json, pointing to the absolute path of your cloned repository.
{
"mcpServers": {
"mlb-api": {
"command": "uv",
"args": ["run", "python", "main.py"],
"cwd": "/absolute/path/to/mlb-api-mcp",
"env": {
"TZ": "America/New_York"
}
}
}
}Restart Claude Desktop and test
Fully quit and relaunch Claude Desktop. Open a conversation and ask a baseball question to verify the MLB data tools are available and returning results.
MLB API Examples
Client configuration
Complete claude_desktop_config.json block for the MLB API MCP Server using uv.
{
"mcpServers": {
"mlb-api": {
"command": "uv",
"args": ["run", "python", "main.py"],
"cwd": "/absolute/path/to/mlb-api-mcp",
"env": {
"TZ": "America/New_York"
}
}
}
}Prompts to try
Example baseball questions that use the MLB API MCP Server's 20+ tools.
- "What are the current MLB standings by division?"
- "Show me the box score from last night's Yankees game."
- "What are Shohei Ohtani's career batting stats and advanced sabermetrics?"
- "Who is on the Boston Red Sox 26-man roster right now?"
- "What games are scheduled for this weekend and what time do they start?"
- "Which players won the Cy Young award in the last five years?"Troubleshooting MLB API
Server fails to start with 'uv: command not found'
Install uv via 'pip install uv' or 'curl -LsSf https://astral.sh/uv/install.sh | sh'. After installation, open a new terminal session so the PATH update takes effect.
MLB API returns empty results or 404 errors
The MLB Stats API is a public API with no key required, but it may have occasional downtime or rate limits. Verify network access and try a direct test: 'curl https://statsapi.mlb.com/api/v1/teams'. Game data is only available for scheduled or completed games within the current season.
Incorrect timestamps or schedule times are off by hours
Set the TZ environment variable in your MCP config to your local timezone (e.g. 'America/New_York', 'America/Los_Angeles'). The server defaults to UTC, which shifts displayed game times from local broadcast times.
Frequently Asked Questions about MLB API
What is MLB API?
MLB API is a Model Context Protocol (MCP) server that 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 info It connects AI assistants to external tools and data sources through a standardized interface.
How do I install MLB API?
Follow the installation instructions on the MLB API GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with MLB API?
MLB API works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is MLB API free to use?
Yes, MLB API is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.
MLB API Alternatives — Similar Analytics Servers
Looking for alternatives to MLB API? Here are other popular analytics servers you can use with Claude, Cursor, and VS Code.
OpenMetadata
★ 14.0kOpenMetadata is a unified metadata platform for data discovery, data observability, and data governance powered by a central metadata repository, in-depth column level lineage, and seamless team collaboration.
Superset
★ 10.9kAn MCP server that provides AI assistants with full access to Apache Superset instances, enabling interaction with dashboards, charts, datasets, databases, and SQL execution capabilities.
Horizon
★ 4.4k📡 Your own AI-powered news radar. Generates daily briefings in English & Chinese. | 用 AI 构建你专属的新闻雷达
MCP Server Chart
★ 4.1kEnables generation of 25+ types of charts and data visualizations using AntV, including bar charts, line charts, maps, mind maps, and specialized diagrams like fishbone and sankey charts. Supports both statistical charts and geographic visualizations
Muapi CLI
★ 997Official CLI for muapi.ai — generate images, videos & audio from the terminal. MCP server, 14 AI models, npm + pip installable.
Weather MCP Server
★ 907Weather Data Fetcher MCP server built with Node.js, MCP SDK, and Zod. Provides weather details like temperature and forecast for cities such as Noida and Delhi via a registered tool. Simplifies API integration, enabling structured responses for clien
Browse More Analytics MCP Servers
Explore all analytics servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up MLB API in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use MLB API?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.