Lichess MCP

by karayaman
Verified

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Provides support for loading environment variables from a .env file for configuring the Lichess API token.

  • Enables comprehensive interaction with the Lichess chess platform, including account management, playing chess games, creating challenges, analyzing positions, managing tournaments, joining teams, and connecting with other players.

Lichess MCP

使用自然语言与 Lichess 对话,即可与国际象棋平台互动。配合 Claude Desktop 使用,您可以对局、分析棋局并管理您的国际象棋活动。

使用模型上下文协议构建。

该服务器支持:

  • 管理您的 Lichess 帐户
  • 下棋游戏和挑战
  • 分析位置和比赛
  • 参加比赛和团队
  • 与其他玩家互动

配置

Lichess API 令牌可以通过两种方式设置:

  1. 环境变量:将其添加到项目根目录中的.env文件中或直接设置:
    LICHESS_TOKEN=your-lichess-api-token
  2. 在运行时使用set_token工具:
    set_token({ token: "your-lichess-api-token" });

可以在https://lichess.org/account/oauth/token生成令牌

可用工具

1. 账户管理

// Set your Lichess API token set_token({ token: "your-lichess-api-token" }); // Get your Lichess profile get_my_profile(); // Get another user's profile get_user_profile({ username: "player_name", trophies: true // include trophies, optional });

2.游戏玩法

// Create a challenge against another player create_challenge({ username: "opponent_username", timeControl: "10+0", // 10 minutes, no increment color: "random" // or "white", "black" }); // Make a move in a game make_move({ gameId: "abcd1234", move: "e2e4", offeringDraw: false }); // Get your ongoing games get_ongoing_games({ nb: 10 // number of games to fetch });

3. 游戏分析

// Export a game in PGN format export_game({ gameId: "abcd1234", clocks: true, evals: true }); // Get cloud evaluation for a position get_cloud_eval({ fen: "rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2" });

4. 锦标赛

// List current tournaments get_arena_tournaments(); // Join a tournament join_arena({ tournamentId: "abc123" }); // Create a new tournament create_arena({ name: "My Tournament", clockTime: 3, clockIncrement: 2, minutes: 45 });

国际象棋符号

移动格式

Lichess API 接受以下格式的移动:

  • UCI :通用国际象棋接口格式(例如e2e4g8f6
  • SAN :标准代数符号(例如e4Nf6 )- 仅适用于某些端点

FEN 格式

福赛斯-爱德华兹符号(FEN)用于表示国际象棋位置:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

这代表:

  • 棋子位置(从第 8 位到第 1 位)
  • 活动颜色 (w/b)
  • 王车易位可用性 (KQkq)
  • 顺便瞄准目标方块
  • 半步时钟
  • Fullmove 号码

错误处理

服务器提供以下详细的错误消息:

  • 无效的移动或位置
  • 身份验证问题
  • 速率限制
  • 资源未找到的情况

设置说明

  1. 克隆存储库:
    git clone https://github.com/karayaman/lichess-mcp.git cd lichess-mcp
  2. 安装依赖项:
    npm install
  3. 配置环境变量:在根目录下创建.env文件:
    LICHESS_TOKEN=your-lichess-api-token
  4. 构建项目:
    npm run build
  5. 全局安装软件包(推荐用于 Claude Desktop 集成):
    npm install -g
  6. 启动服务器(供独立使用):
    npm start

配置 Claude 桌面

要将此 MCP 服务器与 Claude Desktop 一起使用:

  1. 找到您的 Claude Desktop 配置文件:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. 将 Lichess MCP 服务器添加到您的配置中:
    { "mcpServers": { "lichess": { "command": "lichess-mcp", "env": { "LICHESS_TOKEN": "your-lichess-api-token", "DEBUG": "*" } } } }
    注意:请将your-lichess-api-token替换为你的实际 Lichess API 令牌。DEBUG 环境DEBUG是可选的,但有助于故障排除。
  3. (可选)您也可以添加其他 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" } } } }
  4. 重新启动 Claude Desktop 以应用更改。
    • 确保完全关闭 Claude Desktop(包括从系统托盘/菜单栏关闭)
    • 再次启动 Claude Desktop
    • 在界面中查找锤子图标,表示 MCP 服务器已连接
  5. 通过向 Claude 询问您的 Lichess 帐户来测试集成:
    • “显示我的 Lichess 个人资料”
    • “开始一场新的棋局,时间控制为10分钟”

故障排除

如果您遇到 MCP 服务器连接问题:

  1. 确保已使用npm install -g全局安装了该软件包
  2. 验证lichess-mcp命令是否在您的 PATH 中可用( which lichess-mcp
  3. 检查您的配置文件是否具有正确的格式(较新的mcpServers格式而不是mcp_servers格式)
  4. 完全重启Claude Desktop
  5. 尝试在 Claude Desktop 中启用开发者模式(如果可用)以获取更多日志记录
  6. 验证您的 Lichess API 令牌是否有效

参考

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

一个可以与 Lichess 国际象棋平台进行自然语言交互的 MCP 服务器,允许用户通过 Claude 玩游戏、分析位置、管理他们的帐户并参加比赛。

  1. Configuration
    1. Available Tools
      1. 1. Account Management
      2. 2. Game Play
      3. 3. Game Analysis
      4. 4. Tournaments
    2. Chess Notation
      1. Move Formats
      2. FEN Format
    3. Error Handling
      1. Setup Instructions
        1. Configuring Claude Desktop
          1. Troubleshooting
            1. References
              ID: x7iuw37s1v