@mslteam/mslx-agent-skill 0.0.0-stage → 1.0.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.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +273 -2
  3. package/SKILL.md +127 -0
  4. package/bin/cli.js +399 -0
  5. package/package.json +49 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MSLTeam
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,3 +1,274 @@
1
- # Temporary Holding Version
1
+ # MSLX Agent Skill (`@mslteam/mslx-agent-skill`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **MSLX 官方 Minecraft 服务器运维与全平台 MCP 协议桥接 Agent Skill**
4
+ > 面向 Google Antigravity、Cursor、Workbuddy、Qoder、Claude Desktop、Windsurf、豆包等国内外主流 AI Agent,提供完整的 Minecraft 智能运维规则、Java 版本映射矩阵、容灾回档协议与 MCP 运维工具支持。
5
+
6
+ [![npm version](https://img.shields.io/npm/v/@mslteam/mslx-agent-skill.svg)](https://www.npmjs.com/package/@mslteam/mslx-agent-skill)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-green.svg)](https://nodejs.org/)
9
+
10
+ ---
11
+
12
+ ## 🌟 核心特性
13
+
14
+ - 🚀 **零重依赖原生架构**:完全基于 Node.js 原生模块 (`http`, `https`, `events`, `readline`, `url`) 构建,无需安装任何体积庞大的第三方 npm 依赖,秒级拉起、轻量高效。
15
+ - 🔌 **全双工 Stdio-to-SSE 桥接**:完美打通基于标准输入输出 (Stdio) 的本地 Agent 与 MSLX 宿主后端 Server-Sent Events (SSE) / JSON-RPC 2.0 远程 MCP 服务的协议转换。
16
+ - 🛡️ **数据安全防御机制**:深度集成高危操作二次确认卡片防护、防御性备份机制 (Backup-First) 与 Dedicated Server 客户端独占模组深度体检。
17
+ - 🌐 **双通道镜像发布**:内置自动化双通道发布引擎,同时支持组织级包名 `@mslteam/mslx-agent-skill` 与全局精简包名 `mslx-agent-skill`。
18
+ - 📦 **全平台一键开箱即用**:提供针对 Antigravity、Cursor、Workbuddy、Qoder、Claude Desktop、Windsurf 以及纯文本大模型的即拷即用配置。
19
+
20
+ ---
21
+
22
+ ## 💻 CLI 命令行使用指南
23
+
24
+ `install <skills-dir>` 会在指定的技能目录下写入 `mslx-agent-skill/SKILL.md`。使用目标客户端的技能目录,例如下面用工作区的 `.agents/skills`。已有同名文件时会提示,更新前可先备份旧文件。安装后需在客户端另行配置 MCP 连接。
25
+
26
+ 支持远程 MCP 的客户端可以直接使用 WebPanel → AI 助手 → 连接外部 AI(MCP)中的 Streamable HTTP 地址和 Bearer 请求头。下方 Stdio 示例用于需要本地桥接的客户端。使用 `localhost` 时,桥接进程和 MSLX 服务应在同一台机器上。
27
+
28
+ ```bash
29
+ # 查看帮助与参数说明
30
+ npx @mslteam/mslx-agent-skill --help
31
+
32
+ # 安装到工作区的技能目录
33
+ npx -y @mslteam/mslx-agent-skill install .agents/skills
34
+
35
+ # 快速打印完整的官方 Agent Skill 规范(适用于 Antigravity / 豆包预设提示词)
36
+ npx @mslteam/mslx-agent-skill skill
37
+
38
+ # 启动 Stdio-to-SSE MCP 协议桥接(供 Agent 自动化调用)
39
+ npx @mslteam/mslx-agent-skill --token=YOUR_MSLX_TOKEN
40
+
41
+ # 指定自定义 MSLX 宿主地址与 Token
42
+ npx @mslteam/mslx-agent-skill --url=http://127.0.0.1:25333/api/plugin/mslx-plugin-ai-agents/mcp --token=YOUR_MSLX_TOKEN
43
+ ```
44
+
45
+ ---
46
+
47
+ ## 🚀 各平台 Agent 快速接入配置指南
48
+
49
+ ### 1. 🌐 Google 反重力 (Google Antigravity)
50
+
51
+ #### 方式 A:加载为专用 Agent Skill
52
+ 在客户端的自定义技能目录中安装本规范,或从面板查看运维指南。
53
+ ```bash
54
+ # 宿主在线查看或导出
55
+ curl -fsS http://localhost:25333/api/plugin/mslx-plugin-ai-agents/mcp/skill.md
56
+ # 或通过 npm 导出
57
+ npx @mslteam/mslx-agent-skill skill
58
+ ```
59
+
60
+ #### 方式 B:配置为 MCP Server
61
+ 在 Antigravity 的 `mcp_servers` 中添加:
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "mslx": {
66
+ "command": "npx",
67
+ "args": [
68
+ "-y",
69
+ "@mslteam/mslx-agent-skill",
70
+ "--url=http://localhost:25333/api/plugin/mslx-plugin-ai-agents/mcp",
71
+ "--token=YOUR_MSLX_TOKEN"
72
+ ]
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ ---
79
+
80
+ ### 2. ⚡ Cursor
81
+
82
+ 在工程根目录的 `.cursor/mcp.json`(或全局 Cursor 设置中的 `MCP Servers`)中添加以下配置:
83
+
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "mslx-mcp": {
88
+ "command": "npx",
89
+ "args": [
90
+ "-y",
91
+ "@mslteam/mslx-agent-skill",
92
+ "--url=http://localhost:25333/api/plugin/mslx-plugin-ai-agents/mcp",
93
+ "--token=YOUR_MSLX_TOKEN"
94
+ ]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ### 3. 💼 Workbuddy (腾讯工友)
103
+
104
+ 进入 Workbuddy 设置 -> **外部工具与 MCP 接入**:
105
+
106
+ - **接入类型**:Stdio 命令行模式
107
+ - **可执行文件 (Command)**:`npx`
108
+ - **参数 (Args)**:`-y @mslteam/mslx-agent-skill --token=YOUR_MSLX_TOKEN`
109
+
110
+ *注:若使用远程连接,也可直接选择 SSE 模式,填入 MSLX 面板展示的 SSE URL:*
111
+ `http://localhost:25333/api/plugin/mslx-plugin-ai-agents/mcp/sse?token=YOUR_MSLX_TOKEN`
112
+
113
+ ---
114
+
115
+ ### 4. 🧠 Qoder
116
+
117
+ 在 Qoder MCP 配置文件 `~/.qoder/mcp.json` 中配置:
118
+
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "mslx": {
123
+ "command": "npx",
124
+ "args": [
125
+ "-y",
126
+ "@mslteam/mslx-agent-skill",
127
+ "--token=YOUR_MSLX_TOKEN"
128
+ ]
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ ---
135
+
136
+ ### 5. 🤖 Claude Desktop
137
+
138
+ 编辑 Claude Desktop 配置文件:
139
+ - **macOS**:`~/Library/Application Support/Claude/claude_desktop_config.json`
140
+ - **Windows**:`%APPDATA%\Claude\claude_desktop_config.json`
141
+
142
+ ```json
143
+ {
144
+ "mcpServers": {
145
+ "mslx-server": {
146
+ "command": "npx",
147
+ "args": [
148
+ "-y",
149
+ "@mslteam/mslx-agent-skill",
150
+ "--token=YOUR_MSLX_TOKEN"
151
+ ]
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ ---
158
+
159
+ ### 6. 🌊 Windsurf (Codeium)
160
+
161
+ 在 `~/.codeium/windsurf/mcp_config.json` 中添加:
162
+
163
+ ```json
164
+ {
165
+ "mcpServers": {
166
+ "mslx": {
167
+ "command": "npx",
168
+ "args": [
169
+ "-y",
170
+ "@mslteam/mslx-agent-skill",
171
+ "--token=YOUR_MSLX_TOKEN"
172
+ ]
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ ---
179
+
180
+ ### 7. 🇨🇳 豆包 (Doubao) / 纯文本大模型
181
+
182
+ 对于不支持直接挂载 MCP 外部协议的纯文本对话大模型,可执行以下命令提取完整经过优化的 System Prompt 预设词,直接粘贴至模型设定中:
183
+
184
+ ```bash
185
+ npx @mslteam/mslx-agent-skill skill
186
+ ```
187
+
188
+ 只有配置了 MCP 连接的客户端才能执行运维工具。纯文本对话可用这份说明提供指导。令牌应配置在客户端的连接设置中。
189
+
190
+ ---
191
+
192
+ ## 🛠️ MCP 工具库概览
193
+
194
+ 实际工具及权限以当前节点和令牌返回的 `tools/list` 为准。
195
+
196
+ | 业务领域 | 工具名称 | 功能描述 |
197
+ | :--- | :--- | :--- |
198
+ | **实例管理** | `control_server` | 启动、停止或重启 Minecraft 服务器 |
199
+ | | `update_instance_settings` | 修改实例内存配额、绑定 Java 版本、核心文件名 |
200
+ | | `update_server_config` | 修改 `server.properties` 键值(端口、正版验证等) |
201
+ | | `query_server_status` | 查询实例在线状态、PID、CPU 与内存利用率 |
202
+ | | `query_system_metrics` | 监控宿主机与实例的系统级硬件性能指标 |
203
+ | **开服生态** | `create_mc_server` | 支持在线核心、整合包、MCDR、自定义 4 种开服模式 |
204
+ | | `query_available_server_cores` | 动态检索官方全量服务端核心(含正式版与快照版) |
205
+ | | `query_creation_status` | 轮询异步开服进度百分比与部署日志 |
206
+ | | `agree_server_eula` | 一键同意 Mojang EULA 协议解决首次开服阻塞 |
207
+ | **操作审批** | `query_operation_status` | 按 `operation_id` 查询当前令牌提交的操作 |
208
+ | **Java 管理** | `query_java_environments` | 全盘扫描系统已安装 JDK(支持强制重扫) |
209
+ | | `install_online_java` | 一键后台下载安装官方 Java 8/11/16/17/21/25 |
210
+ | **安全文件** | `list_server_files` | 列出服务器目录或子目录文件清单 |
211
+ | | `read_server_file` | 无锁读取日志与配置文件 (`FileShare.ReadWrite`) |
212
+ | | `write_server_file` | 创建或覆盖写入文件(前端交互式授权卡片保护) |
213
+ | | `delete_server_file` | 删除文件或目录(前端交互式授权卡片保护) |
214
+ | | `copy_server_file` | 复制并备份特定文件或关键数据目录 |
215
+ | | `move_server_file` | 移动或重命名文件(排障时快速禁用崩服 Mod) |
216
+ | **诊断交互** | `read_server_log` | 深度审查最新日志与崩溃分析报告 |
217
+ | | `send_server_command` | 向运行中的服务器控制台分发指令 |
218
+ | **容灾备份** | `create_server_backup` | 自动刷新磁盘缓存并生成全量世界备份压缩包 |
219
+ | | `list_server_backups` | 获取备份列表、时间戳与格式化文件大小 |
220
+ | | `restore_server_backup` | 一键回档还原(安全停机与授权卡片双重保护) |
221
+ | | `delete_server_backup` | 安全删除指定的历史备份文件 |
222
+ | **穿透自动化** | `query_frp_status` | 查看宿主 FRP 内网穿透隧道及运行状态 |
223
+ | | `control_frp_tunnel` | 开启/停止 FRP 隧道或提取最近 50 条排错日志 |
224
+ | | `manage_scheduled_tasks` | 编排每日自动备份、定时重启与 Cron 维护任务 |
225
+ | **玩家权限** | `force_kill_server` | 服务器卡死时强制强杀进程 |
226
+ | | `delete_server_instance` | 彻底移除服务器实例(删除文件受二次确认保护) |
227
+ | | `query_players` | 综合查询在线玩家、usercache 缓存与活动历史 |
228
+ | | `manage_whitelist` | 管理白名单(支持热重载,无需重启服务器) |
229
+ | | `manage_ops` | 管理 1~4 级 OP 管理员权限并同步 ops.json |
230
+ | | `manage_bans` | 管理黑名单(封禁/解封玩家与 IP 地址) |
231
+ | **资源生态** | `search_mc_resources` | 聚合搜索 Modrinth 与 CurseForge 资源生态 |
232
+ | | `query_resource_versions` | 查询模组/插件的版本兼容性与直链下载地址 |
233
+ | | `download_file_to_server` | 高速下载文件落盘至 `mods/` 或 `plugins/` |
234
+ | | `audit_client_only_mods` | 深度扫描检出 Dedicated Server 客户端独占模组 |
235
+ | | `manage_mod_plugin_state` | 启用、禁用或彻底删除指定的模组/插件 |
236
+ | | `query_python_environments` | 探测宿主机 Python 解释器与 MCDR 安装状态 |
237
+ | | `extract_archive` | 解包整合包、资源包或存档归档文件 |
238
+ | | `compress_files` | 打包指定目录或文件为 `.zip` 文件 |
239
+ | | `list_server_mods_plugins` | 快速列出已安装的模组与插件总览 |
240
+
241
+ ---
242
+
243
+ ## 📦 发布与维护
244
+
245
+ 双包使用同一份源码和版本。`mslx-agent-skill` 是由个人 npm 账号维护的无 scope 公共包,`@mslteam/mslx-agent-skill` 发布到 MSLTeam 组织。首次发布请使用已开启 2FA、且能在 `mslteam` 组织创建公共包的 npm 账号。
246
+
247
+ ```bash
248
+ npm test
249
+ npm run publish-both -- --pack ./npm-packages
250
+ npm login --registry=https://registry.npmjs.org/
251
+ npm whoami --registry=https://registry.npmjs.org/
252
+ npm run publish-both
253
+ ```
254
+
255
+ 按 npm 提示分别完成 2FA。若只剩一个包未发布,可以直接发布 `npm-packages` 中对应的 tarball。
256
+
257
+ ```bash
258
+ npm view mslx-agent-skill version --registry=https://registry.npmjs.org/
259
+ npm view @mslteam/mslx-agent-skill version --registry=https://registry.npmjs.org/
260
+ ```
261
+
262
+ 首次发布后,如果要用 GitHub Actions 发布后续版本,先将项目和 `.github/workflows/publish.yml` 推到 GitHub。在 npmjs.com 的两个包各自进入 **Settings → Trusted publishing**,选择 **GitHub Actions**,填写实际 GitHub 仓库的所有者、仓库名及工作流文件名 `publish.yml`。Environment 留空,允许 `npm publish`。更新 `package.json` 的版本后,在 GitHub **Actions → Publish MSLX Agent Skill to npm → Run workflow** 选择 `both`。若仅一个包需重试,选择对应的 `scoped` 或 `unscoped`。
263
+
264
+ ---
265
+
266
+ ## 📄 开源许可证
267
+
268
+ 本项目基于 [MIT License](LICENSE) 开源协议发布。
269
+ Copyright (c) 2026 MSLTeam. All rights reserved.
270
+
271
+ ### 更新连接与操作确认
272
+
273
+ 旧地址中的插件 ID 已统一为 `mslx-plugin-ai-agents`,更新客户端 URL 后可继续使用原令牌。
274
+ 涉及删除或覆盖时,请在对应节点的 MSLX AI 助手 → MCP → 待确认操作中审批,无需模型 API Key。
package/SKILL.md ADDED
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: mslx-agent-skill
3
+ description: >-
4
+ 管理 MSLX 上的 Minecraft 服务器。用于通过 MSLX MCP 部署和诊断实例、管理 Java、
5
+ 模组与玩家权限,以及执行备份恢复、FRP 和计划任务。
6
+ ---
7
+
8
+ # MSLX Agent Skill - Minecraft 服务器运维与 MCP 协议规范
9
+
10
+ 本指南是 MSLX 官方为 AI Agent(Google Antigravity、Cursor、Workbuddy、Qoder、Claude Desktop、Windsurf、豆包等)提供的**权威运维指导规范与 MCP 工具集手册**。作为智能运维助手,在管理 Minecraft 服务器、排查故障、执行备份恢复及调用 MCP 工具时,**必须严格遵守以下铁律与规范**。
11
+
12
+ ---
13
+
14
+ ## 连接与工具调用
15
+
16
+ 1. 在 MSLX 面板的 AI 助手 → 连接外部 AI(MCP)中获取目标节点的地址和令牌。支持远程 MCP 的客户端使用 Streamable HTTP 和 `Authorization: Bearer <MCP_TOKEN>` 请求头。仅支持 Stdio 的客户端可以使用 npm 包提供的 SSE 桥接。
17
+ 2. 连接后先调用 `tools/list`。以当前节点和令牌返回的工具及 `inputSchema` 为准。令牌应留在连接配置中。客户端缺少 MCP 连接能力时,可以根据用户提供的信息给出运维指导。
18
+ 3. 用户已指定实例,或面板提供了明确的当前实例时,用对应的 ID。目标有歧义时,先查询实例列表并核对目标。
19
+
20
+ ## 运维规则
21
+
22
+ - 查询支持的核心或 Minecraft 版本时,使用 `query_available_server_cores`。快照端使用 `vanilla-snapshot`,正式版原版端使用 `vanilla`。
23
+ - 执行用户明确要求的删除、覆盖或恢复操作前,核对实例、文件路径或备份编号。工具返回待确认操作编号后,引导管理员在同一节点的 AI 助手 → MCP → 待确认操作中审批。用 `query_operation_status` 查询结果,避免重复提交。
24
+ - 使用 `create_mc_server` 部署整合包时,`package_local_path` 指 MSLX 宿主机上已有的 ZIP 文件,`package_url` 指 MSLX 宿主机可以访问的下载地址。Agent 客户端本机上的文件需要先由用户上传或提供可达的下载地址。
25
+
26
+ ## Minecraft 与 Java 版本对应准则 (Java Matrix)
27
+
28
+ 根据 Minecraft 游戏核心及服务端核心(Forge / NeoForge / Fabric / Paper / Spigot 等)的版本,严格匹配相应的 Java 运行环境:
29
+
30
+ | Minecraft / 核心版本 | 匹配 Java 大版本 | MSLX 运行环境标识 |
31
+ | :--- | :--- | :--- |
32
+ | **NeoForge 26.x / MC 26.1+** | **Java 25** (强制) | `MSLX://Java/25` |
33
+ | **MC 1.20.5 - 1.21.11** | **Java 21** (推荐) | `MSLX://Java/21` |
34
+ | **MC 1.18 - 1.20.4** | **Java 17** (推荐) | `MSLX://Java/17` |
35
+ | **MC 1.17 / 1.17.1** | **Java 16** (推荐) | `MSLX://Java/16` |
36
+ | **MC 1.13 - 1.16.5** | **Java 11** 或 **Java 8** | `MSLX://Java/11` / `MSLX://Java/8` |
37
+ | **MC 1.12.2 及更低旧版本** | **Java 8** (强制) | `MSLX://Java/8` |
38
+
39
+ ### Java 诊断与安装
40
+
41
+ - 排查启动失败时,结合日志、核心版本和 `query_java_environments` 判断运行环境。宿主机刚安装过 JDK 或列表可能过期时,使用 `force_rescan: true`。
42
+ - 需要部署匹配的 JDK 时,根据工具 schema 使用 `install_online_java`,或用 `update_instance_settings` 绑定相应的 `MSLX://Java/<大版本>`。绑定后按用户要求启动实例,并检查启动状态。
43
+
44
+ ---
45
+
46
+ ## 防御性备份与灾备恢复指南 (Backup-First Protocol)
47
+
48
+ 在管理游戏存档与关键数据时,务必恪守数据安全准则:
49
+ 1. **前置防御性备份**:
50
+ - 在执行重大破坏性操作前(如升级核心、批量删除/覆盖文件、更新迁移大型模组、调整深层世界生成参数),**主动询问并协助用户先行调用 `create_server_backup` 备份**!
51
+ 2. **完整回档还原黄金工作流**:
52
+ - **Step 1**:调用 `list_server_backups(server_id)` 获取历史备份列表供用户核对时间戳与文件名。
53
+ - **Step 2**:检查服务器状态,若在线则调用 `control_server(server_id, action="stop")` 停止服务器(Minecraft 运行中禁止直接解压覆盖世界存档)。
54
+ - **Step 3**:调用 `restore_server_backup(server_id, file_name)`,记录返回的操作编号。
55
+ - **Step 4**:管理员在同一节点的 AI 助手 → MCP → 待确认操作中确认,无需 API Key。系统自动执行,用 `query_operation_status` 查询状态,成功后再考虑开服。
56
+
57
+ ---
58
+
59
+ ## MSLX MCP 工具目录
60
+
61
+ 先调用 tools/list,以当前令牌实际可见的工具名和 inputSchema 为准。
62
+
63
+ ### 1. 实例生命周期与基础配置 (Instance & Config)
64
+ - `update_instance_settings`: 修改实例属性(绑定 Java、内存大小 `max_m`/`min_m`、核心文件名 `core`、JVM 参数 `args`、崩溃自启等)。
65
+ - `update_server_config`: 修改 `server.properties` 键值(如端口 `server-port`、正版验证 `online-mode`、难度 `difficulty`、PVP、最大玩家等)。
66
+ - `control_server`: 控制服务器电源状态,`action` 支持 `"start"`、`"stop"`、`"restart"`。
67
+ - `query_server_status`: 查询服务器实时状态(在线状态、PID、CPU 使用率、内存占用、启动耗时等)。
68
+ - `query_operation_status`: 按 `operation_id` 查询当前令牌提交的待审批操作及执行结果。
69
+ - `query_system_metrics`: 查询宿主机与实例的系统级性能指标(CPU/内存负载与磁盘状态)。
70
+
71
+ ### 2. 服务器部署与核心生态 (Deployment & Cores)
72
+ - `create_mc_server`: 全模式开服部署(在线镜像核心、本地/远程整合包 zip、MCDR 架构及自定义模式)。
73
+ - `query_available_server_cores`: 动态实时检索官方镜像站支持的服务端核心列表(支持 `vanilla`、`vanilla-snapshot`、`paper`、`neoforge`、`fabric` 等)。
74
+ - `query_creation_status`: 轮询后台开服/解压任务的进度百分比与日志。
75
+ - `agree_server_eula`: 自动将 `eula.txt` 写入 `eula=true`,解决开服首次启动协议阻塞。
76
+
77
+ ### 3. Java 运行环境编排 (Java Management)
78
+ - `query_java_environments`: 扫描宿主机已安装的 Java 环境列表(支持 `force_rescan: true` 强制全盘重扫)。
79
+ - `install_online_java`: 一键下载、校验并部署指定大版本 JDK(如 Java 8, 11, 16, 17, 21, 25)。
80
+
81
+ ### 4. 文件安全管理 (File Operations)
82
+ - `list_server_files`: 列出服务器目录或子目录(`plugins`、`mods`、`logs` 等)下的文件清单。
83
+ - `read_server_file`: 安全读取文本文件(采用 `FileShare.ReadWrite` 共享模式,运行态无锁读取)。
84
+ - `write_server_file`: 写入或修改配置文件(已存在文件会自动挂起触发前端授权卡片)。
85
+ - `delete_server_file`: 删除文件或目录(自动挂起触发前端二次确认卡片)。
86
+ - `copy_server_file`: 复制文件或目录(用于配置热备份与归档)。
87
+ - `move_server_file`: 移动或重命名文件(用于排错时重命名 `.jar.disabled`)。
88
+
89
+ ### 5. 诊断与指令交互 (Diagnostics & Commands)
90
+ - `read_server_log`: 读取 `logs/latest.log` 运行日志或 `crash-reports/` 最新崩溃报告。
91
+ - `send_server_command`: 向服务器控制台发送命令(如 `say`、`whitelist`、`time set day` 等)。
92
+
93
+ ### 6. 备份与灾备恢复 (Backup & Recovery)
94
+ - `create_server_backup`: 触发全量世界存档备份,生成 `mslx-backup_yyyyMMdd_HHmmss.zip`。
95
+ - `list_server_backups`: 查询历史备份列表、时间戳、物理路径与文件大小。
96
+ - `restore_server_backup`: 还原备份存档(不可逆覆盖操作,触发二次授权卡片)。
97
+ - `delete_server_backup`: 删除指定的旧备份文件。
98
+
99
+ ### 7. FRP 内网穿透与计划任务 (Frp & Automation)
100
+ - `query_frp_status`: 查询 FRP 穿透隧道列表与运行状态。
101
+ - `control_frp_tunnel`: 控制隧道启停(`start`/`stop`)或提取最近 50 条运行日志(`log`)。
102
+ - `manage_scheduled_tasks`: 定时任务调度(`list`/`create`/`delete`/`toggle`,支持备份、重启、指令执行等 Cron 任务)。
103
+
104
+ ### 8. 玩家与安全治理 (Player & Lifecycle Ops)
105
+ - `force_kill_server`: 服务器死锁时强制强杀进程。
106
+ - `delete_server_instance`: 彻底删除服务器实例(`delete_files=true` 时触发二次确认卡片)。
107
+ - `query_players`: 综合查询当前在线玩家、历史登录缓存与最后活动时间。
108
+ - `manage_whitelist`: 管理白名单(`list`/`add`/`remove`,热重载生效)。
109
+ - `manage_ops`: 管理 OP 管理员权限(`list`/`add`/`remove`,支持 1~4 级权限)。
110
+ - `manage_bans`: 管理封禁名单(`list`/`ban_player`/`unban_player`/`ban_ip`/`unban_ip`)。
111
+
112
+ ### 9. 模组、插件与资源生态 (Resource Ops)
113
+ - `search_mc_resources`: 统一聚合搜索 Modrinth 与 CurseForge 资源生态。
114
+ - `query_resource_versions`: 查询目标资源的版本兼容性、加载器适配与下载地址。
115
+ - `download_file_to_server`: 高速下载远程资源并落盘至 `mods/` 或 `plugins/`。
116
+ - `audit_client_only_mods`: 深度扫描 `mods/` 目录,精准检出客户端渲染独占模组,防止 Dedicated Server 启动崩溃。
117
+ - `manage_mod_plugin_state`: 管理模组/插件启用状态(`list`/`enable`/`disable`/`delete`)。
118
+ - `query_python_environments`: 扫描宿主机 Python 环境与 MCDR 安装状态。
119
+ - `extract_archive`: 高速解压 `.zip`、`.tar`、`.7z` 等归档包。
120
+ - `compress_files`: 打包目录或文件为 `.zip` 压缩包。
121
+ - `list_server_mods_plugins`: 列出模组与插件基础清单。
122
+
123
+ ---
124
+
125
+ ## 客户端接入
126
+
127
+ 从面板复制 MCP 配置,或查看 npm 包的 README 获取 Stdio 桥接示例。使用回环地址时,发起 MCP 连接的进程须与 MSLX 服务在同一台机器上。
package/bin/cli.js ADDED
@@ -0,0 +1,399 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MSLX Agent Skill & MCP Stdio-to-SSE Bridge CLI
5
+ *
6
+ * Features:
7
+ * 1. Stdio-to-SSE bridge: Reads JSON-RPC 2.0 requests from process.stdin,
8
+ * forwards to MSLX MCP endpoint via HTTP POST /mcp/message?sessionId=...,
9
+ * listens to SSE from /mcp/sse?token=..., and outputs JSON-RPC responses to process.stdout.
10
+ * 2. CLI options: --url <mcp_base_url>, --token <mcp_token>, --help, --version.
11
+ * 3. Subcommand: `mslx-agent-skill skill` prints out the entire SKILL.md.
12
+ */
13
+
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+ const http = require('http');
17
+ const https = require('https');
18
+ const readline = require('readline');
19
+ const { URL } = require('url');
20
+
21
+ const PKG_PATH = path.resolve(__dirname, '..', 'package.json');
22
+ const SKILL_PATH = path.resolve(__dirname, '..', 'SKILL.md');
23
+
24
+ let pkg = { version: '1.0.0' };
25
+ try {
26
+ pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
27
+ } catch (_) {}
28
+
29
+ function printHelp() {
30
+ console.log(`
31
+ MSLX Agent Skill & MCP Bridge (v${pkg.version})
32
+ Official Model Context Protocol (MCP) Bridge & Agent Skill for MSLX Minecraft Management
33
+
34
+ Usage:
35
+ mslx-agent-skill [command] [options]
36
+ mslx-mcp [command] [options]
37
+ npx @mslteam/mslx-agent-skill [command] [options]
38
+
39
+ Commands:
40
+ (no command) Run the Stdio-to-SSE MCP bridge for AI Agent integration
41
+ skill Print out the entire SKILL.md specification to stdout
42
+ install <skills-dir> Install the bundled Skill into the specified skills directory
43
+ version, --version Print package version
44
+ help, --help Show this help message
45
+
46
+ Options:
47
+ --url <url> MSLX MCP base endpoint URL
48
+ (default: http://localhost:25333/api/plugin/mslx-plugin-ai-agents/mcp)
49
+ --token <token> MSLX MCP authentication token
50
+ --debug Enable verbose debug logging to stderr
51
+
52
+ Environment Variables:
53
+ MSLX_MCP_URL MCP base endpoint URL
54
+ MSLX_MCP_TOKEN MCP authentication token
55
+
56
+ Supported Clients:
57
+ Google Antigravity, Cursor, Workbuddy, Qoder, Claude Desktop, Windsurf, Doubao
58
+ `);
59
+ }
60
+
61
+ function printVersion() {
62
+ console.log(pkg.version);
63
+ }
64
+
65
+ function printSkill() {
66
+ if (fs.existsSync(SKILL_PATH)) {
67
+ const content = fs.readFileSync(SKILL_PATH, 'utf8');
68
+ process.stdout.write(content);
69
+ } else {
70
+ process.stderr.write(`[ERROR] SKILL.md not found at ${SKILL_PATH}\n`);
71
+ process.exit(1);
72
+ }
73
+ }
74
+
75
+ if (process.argv[2] === 'install') {
76
+ try {
77
+ if (process.argv.length !== 4 || process.argv[3].startsWith('-')) {
78
+ throw new Error('Usage: mslx-agent-skill install <skills-dir>');
79
+ }
80
+ const skillDirectory = path.resolve(process.argv[3], 'mslx-agent-skill');
81
+ fs.mkdirSync(skillDirectory, { recursive: true });
82
+ const destination = path.join(skillDirectory, 'SKILL.md');
83
+ fs.copyFileSync(SKILL_PATH, destination, fs.constants.COPYFILE_EXCL);
84
+ console.log(destination);
85
+ } catch (error) {
86
+ console.error(error.code === 'EEXIST' ? 'SKILL.md already exists in the target directory.' : error.message);
87
+ process.exitCode = 1;
88
+ }
89
+ return;
90
+ }
91
+
92
+ // Parse command line arguments
93
+ const args = process.argv.slice(2);
94
+ let command = null;
95
+ let baseUrl = process.env.MSLX_MCP_URL || 'http://localhost:25333/api/plugin/mslx-plugin-ai-agents/mcp';
96
+ let token = process.env.MSLX_MCP_TOKEN || '';
97
+ let debug = false;
98
+
99
+ for (let i = 0; i < args.length; i++) {
100
+ const arg = args[i];
101
+ if (arg === 'help' || arg === '--help' || arg === '-h') {
102
+ printHelp();
103
+ process.exit(0);
104
+ } else if (arg === 'version' || arg === '--version' || arg === '-v') {
105
+ printVersion();
106
+ process.exit(0);
107
+ } else if (arg === 'skill') {
108
+ command = 'skill';
109
+ } else if (arg === '--url') {
110
+ baseUrl = args[++i] || baseUrl;
111
+ } else if (arg.startsWith('--url=')) {
112
+ baseUrl = arg.slice(6);
113
+ } else if (arg === '--token') {
114
+ token = args[++i] || token;
115
+ } else if (arg.startsWith('--token=')) {
116
+ token = arg.slice(8);
117
+ } else if (arg === '--debug') {
118
+ debug = true;
119
+ }
120
+ }
121
+
122
+ if (command === 'skill') {
123
+ printSkill();
124
+ process.exit(0);
125
+ }
126
+
127
+ function logDebug(...msg) {
128
+ if (debug) {
129
+ process.stderr.write(`[DEBUG] ${msg.join(' ')}\n`);
130
+ }
131
+ }
132
+
133
+ function logInfo(...msg) {
134
+ process.stderr.write(`[INFO] ${msg.join(' ')}\n`);
135
+ }
136
+
137
+ function logError(...msg) {
138
+ process.stderr.write(`[ERROR] ${msg.join(' ')}\n`);
139
+ }
140
+
141
+ // -------------------------------------------------------------
142
+ // Stdio-to-SSE Bridge Implementation
143
+ // -------------------------------------------------------------
144
+
145
+ let isReady = false;
146
+ let isShuttingDown = false;
147
+ let postUrl = null;
148
+ const messageQueue = [];
149
+ const emittedIds = new Set();
150
+ let sseReq = null;
151
+ let reconnectTimer = null;
152
+
153
+ function cleanupEmittedIds() {
154
+ if (emittedIds.size > 2000) {
155
+ const arr = Array.from(emittedIds);
156
+ for (let i = 0; i < 1000; i++) {
157
+ emittedIds.delete(arr[i]);
158
+ }
159
+ }
160
+ }
161
+
162
+ function getSseUrl() {
163
+ const normalized = baseUrl.replace(/\/+$/, '');
164
+ const sseObj = new URL(normalized + '/sse');
165
+ return sseObj;
166
+ }
167
+
168
+ function connectSse() {
169
+ if (isShuttingDown) return;
170
+
171
+ const sseUrlObj = getSseUrl();
172
+ logDebug(`Connecting to SSE endpoint: ${sseUrlObj.origin}${sseUrlObj.pathname}`);
173
+
174
+ const isHttps = sseUrlObj.protocol === 'https:';
175
+ const clientMod = isHttps ? https : http;
176
+
177
+ const headers = {
178
+ 'Accept': 'text/event-stream',
179
+ 'Cache-Control': 'no-cache',
180
+ 'Connection': 'keep-alive'
181
+ };
182
+ if (token) {
183
+ headers['Authorization'] = `Bearer ${token}`;
184
+ }
185
+
186
+ sseReq = clientMod.request(sseUrlObj, {
187
+ method: 'GET',
188
+ headers: headers
189
+ }, (res) => {
190
+ if (res.statusCode !== 200) {
191
+ logError(`SSE connection failed with HTTP status ${res.statusCode}`);
192
+ scheduleReconnect();
193
+ return;
194
+ }
195
+
196
+ logDebug('SSE connection established');
197
+ let buffer = '';
198
+
199
+ res.setEncoding('utf8');
200
+ res.on('data', (chunk) => {
201
+ buffer += chunk;
202
+ let boundaryIndex;
203
+ while ((boundaryIndex = buffer.indexOf('\n\n')) !== -1) {
204
+ const rawEvent = buffer.slice(0, boundaryIndex);
205
+ buffer = buffer.slice(boundaryIndex + 2);
206
+ handleSseBlock(rawEvent, sseUrlObj);
207
+ }
208
+ });
209
+
210
+ res.on('end', () => {
211
+ logDebug('SSE connection ended by server');
212
+ isReady = false;
213
+ postUrl = null;
214
+ scheduleReconnect();
215
+ });
216
+
217
+ res.on('error', (err) => {
218
+ logError(`SSE stream error: ${err.message}`);
219
+ isReady = false;
220
+ postUrl = null;
221
+ scheduleReconnect();
222
+ });
223
+ });
224
+
225
+ sseReq.on('error', (err) => {
226
+ logError(`SSE request connection error: ${err.message}`);
227
+ isReady = false;
228
+ postUrl = null;
229
+ scheduleReconnect();
230
+ });
231
+
232
+ sseReq.end();
233
+ }
234
+
235
+ function handleSseBlock(block, sseUrlObj) {
236
+ const lines = block.split(/\r?\n/);
237
+ let eventName = 'message';
238
+ let dataLines = [];
239
+
240
+ for (const line of lines) {
241
+ if (line.startsWith(':')) {
242
+ // Comment or keepalive ping, ignore
243
+ continue;
244
+ }
245
+ if (line.startsWith('event:')) {
246
+ eventName = line.slice(6).trim();
247
+ } else if (line.startsWith('data:')) {
248
+ dataLines.push(line.slice(5).trimStart());
249
+ }
250
+ }
251
+
252
+ const data = dataLines.join('\n');
253
+
254
+ if (eventName === 'endpoint') {
255
+ // Initial SSE endpoint message specifies where to send POST messages
256
+ const endpointUri = data.trim();
257
+ try {
258
+ const resolved = new URL(endpointUri, sseUrlObj);
259
+ if (resolved.origin !== sseUrlObj.origin) throw new Error('MCP endpoint changed origin');
260
+ postUrl = resolved.toString();
261
+ isReady = true;
262
+ logDebug('Received MCP message endpoint');
263
+ flushQueue();
264
+ } catch (err) {
265
+ logError(`Failed to resolve endpoint URL "${endpointUri}": ${err.message}`);
266
+ }
267
+ } else if (eventName === 'message' || (!eventName && data)) {
268
+ // Standard JSON-RPC response or notification
269
+ if (data && data.trim()) {
270
+ handleIncomingJsonRpc(data.trim());
271
+ }
272
+ }
273
+ }
274
+
275
+ function handleIncomingJsonRpc(jsonStr) {
276
+ try {
277
+ const parsed = JSON.parse(jsonStr);
278
+ if (parsed.id !== undefined && parsed.id !== null) {
279
+ if (emittedIds.has(parsed.id)) {
280
+ return; // Avoid duplicate emission
281
+ }
282
+ emittedIds.add(parsed.id);
283
+ cleanupEmittedIds();
284
+ }
285
+ } catch (_) {}
286
+
287
+ // Forward JSON-RPC message directly to stdout
288
+ process.stdout.write(jsonStr + '\n');
289
+ }
290
+
291
+ function scheduleReconnect() {
292
+ if (isShuttingDown || reconnectTimer) return;
293
+ reconnectTimer = setTimeout(() => {
294
+ reconnectTimer = null;
295
+ connectSse();
296
+ }, 2500);
297
+ }
298
+
299
+ function flushQueue() {
300
+ while (isReady && postUrl && messageQueue.length > 0) {
301
+ const nextMsg = messageQueue.shift();
302
+ sendPost(nextMsg);
303
+ }
304
+ }
305
+
306
+ function sendPost(payload) {
307
+ if (!postUrl) {
308
+ messageQueue.push(payload);
309
+ return;
310
+ }
311
+
312
+ try {
313
+ const targetUrl = new URL(postUrl);
314
+ const isHttps = targetUrl.protocol === 'https:';
315
+ const clientMod = isHttps ? https : http;
316
+ const body = Buffer.from(payload, 'utf8');
317
+
318
+ const headers = {
319
+ 'Content-Type': 'application/json',
320
+ 'Content-Length': body.length,
321
+ };
322
+ if (token) {
323
+ headers['Authorization'] = `Bearer ${token}`;
324
+ }
325
+
326
+ const req = clientMod.request(targetUrl, {
327
+ method: 'POST',
328
+ headers: headers
329
+ }, (res) => {
330
+ let resData = '';
331
+ res.setEncoding('utf8');
332
+ res.on('data', (chunk) => {
333
+ resData += chunk;
334
+ });
335
+ res.on('end', () => {
336
+ if (res.statusCode >= 200 && res.statusCode < 300) {
337
+ const trimmed = resData.trim();
338
+ if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
339
+ try {
340
+ const parsed = JSON.parse(trimmed);
341
+ if (parsed.jsonrpc === '2.0') {
342
+ handleIncomingJsonRpc(trimmed);
343
+ }
344
+ } catch (_) {}
345
+ }
346
+ } else if (res.statusCode >= 400) {
347
+ logError(`POST returned status ${res.statusCode}: ${resData}`);
348
+ }
349
+ });
350
+ });
351
+
352
+ req.on('error', (err) => {
353
+ logError(`Failed to send POST request: ${err.message}`);
354
+ });
355
+
356
+ req.write(body);
357
+ req.end();
358
+ } catch (err) {
359
+ logError(`Error preparing POST request: ${err.message}`);
360
+ }
361
+ }
362
+
363
+ // Setup stdin reader for JSON-RPC requests from Agent
364
+ const rl = readline.createInterface({
365
+ input: process.stdin,
366
+ output: null,
367
+ terminal: false
368
+ });
369
+
370
+ rl.on('line', (line) => {
371
+ const trimmed = line.trim();
372
+ if (!trimmed) return;
373
+
374
+ if (isReady && postUrl) {
375
+ sendPost(trimmed);
376
+ } else {
377
+ messageQueue.push(trimmed);
378
+ }
379
+ });
380
+
381
+ rl.on('close', () => {
382
+ shutdown();
383
+ });
384
+
385
+ function shutdown() {
386
+ if (isShuttingDown) return;
387
+ isShuttingDown = true;
388
+ if (reconnectTimer) clearTimeout(reconnectTimer);
389
+ if (sseReq) {
390
+ try { sseReq.destroy(); } catch (_) {}
391
+ }
392
+ process.exit(0);
393
+ }
394
+
395
+ process.on('SIGINT', shutdown);
396
+ process.on('SIGTERM', shutdown);
397
+
398
+ // Start SSE connection
399
+ connectSse();
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@mslteam/mslx-agent-skill",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "MSLX 官方 Minecraft 服务器运维与全平台 MCP 协议桥接 Agent Skill(支持 Google Antigravity、Cursor、Workbuddy、Qoder、Claude Desktop、Windsurf、豆包等)",
5
+ "main": "bin/cli.js",
6
+ "bin": {
7
+ "mslx-agent-skill": "bin/cli.js",
8
+ "mslx-mcp": "bin/cli.js"
9
+ },
10
+ "files": [
11
+ "SKILL.md",
12
+ "README.md",
13
+ "bin/cli.js",
14
+ "LICENSE"
15
+ ],
16
+ "keywords": [
17
+ "mslx",
18
+ "mslx-mcp",
19
+ "minecraft",
20
+ "minecraft-server",
21
+ "mcp",
22
+ "model-context-protocol",
23
+ "antigravity",
24
+ "agent-skill",
25
+ "skills",
26
+ "cursor",
27
+ "claude-desktop",
28
+ "workbuddy",
29
+ "qoder",
30
+ "doubao",
31
+ "windsurf"
32
+ ],
33
+ "author": "MSLTeam <ljy.xiaoyu@qq.com>",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/MSLTeam/mslx-agent-skill.git"
38
+ },
39
+ "scripts": {
40
+ "test": "node bin/cli.js --help",
41
+ "publish-both": "node bin/publish-both.js",
42
+ "publish:both": "node bin/publish-both.js"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
47
+ "publishConfig": {
48
+ "registry": "https://registry.npmjs.org/",
49
+ "access": "public"
50
+ }
51
+ }