侦察盲棋MCP服务器
MCP(模型上下文协议)服务器,使LLM代理能够在远程玩侦察盲棋(RBC)游戏 rbc.jhuapl.edu 对抗各种机器人。
概述
此服务器为LLM代理提供工具,以:
- 播放 未排名游戏 针对特定的机器人(随机、攻击者、鳟鱼、Oracle、StrangeFish2等)
- 等待并接受 排位赛 邀请函
- 为未排名的游戏选择颜色(白色、黑色或随机)
- 跟踪游戏状态、棋盘位置和移动历史
- 查看当前电路板的ASCII表示
- 在游戏过程中提交感官动作和动作
安装
先决条件
- Python 3.8或更高版本
- 帐户在 rbc.jhuapl.edu
设置
- 克隆或下载此存储库:
cd /Users/diept1/projects/rbc_mcp_server- 创建并激活虚拟环境:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- 安装依赖项:
pip install -r requirements.txt用法
运行MCP服务器
使用以下命令启动服务器:
python rbc_mcp_server.py服务器通过stdio进行通信,旨在与MCP兼容的客户端(如Claude Desktop或其他LLM接口)一起使用。
配置Claude桌面
将此添加到您的Claude Desktop配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"rbc": {
"command": "python",
"args": ["/Users/diept1/projects/new_rbc_mcp_server/rbc_mcp_server.py"],
"env": {}
}
}
}调整路径以匹配您的安装目录。
可用工具
1. start_unranked_game
通过发送邀请(基于rc_play_on_server.py)来启动针对特定机器人的未排名游戏。
参数:
opponent_bot(string):机器人名称(例如,“random”、“attacker”、“trout”、“oracle”、“strangefish2”)color(string):播放的颜色(“白色”、“黑色”或“随机”)
- “白色”:始终扮演白色角色 - “black”:总是扮演黑人 - “随机”:两种颜色各有50/50的概率
username(string):您在rbc.jhuapl.edu上的用户名password(string):您在rbc.jhuapl.edu上的密码
例子:
{
"opponent_bot": "trout",
"color": "white",
"username": "your_username",
"password": "your_password"
}笔记:
- 服务器通过以下方式向机器人发送邀请
server.send_invitation() - 当机器人接受邀请时,游戏会自动开始
- 使用
list_active_games查看游戏何时开始 - 游戏ID由服务器在接受邀请时生成
2. start_ranked_game
开始收听来自RBC服务器的排名游戏邀请。自动接受邀请并使用指定的颜色玩游戏。
参数:
username(string):您在rbc.jhuapl.edu上的用户名password(string):您在rbc.jhuapl.edu上的密码max_concurrent_games(整数,可选):可同时玩的排名游戏的最大数量(默认值:1)
例子:
{
"username": "your_username",
"password": "your_password",
"max_concurrent_games": 2
}笔记:
- 监听器在后台连续运行,每5秒检查一次邀请
- 收到邀请后,会自动接受并开始游戏
- 服务器将为您分配一种颜色
- 使用
list_active_games查看正在运行的游戏 - 使用
stop_ranked_listener停止接受新邀请
3. stop_ranked_listener
停止收听排名游戏邀请。
参数: 无
例子:
{}笔记:
- 正在进行的游戏将继续
- 您可以重新开始收听
start_ranked_game
4. get_game_state
获取游戏的当前状态,包括所有跟踪信息。
参数:
game_id(string):开始游戏时返回的游戏ID
5. get_board_ascii
获取包含游戏信息的当前棋盘状态的ASCII表示。
参数:
game_id(string):游戏ID
输出示例:
8 r n b q k b n r
7 p p p p p p p p
6 . . . . . . . .
5 . . . . . . . .
4 . . . . P . . .
3 . . . . . . . .
2 P P P P . P P P
1 R N B Q K B N R
a b c d e f g h
Turn: 1
Playing as: White
Opponent: trout
Last move: e2e4
Actual move: e2e46. submit_sense
提交当前回合的感应动作。在RBC中,感应显示以所选正方形为中心的3x3区域。
参数:
game_id(string):游戏IDsquare(string):方形表示感测(例如,“e4”、“d5”)或“pass”表示跳过感测
例子:
{
"game_id": "unranked_trout_20231130_143022",
"square": "e5"
}7. submit_move
提交当前回合的移动。
参数:
game_id(string):游戏IDmove(string):以UCI格式移动(例如,“e2e4”、“e7e8q”用于推广)或“pass”跳过移动
例子:
{
"game_id": "unranked_trout_20231130_143022",
"move": "e2e4"
}8. list_active_games
列出所有当前活动的游戏。
参数: 无
9. get_game_history
获取游戏的详细移动历史记录。
参数:
game_id(string):游戏ID
游戏流程
侦察盲棋的每个回合都遵循以下顺序:
- 对手移动结果如果你的对手抓住了你的一块棋子,你会得到通知
- 感知阶段:选择一个正方形来感知(显示其周围的3x3区域)
- 移动阶段:选择要采取的行动
未排名游戏会话示例
1. Start a game:
Use: start_unranked_game with opponent="trout", color="white"
2. View the board:
Use: get_board_ascii with the returned game_id
3. Submit sense:
Use: submit_sense with square="e5"
4. Submit move:
Use: submit_move with move="e2e4"
5. Repeat steps 2-4 for each turn排名游戏会话示例
1. Start listening for invitations:
Use: start_ranked_game with username="your_username", password="your_password"
2. Wait for invitations (happens automatically in background):
The server will accept invitations and start games
3. Check active games:
Use: list_active_games to see which games are running
4. Play each game:
For each game_id, use get_board_ascii, submit_sense, and submit_move
5. Stop listening (when done):
Use: stop_ranked_listenerRBC规则摘要
- 目标:抓住对手的国王(不是将死对手)
- 感知:每转一圈,感觉一个3x3的区域,以查看真实的电路板状态
- 动作:下标准棋,但非法棋可能会失败或被修改
- 无检查警告:国王可以进入检查
- 有限的信息:你只看到你感觉到的东西,并捕捉反馈
有关完整规则,请参阅: RBC规则文件
API 文档
此服务器实现了reconsches Player API。有关API的完整详细信息,请参阅: 重新核对API文档
游戏状态跟踪
服务器跟踪每个游戏:
- 当前电路板状态(基于您的感知)
- 匝数
- 所有对手移动结果
- 所有感官结果
- 您的所有移动结果
- 游戏完成时的历史记录
资源
服务器在以下位置将游戏状态作为MCP资源公开:
rbc://game/{game_id}-游戏状态的JSON表示
故障排除
导入错误
如果您看到以下内容的导入错误 mcp, chess,或 reconchess:
pip install -r requirements.txt连接问题
- 验证您的rbc.jhuapl.edu凭据
- 检查服务器是否可访问
- 确保您有活动的互联网连接
游戏超时
游戏有时间限制。如果转弯超时:
- 服务器将自动通过感应/移动
- 检查
seconds_left处于游戏状态
贡献
这是一个基本的实现。潜在改进:
- 更好的错误处理和重试逻辑
- 支持本地游戏
- 游戏回放功能
- 增强的电路板可视化
- 锦标赛支持
许可证
此项目使用reconcises库并遵循其许可条款。
