@chessceo/mcp 0.3.0 → 0.3.1
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/dist/index.js +69 -0
- package/package.json +15 -3
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";
|
|
@@ -161,6 +162,27 @@ const TOOLS = [
|
|
|
161
162
|
required: ["fide_id"],
|
|
162
163
|
},
|
|
163
164
|
},
|
|
165
|
+
{
|
|
166
|
+
name: "prep_snapshot",
|
|
167
|
+
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).",
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: "object",
|
|
170
|
+
properties: {
|
|
171
|
+
fide_id_me: { type: "integer", description: "Your FIDE ID." },
|
|
172
|
+
fide_id_opponent: { type: "integer", description: "Opponent's FIDE ID." },
|
|
173
|
+
my_color: { type: "string", enum: ["white", "black"], description: "The colour YOU will play." },
|
|
174
|
+
line: {
|
|
175
|
+
type: "string",
|
|
176
|
+
description: "Move sequence in SAN, space-separated. Empty = starting position. Example: 'e4 c5 Nf3'. Either line or fen (or neither for the starting position).",
|
|
177
|
+
},
|
|
178
|
+
fen: {
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Alternative to line — raw FEN of the target position.",
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
required: ["fide_id_me", "fide_id_opponent", "my_color"],
|
|
184
|
+
},
|
|
185
|
+
},
|
|
164
186
|
];
|
|
165
187
|
async function callTool(name, args) {
|
|
166
188
|
switch (name) {
|
|
@@ -204,6 +226,53 @@ async function callTool(name, args) {
|
|
|
204
226
|
case "list_player_live_tournaments":
|
|
205
227
|
// Note: snake_case fide_id, unlike the prep endpoints. Documented quirk.
|
|
206
228
|
return get("/api/chess/live/player", { fide_id: Number(args.fide_id) });
|
|
229
|
+
case "prep_snapshot": {
|
|
230
|
+
const me = Number(args.fide_id_me);
|
|
231
|
+
const opp = Number(args.fide_id_opponent);
|
|
232
|
+
const myColor = String(args.my_color);
|
|
233
|
+
const oppColor = myColor === "white" ? "black" : "white";
|
|
234
|
+
const line = typeof args.line === "string" ? args.line.trim() : "";
|
|
235
|
+
let fen = typeof args.fen === "string" ? args.fen.trim() : "";
|
|
236
|
+
// General DB lookup needs a FEN. If we only have a line, compute it
|
|
237
|
+
// locally with chess.js — one dep, keeps the three data-fetches truly
|
|
238
|
+
// parallel instead of doing a preliminary round-trip.
|
|
239
|
+
if (!fen) {
|
|
240
|
+
const board = new Chess();
|
|
241
|
+
if (line.length > 0) {
|
|
242
|
+
for (const raw of line.split(/\s+/)) {
|
|
243
|
+
// Tolerant of move-number tokens like "1." / "12..." that some
|
|
244
|
+
// clients include; chess.js rejects those outright.
|
|
245
|
+
const san = raw.replace(/^\d+\.+/, "");
|
|
246
|
+
if (!san)
|
|
247
|
+
continue;
|
|
248
|
+
try {
|
|
249
|
+
board.move(san);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
throw new Error(`bad SAN token '${raw}' in line`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
fen = board.fen();
|
|
257
|
+
}
|
|
258
|
+
const prepParams = (fideId, color) => ({
|
|
259
|
+
fideId,
|
|
260
|
+
color,
|
|
261
|
+
compact: "true",
|
|
262
|
+
...(line.length > 0 ? { line } : { fen }),
|
|
263
|
+
});
|
|
264
|
+
const [opponent, you, general] = await Promise.all([
|
|
265
|
+
get("/api/chess/prep/by-player", prepParams(opp, oppColor)),
|
|
266
|
+
get("/api/chess/prep/by-player", prepParams(me, myColor)),
|
|
267
|
+
get("/api/chess/database/main", { fen, limit: 20, sort: "relevance" }),
|
|
268
|
+
]);
|
|
269
|
+
return {
|
|
270
|
+
position: { line, fen, my_color: myColor },
|
|
271
|
+
opponent,
|
|
272
|
+
you,
|
|
273
|
+
general,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
207
276
|
default:
|
|
208
277
|
throw new Error(`Unknown tool: ${name}`);
|
|
209
278
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chessceo/mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
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": {
|