@pipeworx/mcp-lichess 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +65 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +238 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# mcp-lichess
|
|
2
|
+
|
|
3
|
+
Lichess public API: players, ratings, eval, tablebase, opening explorer
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `user` | Player profile with ratings across all variants. |
|
|
12
|
+
| `users` | Bulk lookup of up to 300 users by username. |
|
|
13
|
+
| `user_status` | Online / playing status for the given usernames (up to 100). |
|
|
14
|
+
| `user_performance` | Single-variant performance + best rated game for a user. |
|
|
15
|
+
| `top_players` | Top-rated players for one variant. |
|
|
16
|
+
| `leaderboards` | Top-10 across all variants in one call. |
|
|
17
|
+
| `tv_channels` | Currently-featured TV games per variant. |
|
|
18
|
+
| `cloud_eval` | Stockfish cloud evaluation for a FEN position. |
|
|
19
|
+
| `tablebase` | Syzygy tablebase lookup (≤7 pieces). Variant: standard (default), atomic, antichess. |
|
|
20
|
+
| `opening_explorer` | Opening explorer. scope: "lichess" (community), "masters" (top 2200+ humans), "player" (single user). |
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"lichess": {
|
|
30
|
+
"url": "https://gateway.pipeworx.io/lichess/mcp"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or connect to the full Pipeworx gateway for access to all 250+ data sources:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"pipeworx": {
|
|
42
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Using with ask_pipeworx
|
|
49
|
+
|
|
50
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
ask_pipeworx({ question: "your question about Lichess data" })
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
57
|
+
|
|
58
|
+
## More
|
|
59
|
+
|
|
60
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
61
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-lichess",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lichess public API: players, ratings, eval, tablebase, opening explorer",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "lichess"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-lichess"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/lichess",
|
|
4
|
+
"title": "Lichess",
|
|
5
|
+
"description": "Lichess public API: players, ratings, eval, tablebase, opening explorer",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/lichess",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-lichess",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/lichess/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
meter?: { credits: number };
|
|
15
|
+
cost?: Record<string, unknown>;
|
|
16
|
+
provider?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Lichess MCP — public read-only API for users, games, explorer, tablebase.
|
|
21
|
+
*
|
|
22
|
+
* Docs: https://lichess.org/api
|
|
23
|
+
* No auth for public data.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const BASE = 'https://lichess.org/api';
|
|
28
|
+
const EXPLORER = 'https://explorer.lichess.ovh';
|
|
29
|
+
const TABLEBASE = 'https://tablebase.lichess.ovh';
|
|
30
|
+
const UA = 'pipeworx-mcp-lichess/1.0 (+https://pipeworx.io)';
|
|
31
|
+
|
|
32
|
+
const tools: McpToolExport['tools'] = [
|
|
33
|
+
{
|
|
34
|
+
name: 'user',
|
|
35
|
+
description: 'Player profile with ratings across all variants.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: { username: { type: 'string' } },
|
|
39
|
+
required: ['username'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'users',
|
|
44
|
+
description: 'Bulk lookup of up to 300 users by username.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
usernames: { type: 'array', items: { type: 'string' }, description: '1-300 usernames.' },
|
|
49
|
+
},
|
|
50
|
+
required: ['usernames'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'user_status',
|
|
55
|
+
description: 'Online / playing status for the given usernames (up to 100).',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
usernames: { type: 'array', items: { type: 'string' } },
|
|
60
|
+
},
|
|
61
|
+
required: ['usernames'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'user_performance',
|
|
66
|
+
description: 'Single-variant performance + best rated game for a user.',
|
|
67
|
+
inputSchema: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
properties: {
|
|
70
|
+
username: { type: 'string' },
|
|
71
|
+
perf: { type: 'string', description: 'bullet | blitz | rapid | classical | correspondence | chess960 | crazyhouse | antichess | atomic | horde | kingOfTheHill | racingKings | threeCheck | ultraBullet' },
|
|
72
|
+
},
|
|
73
|
+
required: ['username', 'perf'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'top_players',
|
|
78
|
+
description: 'Top-rated players for one variant.',
|
|
79
|
+
inputSchema: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
perf: { type: 'string' },
|
|
83
|
+
limit: { type: 'number', description: '1-200 (default 50)' },
|
|
84
|
+
},
|
|
85
|
+
required: ['perf'],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'leaderboards',
|
|
90
|
+
description: 'Top-10 across all variants in one call.',
|
|
91
|
+
inputSchema: { type: 'object', properties: {} },
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'tv_channels',
|
|
95
|
+
description: 'Currently-featured TV games per variant.',
|
|
96
|
+
inputSchema: { type: 'object', properties: {} },
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'cloud_eval',
|
|
100
|
+
description: 'Stockfish cloud evaluation for a FEN position.',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
fen: { type: 'string', description: 'FEN of position to evaluate.' },
|
|
105
|
+
multi_pv: { type: 'number', description: '1-5 (default 1)' },
|
|
106
|
+
},
|
|
107
|
+
required: ['fen'],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'tablebase',
|
|
112
|
+
description: 'Syzygy tablebase lookup (≤7 pieces). Variant: standard (default), atomic, antichess.',
|
|
113
|
+
inputSchema: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
fen: { type: 'string' },
|
|
117
|
+
variant: { type: 'string', description: 'standard | atomic | antichess' },
|
|
118
|
+
},
|
|
119
|
+
required: ['fen'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'opening_explorer',
|
|
124
|
+
description: 'Opening explorer. scope: "lichess" (community), "masters" (top 2200+ humans), "player" (single user).',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
scope: { type: 'string', description: 'lichess | masters | player' },
|
|
129
|
+
fen: { type: 'string', description: 'Mutually exclusive with play.' },
|
|
130
|
+
play: { type: 'string', description: 'UCI move list, comma-separated. Mutually exclusive with fen.' },
|
|
131
|
+
player: { type: 'string', description: 'Username (only for scope=player).' },
|
|
132
|
+
speeds: { type: 'string', description: 'Comma-sep: ultraBullet,bullet,blitz,rapid,classical,correspondence' },
|
|
133
|
+
ratings: { type: 'string', description: 'Comma-sep (lichess scope): 0,1000,1200,1400,1600,1800,2000,2200,2500' },
|
|
134
|
+
moves: { type: 'number', description: 'Number of top moves to return (default 12, max 64).' },
|
|
135
|
+
},
|
|
136
|
+
required: ['scope'],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
142
|
+
switch (name) {
|
|
143
|
+
case 'user':
|
|
144
|
+
return lichessGet(`/user/${encodeURIComponent(reqStr(args, 'username', '"DrNykterstein"'))}`);
|
|
145
|
+
case 'users': {
|
|
146
|
+
const names = reqArr(args, 'usernames', '["DrNykterstein"]').slice(0, 300);
|
|
147
|
+
const res = await fetch(`${BASE}/users`, {
|
|
148
|
+
method: 'POST',
|
|
149
|
+
headers: { 'Content-Type': 'text/plain', Accept: 'application/json', 'User-Agent': UA },
|
|
150
|
+
body: names.join(','),
|
|
151
|
+
});
|
|
152
|
+
if (!res.ok) throw new Error(`Lichess: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
153
|
+
return res.json();
|
|
154
|
+
}
|
|
155
|
+
case 'user_status': {
|
|
156
|
+
const names = reqArr(args, 'usernames', '["DrNykterstein"]').slice(0, 100);
|
|
157
|
+
return lichessGet(`/users/status?ids=${encodeURIComponent(names.join(','))}`);
|
|
158
|
+
}
|
|
159
|
+
case 'user_performance':
|
|
160
|
+
return lichessGet(
|
|
161
|
+
`/user/${encodeURIComponent(reqStr(args, 'username', '"DrNykterstein"'))}/perf/${encodeURIComponent(reqStr(args, 'perf', '"blitz"'))}`,
|
|
162
|
+
);
|
|
163
|
+
case 'top_players': {
|
|
164
|
+
const limit = Math.min(200, Math.max(1, (args.limit as number) ?? 50));
|
|
165
|
+
return lichessGet(`/player/top/${limit}/${encodeURIComponent(reqStr(args, 'perf', '"blitz"'))}`);
|
|
166
|
+
}
|
|
167
|
+
case 'leaderboards':
|
|
168
|
+
return lichessGet('/player');
|
|
169
|
+
case 'tv_channels':
|
|
170
|
+
return lichessGet('/tv/channels');
|
|
171
|
+
case 'cloud_eval': {
|
|
172
|
+
const params = new URLSearchParams({ fen: reqStr(args, 'fen', '"<fen>"') });
|
|
173
|
+
if (args.multi_pv) params.set('multiPv', String(args.multi_pv));
|
|
174
|
+
return lichessGet(`/cloud-eval?${params}`);
|
|
175
|
+
}
|
|
176
|
+
case 'tablebase': {
|
|
177
|
+
const variant = (args.variant as string | undefined)?.toLowerCase() ?? 'standard';
|
|
178
|
+
if (!['standard', 'atomic', 'antichess'].includes(variant)) {
|
|
179
|
+
throw new Error('variant must be standard | atomic | antichess.');
|
|
180
|
+
}
|
|
181
|
+
const params = new URLSearchParams({ fen: reqStr(args, 'fen', '"4k3/8/4K3/4P3/8/8/8/8 b - - 0 1"') });
|
|
182
|
+
const res = await fetch(`${TABLEBASE}/${variant}?${params}`, {
|
|
183
|
+
headers: { Accept: 'application/json', 'User-Agent': UA },
|
|
184
|
+
});
|
|
185
|
+
if (!res.ok) throw new Error(`Lichess tablebase: ${res.status}`);
|
|
186
|
+
return res.json();
|
|
187
|
+
}
|
|
188
|
+
case 'opening_explorer': {
|
|
189
|
+
const scope = reqStr(args, 'scope', '"lichess"').toLowerCase();
|
|
190
|
+
if (!['lichess', 'masters', 'player'].includes(scope)) {
|
|
191
|
+
throw new Error('scope must be lichess | masters | player.');
|
|
192
|
+
}
|
|
193
|
+
const params = new URLSearchParams();
|
|
194
|
+
if (args.fen) params.set('fen', String(args.fen));
|
|
195
|
+
if (args.play) params.set('play', String(args.play));
|
|
196
|
+
if (args.speeds) params.set('speeds', String(args.speeds));
|
|
197
|
+
if (args.ratings && scope === 'lichess') params.set('ratings', String(args.ratings));
|
|
198
|
+
if (args.moves) params.set('moves', String(Math.min(64, Math.max(1, args.moves as number))));
|
|
199
|
+
if (scope === 'player') {
|
|
200
|
+
params.set('player', reqStr(args, 'player', '"DrNykterstein"'));
|
|
201
|
+
params.set('color', 'white');
|
|
202
|
+
}
|
|
203
|
+
const res = await fetch(`${EXPLORER}/${scope === 'lichess' ? 'lichess' : scope}?${params}`, {
|
|
204
|
+
headers: { Accept: 'application/json', 'User-Agent': UA },
|
|
205
|
+
});
|
|
206
|
+
if (!res.ok) throw new Error(`Lichess explorer: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
207
|
+
return res.json();
|
|
208
|
+
}
|
|
209
|
+
default:
|
|
210
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function lichessGet(path: string): Promise<unknown> {
|
|
215
|
+
const res = await fetch(`${BASE}${path}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
216
|
+
if (res.status === 404) throw new Error('Lichess: not found');
|
|
217
|
+
if (res.status === 429) throw new Error('Lichess: rate-limit (HTTP 429)');
|
|
218
|
+
if (!res.ok) throw new Error(`Lichess: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
219
|
+
return res.json();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
223
|
+
const v = args[key];
|
|
224
|
+
if (typeof v !== 'string' || !v.trim()) {
|
|
225
|
+
throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
|
|
226
|
+
}
|
|
227
|
+
return v;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function reqArr(args: Record<string, unknown>, key: string, example: string): string[] {
|
|
231
|
+
const v = args[key];
|
|
232
|
+
if (!Array.isArray(v) || v.length === 0) {
|
|
233
|
+
throw new Error(`Required argument "${key}" must be a non-empty array, e.g. ${example}.`);
|
|
234
|
+
}
|
|
235
|
+
return v.filter((s): s is string => typeof s === 'string');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|