MCP象棋服务器
_通过 BINATI A分析_
提供Chess.com玩家数据集成的模型上下文协议(MCP)服务器。该服务器允许像Claude这样的人工智能助手从chess.com的公共API获取实时国际象棋选手档案和统计数据。
截图
UI Screenshot 1 UI Screenshot 2 UI Screenshot 3 UI Screenshot 4 UI Screenshot 5
特性
- 玩家档案查找:获取任何Chess.com玩家的详细个人资料信息
- 球员统计:检索包括评级、游戏计数和性能指标在内的综合统计数据
- 错误处理:为API请求提供强大的错误处理,并提供详细的错误消息
- 类型安全:完整的类型提示,以获得更好的代码质量和IDE支持
安装
先决条件
- Python>=3.13
- uv(推荐)或pip用于包装管理
设置
- 克隆存储库:
git clone https://github.com/CyprianFusi/mcp-chess-server.git
cd mcp_chess_server- 使用uv安装依赖项:
uv sync或者使用pip:
pip install -e .用法
运行服务器
可以使用安装的命令直接运行服务器:
chess或者通过Python模块:
python -m chess.server与Claude Desktop集成
要将此MCP服务器与Claude Desktop一起使用,请将以下配置添加到您的Claude Desktop配置文件中:
适用于MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json 对于Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"chess": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp_chess_server",
"run",
"chess.py"
]
}
}
}替换 /path/to/mcp_chess_server 带有安装目录的实际路径。
或者,您也可以通过更新claude桌面直接从Github集成它,如下所示:
"chess": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/CyprianFusi/mcp-chess-server.git",
"chess.py"
]
}如果这是您的第一台MCP服务器,请使用以下内容:
{
"mcpServers": {
"chess": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/CyprianFusi/mcp-chess-server.git",
"chess.py"
]
}
}
}可用工具
1. get_chess_player_profile
检索Chess.com玩家的公开资料。
参数:
player_name(str):Chess.com用户名
退货:
- 玩家资料信息包括:
- 用户名 - 玩家ID - 统一资源定位符 - 姓名(如公开) - 国家 - 位置 - 加入日期 - 上次在线时间戳 - 关注者计数 - 还有更多。..
例子:
Get the profile for player "hikaru"2. get_chess_player_stats
检索Chess.com玩家的全面统计数据。
参数:
player_name(str):Chess.com用户名
退货:
- 玩家统计数据包括:
- 所有游戏类型(闪电战、子弹、快速、每日等)的当前评级 - 最佳评级 - 赢/输/平局记录 - 战术评级 - 课程统计 - 拼图冲刺得分
例子:
Get the stats for player "magnuscarlsen"项目结构
mcp_chess_server/
├── src/
│ └── chess/
│ ├── __init__.py # Package initialization
│ ├── server.py # MCP server implementation
│ └── chess_api.py # Chess.com API client
├── assets/ # Screenshots and images
├── main.py # Entry point (legacy)
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock file
└── README.md # This file依赖项
- mcp\[cli\] (>=1.22.0):模型上下文协议框架
- 请求: (>=2.32.5):API调用的HTTP库
- 开放人工智能 (>=2.8.1):OpenAI Python客户端
api参考
此服务器使用Chess.com Public API(https://api.chess.com/pub).不需要API密钥,因为它使用公共可用的终结点。
错误处理
服务器包括全面的错误处理:
- 网络超时(请求超时10秒)
- HTTP错误响应
- 玩家名称无效
- API停机时间
所有错误都会通过描述性消息正确传播,以帮助诊断问题。
发展
运行测试
# Install development dependencies
uv sync --dev
# Run tests (when available)
pytest代码质量
代码库遵循Python最佳实践:
- 为所有函数键入提示
- 全面的文档字符串
- PEP 8风格指南
- 所有API调用的错误处理
贡献
欢迎投稿!请随时提交拉取请求。
许可证
该项目是开源的,可在 MIT许可证.
致谢
- 内置于 FastMCP
- 用途 Chess.com公共API
支持
对于问题、疑问或贡献,请在GitHub存储库上打开问题。
