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
k8s服务相关状态检查
MCP Fetch Server Implementation
CLI to set up and deploy MCP Servers to Cloudflare Workers in seconds. Just write TypeScript functions to...
Todoist MCP Server Extended - Enabling natural language management of todoist via Claude, MCP and todoist REST APIv2....
steam statistics
PagerDuty MCP Server for LLM Agent Integration
ChatTTS is a generative speech model for daily dialogue.
Model Context Protocol (MCP) with TikTok integration
An MCP server that provides real-time access to the latest news from Cointelegraph.





