Sleeper MCP Server

Sleeper MCP Server

Enables natural language interaction with Sleeper Fantasy Football API data, allowing queries about leagues, players, matchups, draft results, and trade analysis.

Category
访问服务器

README

Sleeper MCP Server

A Model Context Protocol (MCP) server that provides Claude Desktop with access to Sleeper Fantasy Football API data. This server enables users to query league information, player data, matchups, draft results, and perform trade analysis through natural language interactions with Claude.

Features

  • League Management: Query leagues, rosters, users, and league settings
  • Draft Analysis: Complete draft results with pick positions, keeper status, and team attribution
    • Full draft history with all rounds and picks
    • Player draft metadata showing original draft position and team
    • Keeper identification with 🔒 indicators
    • Free agent tracking for undrafted players
  • Player Information: Search players, get statistics, and trending data
  • Matchup Analysis: View current and historical matchups with real-time scoring
  • Trade Analysis: Analyze potential trade targets and evaluate roster needs
  • Intelligent Caching: Optimized API usage with TTL-based caching
  • Rate Limiting: Respects Sleeper API limits with exponential backoff

Installation

Prerequisites

  • Python 3.8 or higher
  • Claude Desktop application

Install from Source

  1. Clone the repository:
git clone <repository-url>
cd sleeper-mcp-server
  1. Install the package:
pip install -e .
  1. For development with testing and linting tools:
pip install -e ".[dev]"

Configuration

Claude Desktop MCP Configuration

Add the following configuration to your Claude Desktop MCP settings file:

Location of config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

Basic Configuration:

{
  "mcpServers": {
    "sleeper": {
      "command": "python",
      "args": ["-m", "sleeper_mcp_server"],
      "env": {
        "LOG_LEVEL": "INFO"
      },
      "disabled": false,
      "autoApprove": [
        "get_user_leagues",
        "get_league_info",
        "search_players",
        "get_trending_players"
      ]
    }
  }
}

Advanced Configuration with Custom Settings:

{
  "mcpServers": {
    "sleeper": {
      "command": "python",
      "args": ["-m", "sleeper_mcp_server"],
      "env": {
        "SLEEPER_API_BASE_URL": "https://api.sleeper.app/v1",
        "CACHE_TTL_SECONDS": "3600",
        "LOG_LEVEL": "INFO",
        "MAX_RETRIES": "3"
      },
      "disabled": false,
      "autoApprove": [
        "get_user_leagues",
        "get_league_info",
        "get_league_rosters",
        "get_league_rosters_with_draft_info",
        "get_league_users",
        "get_roster_user_mapping",
        "get_league_draft",
        "search_players",
        "get_trending_players",
        "get_player_stats",
        "get_matchups",
        "get_matchup_scores"
      ]
    }
  }
}

Environment Variables

Variable Description Default
SLEEPER_API_BASE_URL Sleeper API endpoint https://api.sleeper.app/v1
CACHE_TTL_SECONDS Default cache TTL in seconds 3600
LOG_LEVEL Logging verbosity (DEBUG, INFO, WARNING, ERROR) INFO
MAX_RETRIES Maximum API retry attempts 3

Available MCP Tools

League Tools

get_user_leagues

Get all leagues for a username in a specific season.

Parameters:

  • username (required): Sleeper username to look up
  • season (optional): Season year (default: "2024")

Example Usage:

Show me all leagues for username "john_doe" in 2024

get_league_info

Get detailed information about a specific league.

Parameters:

  • league_id (required): League ID to retrieve information for

Example Usage:

Get information for league ID "123456789"

get_league_rosters

Get all team rosters in a league.

Parameters:

  • league_id (required): League ID to retrieve rosters for

Example Usage:

Show me all rosters in league "123456789"

get_league_users

Get all users/participants in a league.

Parameters:

  • league_id (required): League ID to retrieve users for

Example Usage:

Who are the users in league "123456789"?

get_league_rosters_with_draft_info

