Baseball MCP Documentation

Quick Start

The Baseball MCP Server provides comprehensive MLB data through the Model Context Protocol (MCP). Access it via HTTPS/SSE through compatible clients like Claude Desktop or Gemini CLI.

MCP Server Configuration

Configure the Baseball MCP server in your MCP client with your API key:

{
  "mcpServers": {
    "baseball-mcp": {
      "command": "npx",
      "args": ["@baseballmcp/server"],
      "env": {
        "BASEBALL_MCP_API_KEY": "your_api_key_here"
      }
    }
  }
}

Available MCP Tools

Teams

get_teams

Get all MLB teams or a specific team by ID.

Tool: get_teams
Parameters:
  • team_id (integer, optional) - Team ID to get specific team info
Example Usage:
// Ask Claude or Gemini CLI:
"Get all MLB teams"

// Or for a specific team:
"Get information about the New York Yankees (team ID 147)"

// The MCP server will call get_teams tool with:
{
  "team_id": 147  // optional
}

Get Team Roster

Get roster for a specific team.

GET /api/teams/roster
Parameters:
  • team_id (integer, required) - Team ID
  • season (integer, optional) - Season year
const roster = await fetch('https://api.baseballmcp.com/v1/teams/roster?team_id=147', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});

Get Bullpen Usage

Get recent bullpen usage for a team (last 7 days).

GET /api/teams/bullpen
Parameters:
  • team_id (integer, required) - MLB team ID
  • days (integer, optional) - Number of days to look back (default: 7)

Players

Search Players

Search for players by name.

GET /api/players/search
Parameters:
  • query (string, required) - Player name to search for
const players = await fetch('https://api.baseballmcp.com/v1/players/search?query=Mike Trout', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});

Get Player Stats

Get statistics for a specific player.

GET /api/players/stats
Parameters:
  • player_id (integer, required) - Player ID
  • group (string, optional) - Stats group: hitting, pitching, or fielding
  • type (string, optional) - Stats type: season or career
// Get Mike Trout's hitting stats
const stats = await fetch('https://api.baseballmcp.com/v1/players/stats?player_id=545361&group=hitting&type=season', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});

Get Player Info

Get detailed information for one or more players.

GET /api/players/info
Parameters:
  • player_ids (integer or array, required) - Player ID(s)

Games & Schedule

Get Schedule

Get MLB game schedule.

GET /api/schedule
Parameters:
  • date (string, optional) - Date for schedule (YYYY-MM-DD)
  • start_date (string, optional) - Start date for range
  • end_date (string, optional) - End date for range
  • team_id (integer, optional) - Team ID to filter by
// Get today's games
const schedule = await fetch('https://api.baseballmcp.com/v1/schedule', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});

// Get Yankees games for a date range
const yankeeGames = await fetch('https://api.baseballmcp.com/v1/schedule?start_date=2024-07-01&end_date=2024-07-31&team_id=147', {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});

Get Game Boxscore

Get boxscore for a specific game.

GET /api/games/boxscore
Parameters:
  • game_id (integer, required) - Game ID

Head-to-Head Stats

Get head-to-head series statistics between two MLB teams.

GET /api/games/h2h
Parameters:
  • team1_id (integer, required) - First team ID
  • team2_id (integer, required) - Second team ID
  • season (integer, optional) - Specific season
  • start_date (string, optional) - Start date (YYYY-MM-DD)
  • end_date (string, optional) - End date (YYYY-MM-DD)

Advanced Statistics

Batting Statistics

Get comprehensive batting statistics for players or teams.

GET /api/stats/batting
Parameters:
  • player_ids (array, optional) - List of player IDs
  • team_ids (array, optional) - List of team IDs
  • season (integer, optional) - Season year
  • stat_type (string, optional) - season, career, monthly, last7, last15, last30
  • include_advanced (boolean, optional) - Include OPS+, wRC+, WAR
  • sort_by (string, optional) - avg, hr, rbi, ops, war, hits, runs

Statcast Data

Get Statcast metrics from Baseball Savant.

GET /api/stats/statcast
Parameters:
  • player_ids (integer or array, required) - Player ID(s)
  • season (integer, optional) - Season year
  • metric_type (string, optional) - exit_velocity, barrel_rate, hard_hit_rate, whiff_rate, chase_rate, all
// Get Statcast data for multiple players
const statcast = await fetch('https://api.baseballmcp.com/v1/stats/statcast', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    player_ids: [545361, 592450], // Mike Trout, Mookie Betts
    metric_type: 'all'
  })
});

Standings

Get Standings

Get current MLB standings with comprehensive team records.

GET /api/standings
Parameters:
  • league_id (integer, optional) - League ID (103=AL, 104=NL)
  • season (integer, optional) - Season year
  • division (string, optional) - Filter by division (e.g., 'AL East')

Weather Data

Stadium Weather

Get current weather conditions for MLB stadiums.

GET /api/weather
Parameters:
  • venue_id (integer, required) - MLB venue ID
  • game_date (string, optional) - Game date (YYYY-MM-DD)

Rate Limits

Plan Limits

  • Starter Plan: 1,000 API calls per month
  • Pro Plan: 10,000 API calls per month
  • Enterprise Plan: Unlimited API calls

Rate limits are enforced on a monthly basis. Exceeding your limit will result in API requests being rejected with a 429 status code.

Error Handling

The API uses conventional HTTP response codes to indicate the success or failure of requests.

HTTP Status Codes

  • 200 - Success
  • 400 - Bad Request - Invalid parameters
  • 401 - Unauthorized - Invalid API key
  • 403 - Forbidden - API key lacks permissions
  • 404 - Not Found - Resource not found
  • 429 - Too Many Requests - Rate limit exceeded
  • 500 - Internal Server Error

Support

Need help? Our support team is here to assist you.

Email Support

Get help via email

[email protected]

Documentation

Comprehensive guides and tutorials

View Documentation