Feature: Add window info RPC for foreground checks and window activation
Add a capability-gated main-connection RPC (COMMAND_MCP_WINDOW_INFO=179 / TOKEN_MCP_WINDOW_INFO=180) that returns visible top-level windows with UTF-8 titles, screen rectangles, foreground flag and z-order, so MCP can verify focus before injecting input. New tool get_foreground_window; host_list_windows switches to the richer fields; host_control_window and operate_window gain action=activate; remote_keyboard and remote_mouse gain expect_hwnd, require_foreground and report_foreground. Old clients keep the previous behavior: the RPC is refused up front via CLIENT_CAP_WINDOW_INFO. The client caps a response at 96 windows (about 101 KB, under MAX_SEND_BUFFER). Signal the cut-off in the mode byte (0x80) instead of silently dropping windows: host_list_windows now reports truncated=true and says the list is incomplete, and activate verification reports state=unknown with reason=list_truncated rather than claiming the window is gone. expect_hwnd is checked only after the session is validated, so an invalid session_id no longer burns a window RPC and no longer reports a window error for a session that does not exist. Nullable output fields (foreground, window) are declared as ["object","null"] so strict clients do not reject responses. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
c7e23f750d
commit
b2c0d81396
18 files changed
+1298
-68
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# MCP 工具清单维护
|
||||
|
||||
`mcp/tools.json` 是 MCP 全部 60 个工具的**单一来源候选**:工具名、描述、
|
||||
`mcp/tools.json` 是 MCP 全部 61 个工具的**单一来源候选**:工具名、描述、
|
||||
inputSchema、outputSchema,以及运行时不可见的开关元信息(`gate` / `write` / `manage`)。
|
||||
|
||||
它的用途不限于给 Go 服务端复用。当前 26KB 的工具描述埋在 11k 行 C++ 里,
|
||||
@@ -35,7 +35,7 @@ python tools/mcp_tools/make_tools_json.py /tmp/tools_raw.json mcp/tools.json
|
||||
python tools/mcp_tools/verify_tools.py --live mcp/tools.json
|
||||
```
|
||||
|
||||
第 3 步输出 `PASS: 60 个工具完全一致` 才算成功。
|
||||
第 3 步输出 `PASS: 61 个工具完全一致` 才算成功。
|
||||
|
||||
### 如果工具数量变了
|
||||
|
||||
@@ -49,7 +49,7 @@ python tools/mcp_tools/verify_tools.py --live mcp/tools.json
|
||||
这是有意为之——`gate` / `write` / `manage` 三项在运行时不可见,只能从 C++
|
||||
注册点的 `if` 条件读出来,必须人工确认。补表时对照:
|
||||
|
||||
- `McpServer.cpp:BuildToolsListResult` —— 内联的 40 个
|
||||
- `McpServer.cpp:BuildToolsListResult` —— 内联的 41 个
|
||||
- `McpMachine.cpp:AppendTools` —— 16 个(总开关 `IsMachineEnabled` 用 early return)
|
||||
- `McpChat.cpp:AppendTools` —— 4 个(总开关 `IsChatEnabled` 用 early return)
|
||||
|
||||
@@ -87,14 +87,14 @@ 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` |
|
||||
|
||||
当前分布(60 个工具):
|
||||
当前分布(61 个工具):
|
||||
|
||||
| platforms | 数量 | 典型工具 |
|
||||
|---|---|---|
|
||||
| `win+lnx+mac+apk` | 10 | 只读写服务端本地数据:`list_online_hosts` / `get_audit_log` / `mcp_*` |
|
||||
| `win+lnx+mac` | 6 | 进程列表、文件列取、日志、V2 文件传输、`copy_files_c2c` |
|
||||
| `win+lnx` | 11 | `remote_*` 全族、`get_screenshot`、`exec_command` / `terminal_*` / `kill_process` |
|
||||
| `win` | 33 | 服务 / 注册表 / 键日志 / 文件写 / **`list_windows`** / `host_*` / `chat_*` / `power_action` |
|
||||
| `win+lnx` | 12 | `remote_*` 全族、`get_screenshot`、`get_activity_history`、`exec_command` / `terminal_*` / `kill_process` |
|
||||
| `win` | 33 | 服务 / 注册表 / 键日志 / 文件写 / **`list_windows`** / `get_foreground_window` / `host_*` / `chat_*` / `power_action` |
|
||||
|
||||
**注意 `exec_command` / `terminal_*` / `kill_process` 不在 `win+lnx+mac` 组**:
|
||||
macOS 客户端其实有对应实现(`macos/main.mm:753` 的 `ShellworkingThread` 跑 PTY,
|
||||
@@ -186,7 +186,7 @@ macOS 客户端其实有对应实现(`macos/main.mm:753` 的 `ShellworkingThre
|
||||
|
||||
```bash
|
||||
python tools/mcp_tools/check_platform_table.py
|
||||
# PASS: 60 个工具的 platforms 两边完全一致,且门禁都能拿到主机 id
|
||||
# PASS: 61 个工具的 platforms 两边完全一致,且门禁都能拿到主机 id
|
||||
```
|
||||
|
||||
## 与 Go 服务端的关系
|
||||
|
||||
@@ -29,6 +29,7 @@ GATE = {
|
||||
"list_windows": (None, False, False),
|
||||
"get_activity_history": (None, False, False),
|
||||
"get_screenshot": (None, False, False),
|
||||
"get_foreground_window": (None, False, False),
|
||||
"list_files": (None, False, False),
|
||||
"list_services": (None, False, False),
|
||||
"get_client_log": (None, False, False),
|
||||
@@ -177,7 +178,8 @@ PLATFORMS = {
|
||||
"control_service": _WIN,
|
||||
"list_registry": _WIN,
|
||||
"get_keylog": _WIN,
|
||||
"get_activity_history": _WIN,
|
||||
"get_activity_history": _WL, # Windows 前台窗口;Linux 桌面/无桌面均有实现(linux/main.cpp)
|
||||
"get_foreground_window": _WIN, # 窗口信息 RPC:CLIENT_CAP_WINDOW_INFO,仅 Windows 客户端声明
|
||||
"search_file": _WIN,
|
||||
"delete_path": _WIN,
|
||||
"move_path": _WIN,
|
||||
|
||||
Reference in new issue
Block a user