NBA Player Stats MCP Server provides comprehensive NBA player statistics from basketball-reference.com, delivering detailed player information including career stats, season comparisons, advanced metrics, shooting stats, and more through the Model Context Protocol (MCP).
pip install nba-player-stats-mcp
git clone https://github.com/ziyadmir/nba-player-stats-mcp
cd nba-player-stats-mcp
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# If installed from PyPI
nba-player-stats-server
# If running from source
python src/server.py
{
"mcpServers": {
"nba-player-stats": {
"command": "python",
"args": ["path/to/basketball/src/server.py"],
"cwd": "path/to/basketball"
}
}
}
# Import the fix first
import fix_basketball_reference
from basketball_reference_scraper.players import get_stats
# Get LeBron's career per-game stats
stats = get_stats('LeBron James', stat_type='PER_GAME', ask_matches=False)
# Get specific season
stats_2023 = stats[stats['SEASON'] == '2022-23']
# Get playoff stats
playoff_stats = get_stats('LeBron James', stat_type='PER_GAME', playoffs=True, ask_matches=False)
get_player_career_stats
Get complete career statistics for an NBA player.
Parameters:
player_name
(string, required): The player's name (e.g., "LeBron James")stat_type
(string, optional): Type of stats - "PER_GAME", "TOTALS", "PER_MINUTE", "PER_POSS", "ADVANCED"get_player_season_stats
Get statistics for a specific season.
Parameters:
player_name
(string, required): The player's nameseason
(integer, required): Season year (e.g., 2023 for 2022-23)stat_type
(string, optional): Type of statsinclude_playoffs
(boolean, optional): Include playoff stats if availableget_player_advanced_stats
Get advanced statistics (PER, TS%, WS, BPM, VORP, etc.).
Parameters:
player_name
(string, required): The player's nameseason
(integer, optional): Specific season, or None for all seasonsget_player_per36_stats
Get per-36-minute statistics (pace-adjusted).
Parameters:
player_name
(string, required): The player's nameseason
(integer, optional): Specific season, or None for all seasonscompare_players
Compare statistics between two NBA players.
Parameters:
player1_name
(string, required): First player's nameplayer2_name
(string, required): Second player's namestat_type
(string, optional): Type of stats to compareseason
(integer, optional): Specific season, or None for career comparisonget_player_shooting_splits
Get detailed shooting statistics and splits.
Parameters:
player_name
(string, required): The player's nameseason
(integer, optional): Specific season, or None for career statsget_player_totals
Get total statistics (not averages).
Parameters:
player_name
(string, required): The player's nameseason
(integer, optional): Specific season, or None for career totalsget_player_playoff_stats
Get playoff statistics with regular season comparison.
Parameters:
player_name
(string, required): The player's namestat_type
(string, optional): Type of statsget_player_headshot_url
Get the basketball-reference.com headshot URL.
Parameters:
player_name
(string, required): The player's nameget_player_career_highlights
Get career highlights and achievements.
Parameters:
player_name
(string, required): The player's nameget_player_game_log
Get game-by-game statistics for a specific season.
Parameters:
player_name
(string, required): The player's nameseason
(integer, required): Season year (e.g., 2024)playoffs
(boolean, optional): Whether to get playoff game logsdate_from
(string, optional): Start date in 'YYYY-MM-DD' formatdate_to
(string, optional): End date in 'YYYY-MM-DD' formatget_player_specific_stat
Get a specific statistic for a player in a given season.
Parameters:
player_name
(string, required): The player's namestat_name
(string, required): The specific stat (e.g., "PTS", "3P%", "PER")season
(integer, required): Season yearget_player_vs_team_stats
Get career statistics against a specific team.
Parameters:
player_name
(string, required): The player's nameteam_abbreviation
(string, required): Team code (e.g., "GSW", "LAL")stat_type
(string, optional): Type of statsget_player_awards_voting
Get awards and voting history.
Parameters:
player_name
(string, required): The player's nameaward_type
(string, optional): "MVP", "DPOY", "ROY", "SMOY", "MIP"get_player_monthly_splits
Get statistics broken down by month.
Parameters:
player_name
(string, required): The player's nameseason
(integer, required): Season yearmonth
(string, optional): Specific month or None for allget_player_clutch_stats
Get performance in clutch situations.
Parameters:
player_name
(string, required): The player's nameseason
(integer, optional): Specific season or None for careerget_player_playoffs_by_year
Get detailed playoff statistics for a specific year.
Parameters:
player_name
(string, required): The player's nameseason
(integer, required): Season yearget_player_career_trends
Analyze career trends and progression.
Parameters:
player_name
(string, required): The player's namestat_name
(string, optional): The stat to analyze trends for (default: "PTS")window_size
(integer, optional): Years for moving average (default: 3)get_player_game_highs
Get career high games and milestone performances.
Parameters:
player_name
(string, required): The player's namethreshold_points
(integer, optional): Point threshold for high-scoring games (default: 40)include_triple_doubles
(boolean, optional): Whether to estimate triple-double gamesget_player_situational_splits
Get situational performance splits.
Parameters:
player_name
(string, required): The player's nameseason
(integer, optional): Specific season or None for careersplit_type
(string, optional): "home_away", "rest_days", "monthly", "win_loss"get_player_quarter_stats
Get quarter-by-quarter performance.
Parameters:
player_name
(string, required): The player's nameseason
(integer, optional): Specific season or None for careerquarter
(string, optional): "1st", "2nd", "3rd", "4th", "OT", or "all"get_player_milestone_tracker
Track progress toward career milestones with projections.
Parameters:
player_name
(string, required): The player's namemilestone_type
(string, optional): "points", "assists", "rebounds", "3pm", "games"get_player_rankings
Get all-time rankings for a player in various categories.
Parameters:
player_name
(string, required): The player's namecategory
(string, optional): "points", "assists", "rebounds", "3pm", "steals", "blocks"To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "nba-player-stats" '{"command":"python","args":["path/to/basketball/src/server.py"],"cwd":"path/to/basketball"}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"nba-player-stats": {
"command": "python",
"args": [
"path/to/basketball/src/server.py"
],
"cwd": "path/to/basketball"
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"nba-player-stats": {
"command": "python",
"args": [
"path/to/basketball/src/server.py"
],
"cwd": "path/to/basketball"
}
}
}
3. Restart Claude Desktop for the changes to take effect