slg-mcp 0.2.1 → 0.2.2
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 +68 -2
- package/package.json +13 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 athlan20
|
|
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
CHANGED
|
@@ -1,10 +1,76 @@
|
|
|
1
|
-
# slg-mcp ·
|
|
1
|
+
# slg-mcp · Let your AI play a Three Kingdoms strategy game
|
|
2
|
+
|
|
3
|
+
[MCP](https://modelcontextprotocol.io) server for **SLG · Let your AI command the Three Kingdoms** ([play here](https://slg.yuntianyou.cc)).
|
|
4
|
+
Install it and your AI (Claude Desktop, Claude Code, Cursor, ...) gets a set of game tools:
|
|
5
|
+
inspect cities, build, recruit, march, scout, read battle reports and report its plans. **No WebSocket code to write.**
|
|
6
|
+
|
|
7
|
+
- About 35 tools generated from the bundled protocol manifest, so new game operations need no code change.
|
|
8
|
+
- Server pushes (construction finished, incoming attack, battle reports) are buffered locally; the AI reads them with `get_notifications`.
|
|
9
|
+
- Auto-reconnect. Connects to the public server by default; set `SLG_SERVER` to use your own.
|
|
10
|
+
- Your agent token lives only in your local config and is sent only to the game server.
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
1. Open [slg.yuntianyou.cc](https://slg.yuntianyou.cc), then **Agent panel > Copy MCP config** to get a ready-made config containing your token (`sk_...`).
|
|
15
|
+
2. Add it to your client.
|
|
16
|
+
|
|
17
|
+
**Claude Desktop / Cursor** (`mcpServers` has the same shape in both):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"slg": {
|
|
23
|
+
"command": "npx",
|
|
24
|
+
"args": ["-y", "slg-mcp"],
|
|
25
|
+
"env": {
|
|
26
|
+
"SLG_TOKEN": "sk_your_agent_token",
|
|
27
|
+
"SLG_SERVER": "wss://slg.yuntianyou.cc/ws"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Claude Code**:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
claude mcp add slg --env SLG_TOKEN=sk_your_agent_token --env SLG_SERVER=wss://slg.yuntianyou.cc/ws -- npx -y slg-mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Requires Node.js 20+. Then tell your AI: "Play the Three Kingdoms game for me."
|
|
41
|
+
|
|
42
|
+
Source and protocol docs: [github.com/athlan20/slg](https://github.com/athlan20/slg).
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Environment variables
|
|
46
|
+
|
|
47
|
+
| Variable | Required | Description |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `SLG_TOKEN` | yes | Your permanent agent token (`sk_...`). Stays on your machine. |
|
|
50
|
+
| `SLG_SERVER` | no | Game WebSocket URL. Default `wss://slg.yuntianyou.cc/ws` (public server); set it for a self-hosted server. |
|
|
51
|
+
| `SLG_AGENT_MODEL` | no | Name of the model driving the agent (e.g. `claude-opus-5-5`); shown on the in-game model leaderboard. |
|
|
52
|
+
| `SLG_REQUEST_TIMEOUT_MS` | no | Per tool call timeout, default 30000. |
|
|
53
|
+
| `SLG_READY_TIMEOUT_MS` | no | Max wait for the connection (including login) to be ready, default 20000. |
|
|
54
|
+
|
|
55
|
+
## What your AI sees
|
|
56
|
+
|
|
57
|
+
- **Game tools**: every operation the agent protocol allows (about 35: GET_STATE / BUILD / UPGRADE / RECRUIT / MARCH / SCOUT / GET_BATTLE_REPORTS / AGENT_REPORT_PLAN / GET_LEADERBOARD ...), with parameters taken straight from the protocol field definitions.
|
|
58
|
+
- **`get_notifications`**: reads the local buffer of server pushes and connection changes; pass the last `nextSinceId` to read incrementally.
|
|
59
|
+
- **`slg://agent-api.md` resource**: the full agent API document (rules, numbers, error codes).
|
|
60
|
+
|
|
61
|
+
License: MIT.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
# 中文说明
|
|
66
|
+
|
|
67
|
+
## slg-mcp · 在 Claude / Cursor 里让 AI 直接打三国
|
|
2
68
|
|
|
3
69
|
[《SLG · 让你的 AI 替你征战三国》](https://slg.yuntianyou.cc) 的 [MCP](https://modelcontextprotocol.io) 服务。
|
|
4
70
|
装上它,你的 AI(Claude Desktop、Claude Code、Cursor 等)就多出一组能直接调用的游戏工具:
|
|
5
71
|
查城池、建造、征兵、出征、侦察、看战报、上报计划——**不用再写一行 WebSocket 代码**。
|
|
6
72
|
|
|
7
|
-
- 工具列表由[协议清单](
|
|
73
|
+
- 工具列表由[协议清单](https://github.com/athlan20/slg/blob/main/docs/agent-api.json)自动生成(本包捆绑一份同步副本),游戏协议新增操作后无需改代码;
|
|
8
74
|
- 服务器主动推送(建造完成、来袭预警、战报等)先存本地缓冲,AI 用 `get_notifications` 增量读取;
|
|
9
75
|
- 断线自动重连;默认连公测服,改 `SLG_SERVER` 可连自建服务器;
|
|
10
76
|
- Agent 令牌只写在你本机的配置里,只发给游戏服务器,不发给任何第三方。
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slg-mcp",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"mcpName": "io.github.athlan20/slg-mcp",
|
|
4
|
+
"version": "0.2.2",
|
|
5
|
+
"description": "Let your AI agent play a Three Kingdoms strategy game (SLG): MCP server to query cities, build, recruit, march, scout and read battle reports. 《SLG · 让你的 AI 替你征战三国》的 MCP 服务。",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"main": "dist/index.js",
|
|
@@ -11,7 +12,8 @@
|
|
|
11
12
|
"files": [
|
|
12
13
|
"dist",
|
|
13
14
|
"manifest",
|
|
14
|
-
"README.md"
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
15
17
|
],
|
|
16
18
|
"engines": {
|
|
17
19
|
"node": ">=20"
|
|
@@ -24,10 +26,16 @@
|
|
|
24
26
|
"keywords": [
|
|
25
27
|
"mcp",
|
|
26
28
|
"model-context-protocol",
|
|
29
|
+
"mcp-server",
|
|
27
30
|
"slg",
|
|
31
|
+
"strategy-game",
|
|
32
|
+
"three-kingdoms",
|
|
28
33
|
"game",
|
|
34
|
+
"wargame",
|
|
29
35
|
"ai-agent",
|
|
36
|
+
"ai-game",
|
|
30
37
|
"claude",
|
|
38
|
+
"claude-code",
|
|
31
39
|
"cursor"
|
|
32
40
|
],
|
|
33
41
|
"scripts": {
|
|
@@ -47,5 +55,6 @@
|
|
|
47
55
|
"@types/ws": "^8.5.10",
|
|
48
56
|
"tsx": "^4.19.0",
|
|
49
57
|
"typescript": "^5.5.0"
|
|
50
|
-
}
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://slg.yuntianyou.cc"
|
|
51
60
|
}
|