@chessceo/mcp 0.3.0 → 0.4.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/dist/index.js +100 -0
- package/package.json +15 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chess.ceo
|
|
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 grant 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/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// endpoints — see the public contract at https://chess.ceo/llms.txt.
|
|
8
8
|
// No API key, no auth, no state; the API's own rate limits apply.
|
|
9
9
|
import { createServer as createHttpServer } from "node:http";
|
|
10
|
+
import { Chess } from "chess.js";
|
|
10
11
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
11
12
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
12
13
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
@@ -120,6 +121,29 @@ const TOOLS = [
|
|
|
120
121
|
required: ["fen"],
|
|
121
122
|
},
|
|
122
123
|
},
|
|
124
|
+
{
|
|
125
|
+
name: "analyse",
|
|
126
|
+
description: "Short Stockfish evaluation at a position. Returns the top-N candidate moves with score (centipawns from side-to-move POV, positive = advantage; or mate distance) and the principal variation for each. Defaults: 2s think time, top-3 lines. PV moves come back in UCI notation (e2e4, not e4). Use this to sanity-check candidate lines from get_position_stats or get_player_preparation — human game frequency tells you what people play, engine evaluation tells you what's actually good.",
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
fen: { type: "string", description: "FEN of the position to analyse." },
|
|
131
|
+
movetime_ms: {
|
|
132
|
+
type: "integer",
|
|
133
|
+
minimum: 100,
|
|
134
|
+
maximum: 10000,
|
|
135
|
+
description: "Think time in milliseconds (default 2000).",
|
|
136
|
+
},
|
|
137
|
+
multipv: {
|
|
138
|
+
type: "integer",
|
|
139
|
+
minimum: 1,
|
|
140
|
+
maximum: 10,
|
|
141
|
+
description: "Number of candidate lines to return (default 3).",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
required: ["fen"],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
123
147
|
{
|
|
124
148
|
name: "get_head_to_head",
|
|
125
149
|
description: "Complete head-to-head record between two players. Includes overall and per-colour W/D/L (from player A's perspective), splits by time control, most-played openings between them, first / last meeting, average game length, and the game list.",
|
|
@@ -161,6 +185,27 @@ const TOOLS = [
|
|
|
161
185
|
required: ["fide_id"],
|
|
162
186
|
},
|
|
163
187
|
},
|
|
188
|
+
{
|
|
189
|
+
name: "prep_snapshot",
|
|
190
|
+
description: "One call, three parallel fetches at the same position: opponent's stats on their side, your stats on your side, and the 11.7M-game general database at that position. Use this while walking the opening tree — one round trip instead of three separate calls, and you can compare the three views directly (e.g. opponent has 2 games here but the general DB has 8k → prep candidate).",
|
|
191
|
+
inputSchema: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
fide_id_me: { type: "integer", description: "Your FIDE ID." },
|
|
195
|
+
fide_id_opponent: { type: "integer", description: "Opponent's FIDE ID." },
|
|
196
|
+
my_color: { type: "string", enum: ["white", "black"], description: "The colour YOU will play." },
|
|
197
|
+
line: {
|
|
198
|
+
type: "string",
|
|
199
|
+
description: "Move sequence in SAN, space-separated. Empty = starting position. Example: 'e4 c5 Nf3'. Either line or fen (or neither for the starting position).",
|
|
200
|
+
},
|
|
201
|
+
fen: {
|
|
202
|
+
type: "string",
|
|
203
|
+
description: "Alternative to line — raw FEN of the target position.",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
required: ["fide_id_me", "fide_id_opponent", "my_color"],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
164
209
|
];
|
|
165
210
|
async function callTool(name, args) {
|
|
166
211
|
switch (name) {
|
|
@@ -190,6 +235,14 @@ async function callTool(name, args) {
|
|
|
190
235
|
limit: typeof args.limit === "number" ? args.limit : 20,
|
|
191
236
|
sort: "relevance",
|
|
192
237
|
});
|
|
238
|
+
case "analyse": {
|
|
239
|
+
const params = { fen: String(args.fen) };
|
|
240
|
+
if (typeof args.movetime_ms === "number")
|
|
241
|
+
params.movetime_ms = args.movetime_ms;
|
|
242
|
+
if (typeof args.multipv === "number")
|
|
243
|
+
params.multipv = args.multipv;
|
|
244
|
+
return get("/api/chess/database/analyse", params);
|
|
245
|
+
}
|
|
193
246
|
case "get_head_to_head":
|
|
194
247
|
return get("/api/chess/players/h2h", {
|
|
195
248
|
a: Number(args.fide_id_a),
|
|
@@ -204,6 +257,53 @@ async function callTool(name, args) {
|
|
|
204
257
|
case "list_player_live_tournaments":
|
|
205
258
|
// Note: snake_case fide_id, unlike the prep endpoints. Documented quirk.
|
|
206
259
|
return get("/api/chess/live/player", { fide_id: Number(args.fide_id) });
|
|
260
|
+
case "prep_snapshot": {
|
|
261
|
+
const me = Number(args.fide_id_me);
|
|
262
|
+
const opp = Number(args.fide_id_opponent);
|
|
263
|
+
const myColor = String(args.my_color);
|
|
264
|
+
const oppColor = myColor === "white" ? "black" : "white";
|
|
265
|
+
const line = typeof args.line === "string" ? args.line.trim() : "";
|
|
266
|
+
let fen = typeof args.fen === "string" ? args.fen.trim() : "";
|
|
267
|
+
// General DB lookup needs a FEN. If we only have a line, compute it
|
|
268
|
+
// locally with chess.js — one dep, keeps the three data-fetches truly
|
|
269
|
+
// parallel instead of doing a preliminary round-trip.
|
|
270
|
+
if (!fen) {
|
|
271
|
+
const board = new Chess();
|
|
272
|
+
if (line.length > 0) {
|
|
273
|
+
for (const raw of line.split(/\s+/)) {
|
|
274
|
+
// Tolerant of move-number tokens like "1." / "12..." that some
|
|
275
|
+
// clients include; chess.js rejects those outright.
|
|
276
|
+
const san = raw.replace(/^\d+\.+/, "");
|
|
277
|
+
if (!san)
|
|
278
|
+
continue;
|
|
279
|
+
try {
|
|
280
|
+
board.move(san);
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
throw new Error(`bad SAN token '${raw}' in line`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
fen = board.fen();
|
|
288
|
+
}
|
|
289
|
+
const prepParams = (fideId, color) => ({
|
|
290
|
+
fideId,
|
|
291
|
+
color,
|
|
292
|
+
compact: "true",
|
|
293
|
+
...(line.length > 0 ? { line } : { fen }),
|
|
294
|
+
});
|
|
295
|
+
const [opponent, you, general] = await Promise.all([
|
|
296
|
+
get("/api/chess/prep/by-player", prepParams(opp, oppColor)),
|
|
297
|
+
get("/api/chess/prep/by-player", prepParams(me, myColor)),
|
|
298
|
+
get("/api/chess/database/main", { fen, limit: 20, sort: "relevance" }),
|
|
299
|
+
]);
|
|
300
|
+
return {
|
|
301
|
+
position: { line, fen, my_color: myColor },
|
|
302
|
+
opponent,
|
|
303
|
+
you,
|
|
304
|
+
general,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
207
307
|
default:
|
|
208
308
|
throw new Error(`Unknown tool: ${name}`);
|
|
209
309
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chessceo/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Model Context Protocol server for chess.ceo — 11.7M+ games, ~1.5M FIDE player profiles, opening preparation, live broadcasts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"chessceo-mcp": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"main": "dist/index.js",
|
|
10
|
-
"files": [
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
11
14
|
"scripts": {
|
|
12
15
|
"build": "tsc",
|
|
13
16
|
"dev": "tsc --watch",
|
|
14
17
|
"start": "node dist/index.js",
|
|
15
18
|
"prepublishOnly": "npm run build"
|
|
16
19
|
},
|
|
17
|
-
"keywords": [
|
|
20
|
+
"keywords": [
|
|
21
|
+
"mcp",
|
|
22
|
+
"modelcontextprotocol",
|
|
23
|
+
"chess",
|
|
24
|
+
"chessceo",
|
|
25
|
+
"llm",
|
|
26
|
+
"claude",
|
|
27
|
+
"fide"
|
|
28
|
+
],
|
|
18
29
|
"author": "chess.ceo",
|
|
19
30
|
"license": "MIT",
|
|
20
31
|
"repository": {
|
|
@@ -30,6 +41,7 @@
|
|
|
30
41
|
},
|
|
31
42
|
"dependencies": {
|
|
32
43
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
44
|
+
"chess.js": "^1.4.0",
|
|
33
45
|
"zod": "^3.23.0"
|
|
34
46
|
},
|
|
35
47
|
"devDependencies": {
|