Feature: add build_client MCP tool and improve build dialog linkage

Add a service-local MCP tool, build_client, that patches a client template
with this master's connect settings and writes the binary on the server.
It covers ghost/TestRun/ServerDll/TinyRun plus Linux, macOS and Android,
reusing the same byte path as CBuildDlg::OnBnClickedOk (CONNECT_ADDRESS
overwrite, build-date check, embedded TLS anchor before UPX/padding).
ShellCode AES and payload impersonation stay dialog-only.

The tool is gated by a new McpBuild switch (default 0) and McpReadonly=0.
It refuses to overwrite an existing file unless overwrite=true, protects
the server binaries/settings.ini/upx.exe, validates names strictly and
uses a unique UPX temp file so it cannot race the dialog. Results report
the path, size, target, TLS-anchor status and follow-up tips.

In the build dialog, Linux/macOS/Android targets now also grey out the
install-location combo/label and run mode, save and restore the Windows
compress choice, hide payload/download rows, grey the random-name and
run-as-admin menu items, and fix the TLS-anchor label for posix targets.
OnBnClickedOk is untouched; generated output is unchanged for every target.

New UI strings were added to the en_US, zh_TW and de_DE language packs.
McpBuild is off by default and changes require a server restart.
Verified on a Debug x64 instance: MCP generation for Linux is patched
correctly, Android and ghost anchor/error paths behave, and dialog-driven
Linux/TestRun/SC_AES generation still succeeds. mcp/tools.json regenerated
(55 tools); check_platform_table.py passes.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-15 20:43:28 +01:00
1 parent 1401ff0a4c
commit 7172ab376d
20 files changed
+1619 -36

No files matched your search

+16 -10
View File
@@ -1,6 +1,6 @@
# MCP 工具清单维护
`mcp/tools.json` 是 MCP 全部 61 个工具的**单一来源候选**:工具名、描述、
`mcp/tools.json` 是 MCP 全部 55 个工具的**单一来源候选**:工具名、描述、
inputSchema、outputSchema,以及运行时不可见的开关元信息(`gate` / `write` / `manage`)。
它的用途不限于给 Go 服务端复用。当前 26KB 的工具描述埋在 11k 行 C++ 里,
@@ -20,23 +20,28 @@ inputSchema、outputSchema,以及运行时不可见的开关元信息(`gate`
## 更新流程
改动 C++ 里的工具定义(`McpServer.cpp` / `McpMachine.cpp` / `McpChat.cpp`)之后:
改动 C++ 里的工具定义(`McpServer.cpp` / `McpMachine.cpp` / `McpChat.cpp` /
`McpBuildClient.cpp`)之后:
```bash
# 0. 先重编并启动主控端,确保服务端跑的是新代码
cd C:/github/YAMA
# 1. 抓取(token 自动从注册表读;端口自动探测 6545/6544)
python tools/mcp_tools/dump_tools.py "" /tmp/tools_raw.json
# 清单是「McpMachine=1」与「McpMachine=0」两份抓取的并集,需在两次抓取之间
# 改配置并重启服务端(关闭态那份包含 5 个降级工具)。
python tools/mcp_tools/dump_tools.py "" /tmp/tools_raw_on.json
# ...把 McpMachine 改成 0、重启服务端...
python tools/mcp_tools/dump_tools.py "" /tmp/tools_raw_off.json
# 2. 生成
python tools/mcp_tools/make_tools_json.py /tmp/tools_raw.json mcp/tools.json
# 2. 生成(第三参数是关闭主机管理时的抓取)
python tools/mcp_tools/make_tools_json.py /tmp/tools_raw_on.json mcp/tools.json /tmp/tools_raw_off.json
# 3. 校验
python tools/mcp_tools/verify_tools.py --live mcp/tools.json
```
第 3 步输出 `PASS: 61 个工具完全一致` 才算成功。
第 3 步输出 `PASS: 55 个工具完全一致` 才算成功。
### 如果工具数量变了
@@ -53,6 +58,7 @@ python tools/mcp_tools/verify_tools.py --live mcp/tools.json
- `McpServer.cpp:BuildToolsListResult` —— 内联的 41 个
- `McpMachine.cpp:AppendTools` —— 16 个(总开关 `IsMachineEnabled` 用 early return)
- `McpChat.cpp:AppendTools` —— 4 个(总开关 `IsChatEnabled` 用 early return)
- `McpBuildClient.cpp:AppendTools` —— 1 个(开关 `McpBuild` 用 early return)
`PLATFORMS` 还要额外核对各平台客户端有没有实现对应命令,见下节。
@@ -60,8 +66,8 @@ python tools/mcp_tools/verify_tools.py --live mcp/tools.json
| 字段 | 含义 |
|---|---|
| `gate` | 该工具出现所需的开关(`null` = 无条件)。取值:`machine` / `chat` / `terminal` / `remote_control` / `file_transfer` / `file_write` / `keylog` / `manage` |
| `write` | 需要 `!McpReadonly` |
| `gate` | 该工具出现所需的开关(`null` = 无条件)。取值:`machine` / `chat` / `terminal` / `remote_control` / `file_transfer` / `file_write` / `keylog` / `manage` / `build` |
| `write` | 执行需要 `!McpReadonly`(只影响调用,不影响可见性;只改服务端本地数据的工具在只读下仍会列出) |
| `manage` | 额外需要 `McpManage`(仅 `kill_network_connection` 用到) |
| `platforms` | 该工具涉及的**任一主机**都必须落在此集合内:`win` / `lnx` / `mac` / `apk` |
| `roles` | 仅多主机工具才有。按参数名细分平台,表达 `platforms` 说不清的方向性能力 |
@@ -88,7 +94,7 @@ python tools/mcp_tools/verify_tools.py --live mcp/tools.json
| 命令分支 | `client/`、`linux/main.cpp`、`macos/main.mm`、`android/app/src/main/cpp/main.cpp` |
| 能力位 | `common/commands.h` 的 `LOGIN_INFOR::DefaultCaps()`;Linux 另在 `linux/main.cpp:RefreshLoginCaps` 追加 `SCREEN_PREVIEW` |
当前分布(54 个工具):
当前分布(55 个工具):
| platforms | 数量 | 典型工具 |
|---|---|---|
@@ -191,7 +197,7 @@ macOS 客户端其实有对应实现(`macos/main.mm:753` 的 `ShellworkingThre
```bash
python tools/mcp_tools/check_platform_table.py
# PASS: 61 个工具的 platforms 两边完全一致,且门禁都能拿到主机 id
# PASS: 55 个工具的 platforms 两边完全一致,且门禁都能拿到主机 id
```
## 与 Go 服务端的关系
+5
View File
@@ -114,6 +114,9 @@ GATE = {
"chat_send": ("chat", False, False),
"chat_wait": ("chat", False, False),
"chat_close": ("chat", False, False),
# ---- 生成客户端(McpBuild,写服务端本机文件;另需 readonly 关)----
"build_client": ("build", True, False),
}
# platforms: 该工具涉及的任一主机都必须落在此集合内。
@@ -160,6 +163,8 @@ PLATFORMS = {
"mcp_cancel_session": _APK,
"host_set_remark": _APK,
"host_set_watch_level": _APK,
# 生成客户端只写服务端本机文件,不触达任何主机;与客户端平台无关。
"build_client": _APK,
# SYSTEM / LIST_DRIVE / QUERY_LOG:三个桌面平台都实现了;APK 也实现了 QUERY_LOG
# (android/.../main.cpp ClientLogThread → TOKEN_REPORT_LOG)