国际象棋支持MCP服务器
为LLM/代理管理国际象棋游戏状态的MCP服务器。它故意不建议采取行动。相反,它提供了以下工具:
- 创建/重置游戏
- 添加移动(UCI)
- 列出所有动作
- 获取最后N个动作
- 机器友好的板JSON(方形到块的映射)
get_status() - 检查搬家是否合法
- 获取状态(FEN、轮到谁、检查、游戏结束、结果)
需求
- Python 3.13+
- uv包管理器
直接从GitHub通过uvx运行(无需本地结账)
您可以使用以下命令运行此MCP服务器而无需克隆 uvx 使用Git URL。用您的仓库信息和可选的标签/提交替换占位符。
通用MCP配置(检查器样式):
{
"servers": {
"chess-support-mcp": {
"transport": {
"type": "stdio",
"command": "uvx",
"args": [
"--from",
"git+https://github.com/danilop/chess-support-mcp.git",
"chess-support-mcp"
]
}
}
}
}克劳德桌面 mcpServers 例子:
{
"mcpServers": {
"chess-support-mcp": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/danilop/chess-support-mcp.git",
"chess-support-mcp"
]
}
}
}第一次运行可能需要更长的时间 uvx 解析并构建包;后续运行使用缓存。
配置为本地MCP服务器(JSON)
使用stdio uv run (没有硬编码路径)。通用JSON配置示例:
{
"servers": {
"chess-support-mcp": {
"transport": {
"type": "stdio",
"command": "uv",
"args": ["run", "chess-support-mcp"]
}
}
}
}使用占位符并通过以下方式设置工作目录,在不硬编码特定路径的情况下包含项目的本地路径 cwd (首选),或通过 --project:
选项A(首选:设置工作目录):
{
"servers": {
"chess-support-mcp": {
"transport": {
"type": "stdio",
"command": "uv",
"args": ["run", "chess-support-mcp"],
"cwd": ""
}
}
}
}选项B(使用uv的项目标志):
{
"servers": {
"chess-support-mcp": {
"transport": {
"type": "stdio",
"command": "uv",
"args": ["run", "--project", "", "chess-support-mcp"]
}
}
}
}Claude Desktop配置(在JSON设置中),使用 mcpServers:
{
"mcpServers": {
"chess-support-mcp": {
"command": "uv",
"args": ["run", "chess-support-mcp"],
"cwd": ""
}
}
}工具(方法)
create_or_reset_game()→ 重置到初始位置。退货status(与pieces地图),以及moves.get_status()→ 归还FEN;side_to_move(白色/黑色);fullmove_number;halfmove_clock;ply_count;last_move_uci;last_move_san;who_moved_last;检查旗帜;is_game_over;result当结束时;以及apieces机器推理地图。add_move(uci: str)→ 如果合法,请采取行动(例如。,e2e4,g1f3,推广类e7e8q).退货{ accepted, status }关于成功moves和moves_detailed.故障返回{ accepted:false, reason:"illegal"|"parse_error", expected_turn? }随着status反映了不变的立场。is_legal(uci: str)→ 检查UCI在当前位置移动的合法性。list_moves()→ 到目前为止,UCI的所有动作。list_moves_detailed()→ 所有动作ply,side,uci,san.last_moves(n: int=1)→ 最后一个N在UCI移动。last_moves_detailed(n: int=1)→ 最后N移动ply,side,uci,san.board_ascii()→ ASCII板(可选,以人为本)。正常的API返回机器友好的JSONstatus.pieces.
API设计说明
- 在UCI中总是提供移动(例如。,
e2e4,g1f3,促销活动e7e8q).服务器推断侧从位置移动;发送移动时,您永远不会指定白色/黑色。 get_status().side_to_move告诉该轮到谁了。who_moved_last,last_move_uci,以及last_move_san帮助上下文。- 详细的搬家清单单独提供
*_detailed保持基本列表简单和向后兼容的工具。
备注
- 服务器维护一个内存游戏。
- 服务器不提供提示或最佳操作。
发展
- 运行测试:
uv run pytest -q