Get all team rosters in a league with complete draft position metadata for each player.

Parameters:

  • league_id (required): League ID to retrieve rosters for

Example Usage:

Show me all rosters with draft information for league "123456789"

get_roster_user_mapping

Get a clear mapping of roster IDs to user names for a league.

Parameters:

  • league_id (required): League ID to get roster-user mapping for

Example Usage:

Show me the roster to user mapping for league "123456789"

get_league_draft

Get complete draft results and pick information for a league.

Parameters:

  • league_id (required): League ID to get draft information for

Example Usage:

Show me the draft results for league "123456789"

Player Tools

search_players

Search for players by name with optional position filtering.

Parameters:

  • query (required): Player name or partial name to search for
  • position (optional): Position filter (QB, RB, WR, TE, K, DEF)

Example Usage:

Search for players named "Josh Allen"
Find all quarterbacks with "Josh" in their name

get_trending_players

Get trending players (most added/dropped).

Parameters:

  • sport (optional): Sport type (default: "nfl")
  • add_drop (optional): Type of trend - "add" or "drop" (default: "add")

Example Usage:

Show me the most added players this week
What players are being dropped the most?

get_player_stats

Get player statistics for a specific season.

Parameters:

  • player_id (required): Player ID to get stats for
  • season (optional): Season year (default: "2024")

Example Usage:

Get stats for player ID "4046" in 2024

Matchup Tools

get_matchups

Get matchups for a specific week in a league.

Parameters:

  • league_id (required): League ID to retrieve matchups for
  • week (required): Week number (1-22)

Example Usage:

Show me week 5 matchups for league "123456789"

get_matchup_scores

Get real-time scoring information for matchups in a specific week.

Parameters:

  • league_id (required): League ID to retrieve scores for
  • week (required): Week number (1-22)

Example Usage:

What are the current scores for week 8 in league "123456789"?

Trade Tools

analyze_trade_targets

Analyze potential trade targets for a roster based on positional needs.

Parameters:

  • league_id (required): League ID to analyze
  • roster_id (required): Roster ID requesting trade analysis
  • position (optional): Position to focus analysis on (QB, RB, WR, TE, K, DEF)

Example Usage:

Analyze trade targets for roster 3 in league "123456789"
Find running back trade targets for my roster

evaluate_roster_needs

Evaluate roster strengths and weaknesses across all positions.

Parameters:

  • league_id (required): League ID to analyze
  • roster_id (required): Roster ID to evaluate

Example Usage:

Evaluate the strengths and weaknesses of roster 1 in league "123456789"

API Rate Limiting and Caching

Rate Limiting

The server implements intelligent rate limiting to respect Sleeper API guidelines:

  • Rate Limit: Follows Sleeper's documented rate limits
  • Retry Logic: Exponential backoff (1s, 2s, 4s, 8s) for rate-limited requests
  • Queue Management: Requests are queued during rate limit periods
  • User Feedback: Clear messages when rate limits are encountered

Caching Strategy

Different data types have optimized cache TTL values:

Data Type Cache TTL Reason
Player Data 1 hour Relatively static during season
League Settings 24 hours Rarely change mid-season
Draft Data 24 hours Historical data, doesn't change
Matchup Data (active) 5 minutes Real-time scoring updates
Matchup Data (completed) 1 hour Historical data is stable
Trending Players 30 minutes Updated frequently
Roster Data 15 minutes Changes with transactions
Roster Data (with draft) 15 minutes Changes with transactions

Cache Features:

  • In-memory caching for optimal performance
  • TTL-based expiration
  • Automatic cache invalidation
  • Cache hit/miss logging for monitoring

Usage Examples

Basic League Queries

# Get your leagues
"Show me all leagues for username 'myusername'"

# Get league details
"What are the settings for league ID '123456789'?"

# View rosters
"Show me all the rosters in my main league"

# View rosters with draft information
"Show me all rosters with draft info - I want to see where each player was drafted and by whom"

