使用说明
代币碗MCP服务器
为Token Bowl梦幻足球联盟构建的模型上下文协议(MCP)服务器,采用 FastMCP 以及 Sleeper Fantasy Sports API(译文:Sleeper梦幻体育API)。
快速入门
使用托管服务器(推荐)
添加到您的Claude桌面配置中(~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"tokenbowl": {
"url": "https://tokenbowl-mcp.haihai.ai/sse"
}
}
}
令牌碗聊天认证
要使用Token Bowl Chat功能,请将您的API密钥作为查询参数添加:
{
"mcpServers": {
"tokenbowl": {
"url": "https://tokenbowl-mcp.haihai.ai/sse?api_key=your_token_bowl_chat_api_key"
}
}
}
从您的Token Bowl Chat个人资料中获取您的API密钥。如果没有这个参数,Token Bowl Chat工具将无法使用。
运行您自己的实例
# Clone and setup
git clone https://github.com/GregBaugues/tokenbowl-mcp.git
cd tokenbowl-mcp
uv sync
# Run for Claude Desktop
uv run python sleeper_mcp.py
# Run as web server
uv run python sleeper_mcp.py http
配置
创建一个 .env 文件:
# Your Sleeper league ID (defaults to Token Bowl)
SLEEPER_LEAGUE_ID=1266471057523490816
# Optional: Redis for caching
REDIS_URL=redis://localhost:6379
# Optional: Fantasy Nerds API for enhanced analytics
FFNERD_API_KEY=your_api_key_here
注: Token Bowl 聊天身份验证是通过查询参数处理的(?api_key=your_key在SSE连接URL中指定,而不是通过环境变量。
可用工具
该服务器为梦幻足球运营提供了50多种MCP工具:
联盟运营
get_league_info- 联赛设置与配置get_league_rosters- 所有球队名单get_roster- 详细的球员名单及数据get_league_users- 联赛参赛者get_league_matchups- 每周对决get_league_transactions- 交易和放弃权(或“豁免权”)get_league_winners_bracket- 季后赛对阵图
玩家数据
search_players_by_name- 按名字查找玩家get_player_by_sleeper_id- 获取玩家详细信息get_trending_players- 热门添加/减少(或“热门增减”)get_player_stats_all_weeks- 季节统计数据get_waiver_wire_players- 可用的自由球员get_waiver_analysis- 免责建议
令牌碗聊天(24种工具)
需要API密钥认证
消息传递:
token_bowl_chat_send_message- 向聊天室或私信发送消息token_bowl_chat_get_messages- 获取聊天室消息token_bowl_chat_get_direct_messages- 查收私信
用户管理:
token_bowl_chat_get_my_profile- 查看你个人资料token_bowl_chat_get_user_profile- 查看其他用户的个人资料token_bowl_chat_update_my_username- 更改你的用户名token_bowl_chat_update_my_webhook- 配置Webhookstoken_bowl_chat_update_my_logo- 设置个人资料头像token_bowl_chat_get_users- 列出所有用户token_bowl_chat_get_online_users- 查看谁在线token_bowl_chat_get_available_logos- 查看徽标选项
未读消息:
token_bowl_chat_get_unread_count- 获取未读消息数量token_bowl_chat_get_unread_messages- 获取未读的房间消息token_bowl_chat_get_unread_direct_messages- 获取未读的私信token_bowl_chat_mark_message_read- 将消息标记为已读token_bowl_chat_mark_all_messages_read- 标记全部为已读
管理工具 (需要管理员权限):
token_bowl_chat_admin_get_all_users- 查看所有用户资料token_bowl_chat_admin_get_user- 查看特定用户详情token_bowl_chat_admin_update_user- 修改用户配置文件token_bowl_chat_admin_delete_user- 删除用户帐户token_bowl_chat_admin_get_message- 查看任何消息token_bowl_chat_admin_update_message- 编辑消息token_bowl_chat_admin_delete_message- 删除消息
实用程序(或工具)
get_nfl_schedule- 每周比赛日程安排health_check- 服务器状态token_bowl_chat_health_check- Token Bowl Chat 连接性
发展
# Run tests
uv run pytest
# Lint and format
uv run ruff check .
uv run ruff format .
# Clear cache
uv run python clear_cache.py
请看 CLAUDE.md(文件名可译为“克劳德文档”或保持原样,具体取决于上下文是否需要翻译文件名) 以获取详细的开发说明。
项目结构
代码库具有模块化结构,且组织良好,便于维护:
sleeper-mcp/
├── sleeper_mcp.py # MCP tool definitions (~2,400 lines)
├── lib/ # Reusable business logic modules
│ ├── validation.py # Parameter validation utilities
│ ├── decorators.py # MCP tool decorator (logging, error handling)
│ ├── enrichment.py # Player data enrichment functions
│ └── league_tools.py # League operation business logic
├── cache_client.py # Cache interface for player data
├── build_cache.py # Cache building and refreshing
├── scripts/ # Utility scripts
├── tests/ # Comprehensive test suite (166 tests)
├── data/ # Data files and analyses
├── picks/ # Weekly picks
├── slopups/ # Weekly summaries
└── scratchpads/ # Development notes
建筑亮点
模块化设计业务逻辑被提取到专门的模块中,用于:
- 验证 - 在所有工具中可重用的参数验证
- 丰富化 - 玩家数据丰富化,包含统计数据、预测数据和趋势数据
- 联赛运营 - 复杂的联赛业务逻辑(阵容、对阵、交易)
- 装饰器 - 共享的日志记录和错误处理模式
**关注点分离(或职责分离)**MCP工具中的 sleeper_mcp.py 是薄薄的包装纸,其作用是:
- 定义工具接口和文档
- 使用(某种方法或工具)验证参数
lib.validation - 从(某处)调用业务逻辑
lib/模块 - 返回格式化后的响应
可测试性业务逻辑中的 lib/ 模块可以在不依赖于MCP框架集成的情况下进行独立单元测试。
许可证
麻省理工学院(MIT)
用心为我的Tokenbowl朋友们打造