MLB Stats MCP Server
A Cloudflare Worker that serves as an MCP (Model Context Protocol) server for accessing MLB Stats API data.
Features
- Proxy requests to MLB Stats API
- Support for multiple MLB endpoints
- CORS enabled for web applications
- Error handling and validation
- No API keys required (MLB Stats API is public)
Supported Commands
getTeamInfo- Get team informationgetRoster- Get team rostergetPlayerStats- Get player statisticsgetSchedule- Get game schedulegetLiveGame- Get live game datagetStandings- Get league standingsgetGameBoxscore- Get game boxscoregetPlayerInfo- Get player informationgetSeasons- Get season informationgetVenues- Get venue information
Request Format
Send POST requests to the worker endpoint with the following JSON structure:
{
"command": "getPlayerStats",
"params": {
"pathParams": {
"playerId": "660271"
},
"queryParams": {
"stats": "season",
"group": "hitting",
"season": "2024"
}
}
}
Response Format
Successful responses return:
{
"result": {
// MLB API response data
}
}
Error responses return:
{
"error": "Error message"
}
Development
Install Wrangler CLI:
npm install -g wranglerLogin to Cloudflare:
wrangler loginDeploy the worker:
wrangler deploy
Example Usage
Get Team Information
{
"command": "getTeamInfo",
"params": {
"queryParams": {
"season": "2024",
"sportId": "1"
}
}
}
Get Player Stats
{
"command": "getPlayerStats",
"params": {
"pathParams": {
"playerId": "660271"
},
"queryParams": {
"stats": "season",
"group": "hitting",
"season": "2024"
}
}
}
Get Schedule
{
"command": "getSchedule",
"params": {
"queryParams": {
"sportId": "1",
"date": "2024-07-04"
}
}
}