davorpavlov/nba-stats-predictor-mcp
If you are the rightful owner of nba-stats-predictor-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
An MCP-powered tool for the NBA stats predictor app that generates player performance forecasts using real-time data analysis and advanced statistical modeling.
MCP Server for NBA Stats Predictor Application
An MCP-powered tool for the NBA stats predictor app that generates player performance forecasts using real-time data analysis and advanced statistical modeling.
Features
- 🏀 Real-time NBA Stats: Fetches latest player and team data from NBA API
- 🤖 ML Predictions: Uses XGBoost for accurate player performance predictions
- 🚀 FastAPI Backend: High-performance REST API for predictions
- 🔧 MCP Integration: Seamlessly works with Claude Desktop
- 🐳 Docker Support: Easy deployment with Docker and Docker Compose
- ☁️ Coolify Ready: Deploy to Coolify with one click
Deployment Options
🚀 Quick Deploy with Coolify (Recommended)
Deploy the API to Coolify for production use. See for detailed instructions.
Quick Start:
- Fork this repository
- Create new application in Coolify
- Select branch:
claude/coolify-deployment-setup-011CUzUkEmzLLA9UDBDfbVhS(ormainafter merge) - Dockerfile is at root level - Coolify will auto-detect it
- Deploy!
🐳 Docker Compose (Local Development)
# Clone and start
git clone <repository-url>
cd nba-stats-predictor-mcp
docker-compose up -d
# API will be available at http://localhost:8000
💻 Local Development Setup
Prerequisites
- Python 3.8+
- pip
- Claude Desktop
Step-by-Step Setup
-
Clone this repository onto your local device
-
Navigate to the project directory:
cd nba-stats-predictor-application -
Create a virtual environment:
python3 -m venv venv -
Activate the virtual environment:
source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt -
Download the necessary data:
python3 data_pipeline/download_data.py -
Train the prediction model:
python3 models/train_model.py -
Start the FastAPI server:
uvicorn api.fastapi_server:app --reload -
Open a new terminal
-
Return to the project directory
-
Install UV package manager:
curl -LsSf https://astral.sh/uv/install.sh | sh -
Restart the terminal in this directory
-
Run the MCP server:
uv run mcp_main.py -
Open another new terminal
-
Configure Claude Desktop:
code ~/Library/Application\ Support/Claude/claude_desktop_config.jsonNote: If the file doesn't exist, create it.
-
Add the following configuration to
claude_desktop_config.json:{ "mcpServers": { "NBA-stats-predictor": { "command": "/PATH/TO/PROJECT/DIRECTORY/.venv/bin/uv", "args": [ "--directory", "/PATH/TO/PROJECT/DIRECTORY/", "run", "mcp_main.py" ] } } }Remember to replace
/PATH/TO/PROJECT/DIRECTORY/with the actual path to your project. -
You should now be able to use this MCP tool on Claude Desktop.
Configuration
MCP Server Configuration
The MCP server can connect to either a local or remote API:
Local API (default):
{
"mcpServers": {
"NBA-stats-predictor": {
"command": "/PATH/TO/PROJECT/.venv/bin/uv",
"args": ["--directory", "/PATH/TO/PROJECT/", "run", "mcp_main.py"]
}
}
}
Remote API (Coolify deployment):
{
"mcpServers": {
"NBA-stats-predictor": {
"command": "/PATH/TO/PROJECT/.venv/bin/uv",
"args": ["--directory", "/PATH/TO/PROJECT/", "run", "mcp_main.py"],
"env": {
"NBA_API_URL": "https://your-coolify-domain.com"
}
}
}
}
Environment Variables
Create a .env file in the project root (copy from .env.example):
# API URL for the MCP server to connect to
NBA_API_URL=http://localhost:8000 # or your Coolify URL
# For running the FastAPI server
PORT=8000
Usage
Once configured, you can use the NBA stats predictor tool in Claude Desktop:
Examples:
- "Predict LeBron James stats against the Boston Celtics at home"
- "What will Stephen Curry's performance be like against the Lakers away?"
- "Show me predicted stats for Giannis Antetokounmpo vs the Warriors at home"
API Endpoints
The FastAPI server provides the following endpoints:
GET /- API information and available endpointsGET /health- Health check endpointGET /docs- Interactive API documentation (Swagger UI)POST /predict- Get player stat predictions
Example API Request:
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{
"player_name": "LeBron James",
"opponent_team": "BOS",
"home_or_away": "Home"
}'
Architecture
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Claude Desktop │ ───> │ MCP Server │ ───> │ FastAPI Server │
│ │ │ (mcp_main.py)│ │ (Port 8000) │
└─────────────────┘ └──────────────┘ └─────────────────┘
│
v
┌─────────────────┐
│ SQLite DB + │
│ ML Model │
└─────────────────┘
Troubleshooting
Local Development
- Make sure all paths in the configuration are correct
- Ensure the virtual environment is activated before running commands
- Check that all dependencies are properly installed
- Verify that the FastAPI server is running before using the MCP tool
Docker/Coolify Deployment
- Check application logs in Coolify dashboard
- Verify environment variables are correctly set
- Ensure PORT is set to 8000
- If database/model is missing, run initialization scripts manually
- For SSL issues, verify domain configuration in Coolify
MCP Connection Issues
- Restart Claude Desktop after configuration changes
- Check that NBA_API_URL is correctly set
- Verify the API is accessible from your machine
- Look for errors in Claude Desktop logs
Development
Project Structure
nba-stats-predictor-mcp/
├── mcp_main.py # MCP server implementation
├── pyproject.toml # MCP dependencies
├── docker-compose.yml # Local development setup
├── .env.example # Environment configuration template
├── COOLIFY_DEPLOYMENT.md # Coolify deployment guide
└── nba-stats-predictor-application/ # FastAPI application (submodule)
├── Dockerfile # Container configuration
├── api/
│ └── fastapi_server.py # FastAPI endpoints
├── models/
│ ├── predict.py # Prediction logic
│ └── train_model.py # Model training
└── data_pipeline/
├── download_data.py # NBA data fetching
└── database.py # Database management
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally with Docker Compose
- Submit a pull request
License
[Add your license here]
Credits
Built with:
