Pybaseball MCP Server
This is a FastAPI-based MCP server that exposes MLB and Fangraphs baseball data via the pybaseballstats library.
The pybaseballstats package relies on common scientific Python libraries such as pandas and numpy.
Features
/player?name=...— Get player Statcast data by name (optionally filter by date range)/team_stats?team=...&year=...&type=batting|pitching— Get team batting or pitching stats for a given year/leaderboard?stat=...&season=...&league=...&type=batting|pitching— Get MLB leaderboard for a stat, season, and league
Setup
pip install -r requirements.txt
uvicorn main:app --reload
Example Usage
- Player stats:
GET /player?name=Mike TroutGET /player?name=Shohei Ohtani&start_date=2023-04-01&end_date=2023-10-01
- Team stats:
GET /team_stats?team=Yankees&year=2023&type=battingGET /team_stats?team=Dodgers&year=2022&type=pitching
- Leaderboards:
GET /leaderboard?stat=HR&season=2023&league=AL&type=battingGET /leaderboard?stat=ERA&season=2023&league=NL&type=pitching
API Documentation
One up and running, interactive API docs are available at http://127.0.0.1:8000/docs.
Publishing
To expose an MCP STDIO interface instead of HTTP, first start the FastAPI server and then run the wrapper:
uvicorn main:app --host 0.0.0.0 --port 8000 &
python mcp_stdio_wrapper.py
This project is ready for deployment on Smithery or any other MCP-compatible platform. It uses the pybaseballstats library and its dependencies, including pandas and numpy.
Listing available tools
The server supports the MCP tool-discovery protocol. After starting the server, you can list available tools using either HTTP or the STDIO wrapper.
HTTP
curl -X POST http://localhost:8000/tools/list
STDIO
echo '{"jsonrpc": "2.0", "method": "tools/list", "id": 1}' | python mcp_stdio_wrapper.py
Powered by pybaseballstats and FastAPI
MLB MCP
Project Details
- jweingardt12/mlb_mcp
- Last Updated: 6/4/2025
Recomended MCP Servers
A Model Context Protocol (MCP) server for encrypting/decrypting/algorithm/hash
Repository for MCP server implementation
A MCP server for Resend API. Let LLMs compose and send emails for you.
JIRA integration server for Model Context Protocol (MCP) - enables LLMs to interact with JIRA tasks and workflows
The server acts as a bridge between MCP-compatible assistants and Together AI's image generation capabilities.
An integration that allows Claude Desktop to interact with Spotify using the Model Context Protocol (MCP).
MCP Server to enable LLM's to connect to the Contentful GraphQL Endpoints
This is an implementation project of a JVM-based MCP (Model Context Protocol) server. The project aims to provide...