Player Research

# Search for players
"Find all players named 'Cooper'"

# Get trending players
"What players are being added the most this week?"

# Player statistics
"Show me Josh Allen's stats for 2024"

Matchup Analysis

# Current week matchups
"What are this week's matchups in my league?"

# Live scoring
"What are the current scores for week 8?"

# Historical data
"Show me the results from week 3"

Draft Analysis

# Complete draft results
"Show me the draft results for my league"

# Roster with draft info
"Show me all rosters with draft information - I want to see where each player was drafted"

# Keeper analysis
"Which players were kept from last year and what was their original draft cost?"

# Draft value analysis
"Show me players who are outperforming their draft position"

Trade Analysis

# Find trade partners
"Who should I target for a trade in my league? I need a running back"

# Roster evaluation
"Analyze my roster strengths and weaknesses"

# Specific position analysis
"Find quarterback trade targets for my team"

Troubleshooting

Common Issues

1. Server Won't Start

Symptoms:

  • Claude Desktop shows "Server unavailable" error
  • No response from MCP tools

Solutions:

  • Verify Python installation: python --version (should be 3.8+)
  • Check package installation: pip show sleeper-mcp-server
  • Verify Claude Desktop configuration syntax
  • Check logs for specific error messages

2. Authentication/API Errors

Symptoms:

  • "API request failed" errors
  • "Invalid league ID" messages

Solutions:

  • Verify league IDs are correct (18-character strings)
  • Check username spelling and case sensitivity
  • Ensure Sleeper API is accessible from your network
  • Try again after a few minutes (may be temporary API issues)

3. Rate Limiting Issues

Symptoms:

  • "Rate limit exceeded" messages
  • Slow response times
  • "Please wait" messages

Solutions:

  • Wait for the specified retry period
  • Reduce frequency of requests
  • Use cached data when possible
  • Check if multiple instances are running

4. Cache Issues

Symptoms:

  • Stale data being returned
  • Inconsistent results

Solutions:

  • Restart the MCP server to clear cache
  • Adjust CACHE_TTL_SECONDS environment variable
  • Check system memory availability

5. Configuration Problems

Symptoms:

  • Tools not appearing in Claude Desktop
  • Environment variables not working

Solutions:

  • Validate JSON syntax in Claude Desktop config
  • Restart Claude Desktop after configuration changes
  • Check file permissions on config file
  • Verify environment variable names and values

Debug Mode

Enable debug logging for detailed troubleshooting:

{
  "mcpServers": {
    "sleeper": {
      "command": "python",
      "args": ["-m", "sleeper_mcp_server"],
      "env": {
        "LOG_LEVEL": "DEBUG"
      }
    }
  }
}

Getting Help

  1. Check Logs: Enable DEBUG logging to see detailed error information
  2. Verify Configuration: Ensure Claude Desktop MCP configuration is correct
  3. Test API Access: Verify you can access Sleeper API directly
  4. Update Dependencies: Ensure all packages are up to date
  5. Restart Services: Try restarting both the MCP server and Claude Desktop

Performance Optimization

For Large Leagues

  • Use position filtering in player searches
  • Cache frequently accessed league data
  • Limit historical matchup queries

For Multiple Leagues

  • Batch similar requests when possible
  • Use appropriate cache TTL settings
  • Monitor rate limit usage

Development

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=sleeper_mcp_server

# Run specific test file
pytest tests/test_server.py

Code Quality

# Format code
black sleeper_mcp_server/

# Sort imports
isort sleeper_mcp_server/

# Lint code
flake8 sleeper_mcp_server/

# Type checking
mypy sleeper_mcp_server/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

For issues and questions:

  1. Check the troubleshooting section above
  2. Review existing GitHub issues
  3. Create a new issue with detailed information about your problem

Note: This MCP server is not officially affiliated with Sleeper. It's a third-party integration that uses Sleeper's public API.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选