kenpom-mcp
# KenPom MCP Server ๐
[](https://github.com/dburge86/kenpom-mcp/actions/workflows/ci.yml)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/astral-sh/ruff)
Production-ready async MCP server for KenPom basketball analytics.
> **Note**: Requires a paid KenPom subscription ([kenpom.com](https://kenpom.com)) - email/password login, no API key needed.
## โจ Project Status: Production Ready
- โ
**100% Test Coverage** โ 61 tests covering all parsers and scraper
- โ
**CI/CD Pipeline** โ GitHub Actions running tests, linting, and formatting
- โ
**Code Quality** โ Pre-commit hooks with ruff enforcement
- โ
**Network Resilience** โ Retry logic with exponential backoff
- โ
**Dual Transport** โ Local (STDIO) and self-hosted HTTP/SSE support
## Features
- ๐ **Async Architecture** โ Built with httpx for non-blocking requests
- โ๏ธ **Self-Hostable** โ Optional HTTP/SSE server for remote access
- ๐พ **Smart Caching** โ KV-based caching to reduce scraping frequency
- ๐ง **Dual Transport** โ Local (STDIO) and Remote (SSE) support
- ๐ **13+ Data Tools** โ Full coverage of KenPom stats
- ๐ **Retry Logic** โ Automatic retry with backoff for network failures
- ๐งช **Well Tested** โ Comprehensive unit and integration tests
## Quick Start (Local)
```bash
cd /path/to/mcp_kenpom
cp .env.example .env # Add your credentials
uv sync
uv run kenpom-mcp
```
## MCP Client Configuration
### Local Mode
```json
{
"mcpServers": {
"kenpom": {
"command": "uv",
"args": ["--directory", "/path/to/mcp_kenpom", "run", "kenpom-mcp"]
}
}
}
```
### Remote Mode (Self-Hosted)
If you run the HTTP server on your own infrastructure:
```json
{
"mcpServers": {
"kenpom": {
"command": "npx",
"args": [
"mcp-remote",
"https://your-server-url/sse"
]
}
}
}
```
## Available Tools
| Tool | Description |
| ------------------------ | --------------------------------------------- |
| `get_ratings` | Pomeroy ratings (rank, adj efficiency, tempo) |
| `get_efficiency` | Efficiency and tempo stats |
| `get_four_factors` | eFG%, TO%, OR%, FTRate |
| `get_team_stats` | Miscellaneous team stats (offense/defense) |
| `get_player_stats` | Player leaders by metric |
| `get_height` | Height/experience data |
| `get_fanmatch` | Game predictions by date |
| `get_arenas` | Arena information |
| `get_game_attrs` | Top games by attribute (excitement, upsets) |
| `get_program_ratings` | Historical program rankings |
| `get_kpoy` | Player of the Year standings |
| `get_point_distribution` | Scoring breakdown by shot type |
| `get_hca` | Home court advantage data |
## Architecture
```
src/kenpom_mcp/
โโโ server.py # FastMCP server with 13 tools (STDIO transport)
โโโ http_server.py # Starlette server (HTTP/SSE transport)
โโโ tools.py # Unified tool registry (single source of truth)
โโโ scraper.py # Async httpx scraper with retry logic
โโโ parsers/ # HTML parsing modules
โโโ ratings.py # Pomeroy ratings
โโโ efficiency.py # Efficiency and tempo stats
โโโ stats.py # Team and player stats
โโโ fanmatch.py # Game predictions
โโโ misc.py # Arena, HCA, program ratings, KPOY
tests/
โโโ conftest.py # Pytest fixtures
โโโ fixtures/ # 14 HTML sample files
โโโ test_fixtures.py # Fixture loading tests
โโโ test_parsers.py # 33 parser unit tests
โโโ test_scraper.py # 14 scraper integration tests
```
## Development
### Setup
```bash
# Install dependencies
uv sync
# Copy environment template
cp .env.example .env # Add your KenPom credentials
# Install pre-commit hooks (optional but recommended)
uv run pre-commit install
```
### Running
```bash
# Local dev (STDIO)
uv run kenpom-mcp
# HTTP dev server (port 8000)
uv run uvicorn kenpom_mcp.http_server:app --reload
# Test with MCP inspector
npx @modelcontextprotocol/inspector uv --directory . run kenpom-mcp
```
### Testing & Quality
```bash
# Run all tests
uv run pytest tests/
# Run tests with coverage
uv run pytest tests/ --cov=kenpom_mcp
# Run specific test file
uv run pytest tests/test_parsers.py -v
# Lint and format
uv run ruff check src/ tests/
uv run ruff format src/ tests/
# Run pre-commit hooks manually
uv run pre-commit run --all-files
```
## ๐ค Contributing
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
This project uses:
- **pytest** for testing with async support
- **ruff** for linting and formatting
- **pre-commit** for automated quality checks
- **GitHub Actions** for CI/CD
All PRs must pass tests and linting checks.
## ๐ Security
For security issues, please see [SECURITY.md](SECURITY.md) for responsible disclosure guidelines.
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- **KenPom** ([kenpom.com](https://kenpom.com)) - Ken Pomeroy's advanced basketball analytics
- **FastMCP** ([github.com/jlowin/fastmcp](https://github.com/jlowin/fastmcp)) - MCP server framework
- **MCP Protocol** ([modelcontextprotocol.io](https://modelcontextprotocol.io)) - Model Context Protocol specification
## ๐ Support
- **Issues**: [GitHub Issues](https://github.com/dburge86/kenpom-mcp/issues)
- **Discussions**: [GitHub Discussions](https://github.com/dburge86/kenpom-mcp/discussions)
- **Security**: See [SECURITY.md](SECURITY.md)
---
**Made with โค๏ธ for basketball analytics enthusiasts**
TDQS
Scored across 18 tools
Most tools target a distinct resource (ratings, efficiency, four factors, player stats, arenas, schedule, etc.). However, several team-level stat tools (get_ratings, get_efficiency, get_four_factors, get_team_stats, get_scouting_report) overlap in content, though descriptions clarify their specific focuses.
All tool names follow a consistent 'get_<noun>' pattern in snake_case, making them highly predictable. Examples include get_ratings, get_schedule, get_scouting_report, and get_conference_standings.
With 18 tools, the server is comprehensive but slightly heavy for a niche stats domain. The count is justifiable given the breadth of KenPom data, but it edges into the upper range of ideal scope.
The surface covers a wide range of college basketball analytics: ratings, efficiency, player stats, schedule, conference stats, and more. Minor gaps exist (e.g., no direct box score or team roster details beyond height), but core use cases are well covered.