使用自然语言与国际象棋平台Lichess进行交互。通过与Claude Desktop结合使用,可以玩游戏、分析位置以及管理你的国际象棋活动。
使用了模型上下文协议构建。
<a href="https://glama.ai/mcp/servers/x7iuw37s1v"> <img width="380" height="200" src="https://gips3.baidu.com/it/u=3248717467,2851326416&fm=3081&app=31&f=PNG?w=760&h=400" alt="Lichess MCP 服务器" /> </a>该服务器支持:
Lichess API令牌可以通过以下两种方式设置:
环境变量:在项目根目录下的.env文件中添加或直接设置:
LICHESS_TOKEN=your-lichess-api-token
在运行时使用set_token工具:
set_token({
token: "your-lichess-api-token"
});
令牌可以在 https://lichess.org/account/oauth/token 处生成。
// 设置你的Lichess API令牌
set_token({
token: "your-lichess-api-token"
});
// 获取你的Lichess个人资料
get_my_profile();
// 获取其他用户的个人资料
get_user_profile({
username: "player_name",
trophies: true // 包括奖杯,可选
});
// 对另一个玩家发起挑战
create_challenge({
username: "opponent_username",
timeControl: "10+0", // 10分钟,无加秒
color: "random" // 或 "white", "black"
});
// 在游戏中走一步
make_move({
gameId: "abcd1234",
move: "e2e4",
offeringDraw: false
});
// 获取正在进行的游戏
get_ongoing_games({
nb: 10 // 要获取的游戏数量
});
// 导出游戏为PGN格式
export_game({
gameId: "abcd1234",
clocks: true,
evals: true
});
// 获取某个位置的云评估
get_cloud_eval({
fen: "rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2"
});
// 列出现有比赛
get_arena_tournaments();
// 加入比赛
join_arena({
tournamentId: "abc123"
});
// 创建新比赛
create_arena({
name: "我的比赛",
clockTime: 3,
clockIncrement: 2,
minutes: 45
});
Lichess API接受以下格式的移动:
e2e4,g8f6)e4,Nf6)——仅适用于某些端点福斯-爱德华兹符号(FEN)用于表示国际象棋位置:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
这表示:
服务器提供详细的错误消息,包括:
要通过 Smithery 自动安装 Lichess 集成到 Claude Desktop:
npx -y @smithery/cli install @karayaman/lichess-mcp --client claude
克隆仓库:
git clone https://github.com/karayaman/lichess-mcp.git
cd lichess-mcp
安装依赖项:
npm install
配置环境变量:
在根目录创建一个 .env 文件:
LICHESS_TOKEN=your-lichess-api-token
构建项目:
npm run build
全局安装包(推荐用于 Claude Desktop 集成):
npm install -g
启动服务器(用于独立使用):
npm start
要将此 MCP 服务器与 Claude Desktop 结合使用:
查找你的 Claude Desktop 配置文件:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json将 Lichess MCP 服务器添加到配置中:
{
"mcpServers": {
"lichess": {
"command": "lichess-mcp",
"env": {
"LICHESS_TOKEN": "your-lichess-api-token",
"DEBUG": "*"
}
}
}
}
注意:将 your-lichess-api-token 替换为你实际的 Lichess API 令牌。DEBUG 环境变量是可选的,但有助于故障排除。
(可选)你可以添加其他 MCP 服务器:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Desktop",
"/Users/username/Downloads"
]
},
"lichess": {
"command": "lichess-mcp",
"env": {
"LICHESS_TOKEN": "your-lichess-api-token"
}
}
}
}
重新启动 Claude Desktop 以应用更改。
通过询问 Claude 关于你的 Lichess 账户来测试集成:
如果你遇到 MCP 服务器连接的问题:
npm install -glichess-mcp 命令是否在你的 PATH 中可用(which lichess-mcp)mcpServers 格式而不是 mcp_servers)