diff --git a/mcp/tools.json b/mcp/tools.json index 157813a..e442d79 100644 --- a/mcp/tools.json +++ b/mcp/tools.json @@ -15,11 +15,11 @@ ], "version": 2, "protocolVersion": "2025-06-18", - "toolCount": 65, + "toolCount": 63, "tools": [ { - "name": "list_online_hosts", - "description": "获取当前所有在线主机的列表,包含计算机名、IP、操作系统、版本、备注、分组、活动窗口、延迟等实时信息。可选 group / os / client_type 三个过滤条件(均可选、AND 组合、子串匹配、ASCII 不区分大小写),过滤在分页之前生效:total 为命中台数,totalAll 为全部在线台数。结果按 limit/offset 分页(默认 100 条,上限 1000),hasMore 表示还有下一页。tls=true 表示该客户端登录时使用了 TLS 加密传输(登录时上报,非实时探测;老客户端恒为 false)。", + "name": "list_hosts", + "description": "列主机:默认只返回在线主机(含计算机名、IP、操作系统、版本、备注、分组、活动窗口、延迟等实时信息),include_offline=true 时连离线主机(历史连接过、当前未连接,来自主机列表记录)一起返回,在线主机排在最前面。query 子串匹配计算机名/备注/IP;group / os / client_type 为附加过滤条件(均可选、AND 组合、子串匹配、ASCII 不区分大小写);online=false 只看离线主机。过滤在分页之前生效:total 为命中台数,totalAll 为过滤前的主机库台数。结果按 limit/offset 分页(默认 100 条,上限 1000),hasMore 表示还有下一页。离线主机另有 last_seen(最后一次登录时间)、install_time 字段,但没有 rtt/version/activeWindow 等实时字段,也没有 clientType(按平台筛历史主机请用 os),group 恒为 default。authStatus 为主机授权状态(unauthorized/authorized_by_super/authorized_by_admin/forbidden)。tls=true 表示该客户端登录时使用了 TLS 加密传输(登录时上报,老客户端恒为 false)。", "gate": null, "platforms": [ "win", @@ -38,122 +38,12 @@ "description": "按分组过滤(子串,不区分大小写)。省略则不过滤。", "type": "string" }, - "limit": { - "description": "本次最多返回的条数,默认 100,上限 1000。", - "type": "integer" - }, - "offset": { - "description": "跳过前 N 条,默认 0;配合返回的 total/hasMore 翻页。", - "type": "integer" - }, - "os": { - "description": "按操作系统过滤(子串,不区分大小写,如 Windows、Linux、Android)。省略则不过滤。", - "type": "string" - } - }, - "required": [], - "type": "object" - }, - "outputSchema": { - "properties": { - "hasMore": { + "include_offline": { + "description": "是否把离线主机一起返回,默认 false(只给在线);online=false 时无意义。list_all_hosts 别名默认 true。", "type": "boolean" }, - "hosts": { - "items": { - "properties": { - "activeWindow": { - "type": "string" - }, - "authStatus": { - "type": "string" - }, - "clientType": { - "type": "string" - }, - "group": { - "type": "string" - }, - "id": { - "type": "string" - }, - "install_time": { - "type": "string" - }, - "ip": { - "type": "string" - }, - "last_seen": { - "type": "string" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "online": { - "type": "boolean" - }, - "os": { - "type": "string" - }, - "remark": { - "type": "string" - }, - "rtt": { - "type": "string" - }, - "screen": { - "type": "string" - }, - "tls": { - "type": "boolean" - }, - "version": { - "type": "string" - } - }, - "type": "object" - }, - "type": "array" - }, - "limit": { - "type": "integer" - }, - "offset": { - "type": "integer" - }, - "total": { - "type": "integer" - }, - "totalAll": { - "type": "integer" - } - }, - "required": [ - "hosts" - ], - "type": "object" - } - }, - { - "name": "search_hosts", - "description": "按计算机名/备注、IP、分组、操作系统过滤主机。所有条件均可选、按 AND 组合;子串匹配(ASCII 不区分大小写)。online=true 只返回在线主机,online=false 只返回离线主机(曾连接过、当前未连接),省略时只返回在线主机。离线主机的 group 恒为 default,last_seen 为最后一次登录时间;两类都要请用 list_all_hosts。结果按 limit/offset 分页(默认 100 条,上限 1000),total 为匹配总数。tls=true 表示该客户端登录时使用了 TLS 加密传输(登录时上报,老客户端恒为 false)。", - "gate": null, - "platforms": [ - "win", - "lnx", - "mac", - "apk" - ], - "impl": "mfc", - "inputSchema": { - "properties": { - "group": { - "type": "string" - }, "ip": { + "description": "只按 IP 过滤(search_hosts 的旧参数);与 query 同时给出时两者都需满足。", "type": "string" }, "limit": { @@ -161,6 +51,7 @@ "type": "integer" }, "name": { + "description": "只按计算机名/备注过滤(search_hosts 的旧参数);与 query 同时给出时两者都需满足。", "type": "string" }, "offset": { @@ -168,137 +59,16 @@ "type": "integer" }, "online": { - "type": "boolean" - }, - "os": { - "type": "string" - } - }, - "type": "object" - }, - "outputSchema": { - "properties": { - "hasMore": { - "type": "boolean" - }, - "hosts": { - "items": { - "properties": { - "activeWindow": { - "type": "string" - }, - "authStatus": { - "type": "string" - }, - "clientType": { - "type": "string" - }, - "group": { - "type": "string" - }, - "id": { - "type": "string" - }, - "install_time": { - "type": "string" - }, - "ip": { - "type": "string" - }, - "last_seen": { - "type": "string" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "online": { - "type": "boolean" - }, - "os": { - "type": "string" - }, - "remark": { - "type": "string" - }, - "rtt": { - "type": "string" - }, - "screen": { - "type": "string" - }, - "tls": { - "type": "boolean" - }, - "version": { - "type": "string" - } - }, - "type": "object" - }, - "type": "array" - }, - "limit": { - "type": "integer" - }, - "offset": { - "type": "integer" - }, - "total": { - "type": "integer" - }, - "totalAll": { - "type": "integer" - } - }, - "required": [ - "hosts" - ], - "type": "object" - } - }, - { - "name": "list_all_hosts", - "description": "列出服务端已知的全部主机:在线主机(实时信息)与离线主机(历史连接过、当前未连接,来自主机列表记录)。在线主机字段同 list_online_hosts;离线主机另有 last_seen(最后一次登录时间)、install_time 字段,但没有 rtt/version/activeWindow 等实时字段,也没有 clientType。authStatus 为主机授权状态(unauthorized/authorized_by_super/authorized_by_admin/forbidden)。默认两类都返回;可选 group / os / client_type 过滤(AND 组合、子串匹配、ASCII 不区分大小写),过滤在分页之前生效:total 为命中台数,totalAll 为主机库总数。结果按 limit/offset 分页(默认 100 条,上限 1000)。", - "gate": null, - "platforms": [ - "win", - "lnx", - "mac", - "apk" - ], - "impl": "mfc", - "inputSchema": { - "properties": { - "client_type": { - "description": "按客户端类型过滤(子串,不区分大小写,如 EXE、LNX、MAC)。离线主机没有该字段,不会命中。省略则不过滤。", - "type": "string" - }, - "group": { - "description": "按分组过滤(子串,不区分大小写)。省略则不过滤。", - "type": "string" - }, - "limit": { - "description": "本次最多返回的条数,默认 100,上限 1000。", - "type": "integer" - }, - "offline": { - "description": "是否包含离线主机(历史连接过、当前未连接的),默认 true", - "type": "boolean" - }, - "offset": { - "description": "跳过前 N 条,默认 0;配合返回的 total/hasMore 翻页。", - "type": "integer" - }, - "online": { - "description": "是否包含在线主机,默认 true", + "description": "true(默认)返回在线主机;false 只返回离线主机(历史连接过、当前未连接)。", "type": "boolean" }, "os": { "description": "按操作系统过滤(子串,不区分大小写,如 Windows、Linux、Android)。省略则不过滤。", "type": "string" + }, + "query": { + "description": "关键字:子串匹配计算机名、备注或 IP(ASCII 不区分大小写)。省略则不过滤。", + "type": "string" } }, "type": "object" @@ -412,7 +182,7 @@ ], "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一", + "description": "主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一", "type": "string" }, "ids": { @@ -613,7 +383,7 @@ ], "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一", + "description": "主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一", "type": "string" }, "ids": { @@ -770,7 +540,7 @@ ], "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一", + "description": "主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一", "type": "string" }, "ids": { @@ -929,7 +699,7 @@ ], "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一", + "description": "主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一", "type": "string" }, "ids": { @@ -1071,7 +841,7 @@ ] }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "max_width": { @@ -1173,7 +943,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" } }, @@ -1270,7 +1040,7 @@ ], "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "ids": { @@ -1446,7 +1216,7 @@ ], "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一", + "description": "主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一", "type": "string" }, "ids": { @@ -1605,7 +1375,7 @@ "type": "string" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一", + "description": "主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一", "type": "string" }, "ids": { @@ -1731,7 +1501,7 @@ "type": "integer" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "max_bytes": { @@ -2024,7 +1794,7 @@ ], "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一", + "description": "主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一", "type": "string" }, "ids": { @@ -2156,7 +1926,7 @@ "type": "string" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "timeout_ms": { @@ -2202,7 +1972,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "timeout_ms": { @@ -2255,7 +2025,7 @@ "type": "string" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "max_output_bytes": { @@ -2337,7 +2107,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "session_id": { @@ -2378,7 +2148,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "region": { @@ -2488,7 +2258,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "session_id": { @@ -2540,7 +2310,7 @@ ] }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "key": { @@ -2651,7 +2421,7 @@ ] }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "report_foreground": { @@ -2742,7 +2512,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "session_id": { @@ -2778,7 +2548,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "session_id": { @@ -2814,7 +2584,7 @@ "type": "boolean" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "max_block_ms": { @@ -2870,7 +2640,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "local_dir": { @@ -2943,7 +2713,7 @@ "type": "string" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "limit": { @@ -3051,7 +2821,7 @@ "type": "object" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "max_bytes": { @@ -3157,7 +2927,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "local_path": { @@ -3259,7 +3029,7 @@ "type": "array" }, "src_id": { - "description": "源主机 id(文件从这里发出),取 list_online_hosts / search_hosts 返回的 id", + "description": "源主机 id(文件从这里发出),取 list_hosts 返回的 id", "type": "string" }, "timeout_ms": { @@ -3325,7 +3095,7 @@ "type": "boolean" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "pids": { @@ -3391,7 +3161,7 @@ "type": "integer" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" } }, @@ -3454,7 +3224,7 @@ "type": "string" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "service_name": { @@ -3494,7 +3264,7 @@ "type": "string" }, "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "wait": { @@ -3553,7 +3323,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id,取 list_online_hosts / search_hosts 返回的 id 字段", + "description": "主机 id,取 list_hosts 返回的 id 字段", "type": "string" }, "wait": { @@ -3609,7 +3379,7 @@ "inputSchema": { "properties": { "id": { - "description": "主机 id(list_online_hosts / list_all_hosts 返回的十进制字符串)。", + "description": "主机 id(list_hosts 返回的十进制字符串)。", "type": "string" }, "remark": { diff --git a/server/2015Remote/McpServer.cpp b/server/2015Remote/McpServer.cpp index 1dc2fbc..69ede1a 100644 --- a/server/2015Remote/McpServer.cpp +++ b/server/2015Remote/McpServer.cpp @@ -277,7 +277,7 @@ const char* kServerInstructions = u8"\n" u8"1) 主机 id\n" u8"id 是 64 位无符号十进制字符串,由服务端分配,无法从 IP 或计算机名推算,不要猜测、也不要把示例值当真。" - u8"需要 id 时先用 list_online_hosts(仅在线)或 list_all_hosts(含离线)取得;离线主机除 " + u8"需要 id 时先用 list_hosts 取得(默认只列在线;include_offline=true 连离线一起列);离线主机除 " u8"host_set_remark、host_set_watch_level 外都不能操作。拿不到 id 就向用户确认。\n" u8"\n" u8"2) 工具的可见性与开关\n" @@ -335,7 +335,7 @@ const char* kServerInstructions = u8"\n" u8"5) 客户端平台差异\n" u8"工具能否执行取决于目标主机的平台,这与服务端开关无关,两者是叠加关系。调用前用 " - u8"list_online_hosts / get_host_detail 的 capabilities.platform 确认,宁可先查一次,不要先试后错。\n" + u8"list_hosts / get_host_detail 的 capabilities.platform 确认,宁可先查一次,不要先试后错。\n" u8"支持面从宽到窄依次是 win > lnx > apk ≈ mac:Windows 是唯一全量支持的平台,Linux 次之," u8"Android 与 macOS 只覆盖一部分(Android 偏远程控制与截屏,macOS 偏文件与进程)。拿不准时按这个顺序假设。\n" u8"win(EXE / DLL / MEXE / SC / MDLL):全部工具可用。\n" @@ -350,7 +350,7 @@ const char* kServerInstructions = u8"exec_command、terminal_open / terminal_exec / terminal_close" u8"(客户端有 PTY 实现,但服务端本轮未开放)、kill_process、http_probe;" u8"文件传输、进程列表、日志可用。\n" - u8"apk(APK):支持主机列表(list_online_hosts / list_all_hosts)/ 详情 / 搜索 / " + u8"apk(APK):支持主机列表(list_hosts)/ 详情 / 搜索 / " u8"审计日志 / 服务状态 / 会话管理、运行日志(get_client_log)、活动历史" u8"(get_activity_history,前台应用停留记录)、截屏(get_screenshot,只支持 mode=screen," u8"要靠无障碍服务 takeScreenshot,Android 11+ 且开启无障碍才行),远程控制全族" @@ -916,8 +916,8 @@ void CollectAllHosts(CMy2015RemoteDlg* parent, Json::Value& hosts, LeaveCriticalSection(&parent->m_cs); } -// ===== C3:list_online_hosts / list_all_hosts 的公共过滤 ===== -// 口径与 search_hosts 一致:条件都可选、AND 组合、子串匹配、ASCII 不区分大小写。 +// ===== C3:list_hosts 的公共过滤 ===== +// 口径与 list_hosts 一致:条件都可选、AND 组合、子串匹配、ASCII 不区分大小写。 // 只过滤已有字段,不额外拉取主机数据;离线主机没有 clientType(历史记录里不存), // 所以带 client_type 条件时离线主机不会命中——需要按平台筛历史主机请用 os。 struct HostListFilter { @@ -1006,7 +1006,7 @@ void AppendPageOutputProps(Json::Value& props) { props["hasMore"] = moreProp; } -// list_online_hosts / search_hosts 的 outputSchema(hosts 数组) +// list_hosts 的 outputSchema(hosts 数组) Json::Value BuildHostOutputSchema() { Json::Value props(Json::objectValue); @@ -1081,40 +1081,35 @@ Json::Value BuildHostDetailOutputSchema() { return schema; } -// search_hosts 的 inputSchema(全部可选) -Json::Value BuildSearchHostsInputSchema() { +// list_hosts 的 inputSchema(P1-1:三个主机列表工具合并;全部可选) +// 旧名 list_online_hosts / search_hosts / list_all_hosts 作为别名保留,参数在这里一并声明。 +Json::Value BuildListHostsInputSchema() { Json::Value props(Json::objectValue); - const char* strParams[] = { "name", "ip", "group", "os" }; - for (const char* p : strParams) { - Json::Value s(Json::objectValue); - s["type"] = "string"; - props[p] = s; - } - Json::Value onlineProp(Json::objectValue); - onlineProp["type"] = "boolean"; - props["online"] = onlineProp; - AppendPagingProps(props); + Json::Value queryProp(Json::objectValue); + queryProp["type"] = "string"; + queryProp["description"] = u8"关键字:子串匹配计算机名、备注或 IP(ASCII 不区分大小写)。省略则不过滤。"; + props["query"] = queryProp; - Json::Value schema(Json::objectValue); - schema["type"] = "object"; - schema["properties"] = props; - return schema; -} + Json::Value nameProp(Json::objectValue); + nameProp["type"] = "string"; + nameProp["description"] = u8"只按计算机名/备注过滤(search_hosts 的旧参数);与 query 同时给出时两者都需满足。"; + props["name"] = nameProp; -// list_all_hosts 的 inputSchema:两类开关,默认都返回 -Json::Value BuildListAllHostsInputSchema() { - Json::Value props(Json::objectValue); + Json::Value ipProp(Json::objectValue); + ipProp["type"] = "string"; + ipProp["description"] = u8"只按 IP 过滤(search_hosts 的旧参数);与 query 同时给出时两者都需满足。"; + props["ip"] = ipProp; Json::Value onlineProp(Json::objectValue); onlineProp["type"] = "boolean"; - onlineProp["description"] = u8"是否包含在线主机,默认 true"; + onlineProp["description"] = u8"true(默认)返回在线主机;false 只返回离线主机(历史连接过、当前未连接)。"; props["online"] = onlineProp; - Json::Value offlineProp(Json::objectValue); - offlineProp["type"] = "boolean"; - offlineProp["description"] = u8"是否包含离线主机(历史连接过、当前未连接的),默认 true"; - props["offline"] = offlineProp; + Json::Value includeOfflineProp(Json::objectValue); + includeOfflineProp["type"] = "boolean"; + includeOfflineProp["description"] = u8"是否把离线主机一起返回,默认 false(只给在线);online=false 时无意义。list_all_hosts 别名默认 true。"; + props["include_offline"] = includeOfflineProp; AppendHostListFilterProps(props); AppendPagingProps(props); @@ -1131,7 +1126,7 @@ Json::Value BuildGetHostDetailInputSchema() { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一"; props["id"] = idProp; AppendBatchIdsProp(props); @@ -1299,7 +1294,7 @@ Json::Value BuildServiceListOutputSchema() { static void AddIdRequiredProp(Json::Value& props) { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; } @@ -1533,7 +1528,7 @@ Json::Value BuildListRegistryInputSchema() { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一"; props["id"] = idProp; AppendBatchIdsProp(props); @@ -1599,7 +1594,7 @@ Json::Value BuildExecCommandInputSchema() { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value cmdProp(Json::objectValue); @@ -1656,7 +1651,7 @@ Json::Value BuildClientLogInputSchema() { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段;与 ids 二选一"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段;与 ids 二选一"; props["id"] = idProp; Json::Value limitProp(Json::objectValue); @@ -1872,7 +1867,7 @@ Json::Value BuildGetScreenshotInputSchema() { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value modeProp(Json::objectValue); @@ -1939,7 +1934,7 @@ Json::Value BuildGetForegroundWindowInputSchema() { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value schema(Json::objectValue); @@ -1957,7 +1952,7 @@ Json::Value BuildListFilesInputSchema() { Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value pathProp(Json::objectValue); @@ -2127,49 +2122,14 @@ std::string BuildToolsListResult(const Json::Value& id) { Json::Value result(Json::objectValue); Json::Value tools(Json::arrayValue); - // 1) list_online_hosts + // 1) list_hosts(P1-1:合并 list_online_hosts / search_hosts / list_all_hosts; + // 旧名作为别名保留在分发处,不出现在 tools/list) { Json::Value tool(Json::objectValue); - tool["name"] = "list_online_hosts"; - // 说明文字为 UTF-8:项目 /execution-charset:.936 会把普通窄字面量编译成 GBK, - // 故用 u8 前缀确保输出到 JSON 的字节是 UTF-8。 - tool["description"] = u8"获取当前所有在线主机的列表,包含计算机名、IP、操作系统、版本、备注、分组、活动窗口、延迟等实时信息。可选 group / os / client_type 三个过滤条件(均可选、AND 组合、子串匹配、ASCII 不区分大小写),过滤在分页之前生效:total 为命中台数,totalAll 为全部在线台数。结果按 limit/offset 分页(默认 100 条,上限 1000),hasMore 表示还有下一页。tls=true 表示该客户端登录时使用了 TLS 加密传输(登录时上报,非实时探测;老客户端恒为 false)。"; - - Json::Value inputSchema(Json::objectValue); - inputSchema["type"] = "object"; - Json::Value props(Json::objectValue); - AppendHostListFilterProps(props); - AppendPagingProps(props); - inputSchema["properties"] = props; - inputSchema["required"] = Json::Value(Json::arrayValue); - tool["inputSchema"] = inputSchema; - + tool["name"] = "list_hosts"; + tool["description"] = u8"列主机:默认只返回在线主机(含计算机名、IP、操作系统、版本、备注、分组、活动窗口、延迟等实时信息),include_offline=true 时连离线主机(历史连接过、当前未连接,来自主机列表记录)一起返回,在线主机排在最前面。query 子串匹配计算机名/备注/IP;group / os / client_type 为附加过滤条件(均可选、AND 组合、子串匹配、ASCII 不区分大小写);online=false 只看离线主机。过滤在分页之前生效:total 为命中台数,totalAll 为过滤前的主机库台数。结果按 limit/offset 分页(默认 100 条,上限 1000),hasMore 表示还有下一页。离线主机另有 last_seen(最后一次登录时间)、install_time 字段,但没有 rtt/version/activeWindow 等实时字段,也没有 clientType(按平台筛历史主机请用 os),group 恒为 default。authStatus 为主机授权状态(unauthorized/authorized_by_super/authorized_by_admin/forbidden)。tls=true 表示该客户端登录时使用了 TLS 加密传输(登录时上报,老客户端恒为 false)。"; + tool["inputSchema"] = BuildListHostsInputSchema(); tool["outputSchema"] = BuildHostOutputSchema(); - - tools.append(tool); - } - - // 2) search_hosts(P2a:纯内存过滤,无子链接) - { - Json::Value tool(Json::objectValue); - tool["name"] = "search_hosts"; - tool["description"] = u8"按计算机名/备注、IP、分组、操作系统过滤主机。所有条件均可选、按 AND 组合;子串匹配(ASCII 不区分大小写)。online=true 只返回在线主机,online=false 只返回离线主机(曾连接过、当前未连接),省略时只返回在线主机。离线主机的 group 恒为 default,last_seen 为最后一次登录时间;两类都要请用 list_all_hosts。结果按 limit/offset 分页(默认 100 条,上限 1000),total 为匹配总数。tls=true 表示该客户端登录时使用了 TLS 加密传输(登录时上报,老客户端恒为 false)。"; - - tool["inputSchema"] = BuildSearchHostsInputSchema(); - tool["outputSchema"] = BuildHostOutputSchema(); - - tools.append(tool); - } - - // 2b) list_all_hosts(P2a+:在线 + 离线主机全量枚举,纯内存) - { - Json::Value tool(Json::objectValue); - tool["name"] = "list_all_hosts"; - tool["description"] = u8"列出服务端已知的全部主机:在线主机(实时信息)与离线主机(历史连接过、当前未连接,来自主机列表记录)。在线主机字段同 list_online_hosts;离线主机另有 last_seen(最后一次登录时间)、install_time 字段,但没有 rtt/version/activeWindow 等实时字段,也没有 clientType。authStatus 为主机授权状态(unauthorized/authorized_by_super/authorized_by_admin/forbidden)。默认两类都返回;可选 group / os / client_type 过滤(AND 组合、子串匹配、ASCII 不区分大小写),过滤在分页之前生效:total 为命中台数,totalAll 为主机库总数。结果按 limit/offset 分页(默认 100 条,上限 1000)。"; - - tool["inputSchema"] = BuildListAllHostsInputSchema(); - tool["outputSchema"] = BuildHostOutputSchema(); - tools.append(tool); } @@ -2294,7 +2254,7 @@ std::string BuildToolsListResult(const Json::Value& id) { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value durProp(Json::objectValue); @@ -2787,57 +2747,84 @@ std::string BuildToolsListResult(const Json::Value& id) { return BuildResult(id, result); } -// tools/call:list_online_hosts -std::string BuildListOnlineHosts(const Json::Value& id, const Json::Value& args, CMy2015RemoteDlg* parent) { - Json::Value all(Json::arrayValue); - CollectOnlineHosts(parent, all); +// ===== P1-1:list_hosts(合并 list_online_hosts / search_hosts / list_all_hosts)===== +// 三个旧工具的差异只在「要不要离线主机」和几个过滤字段,统一成一个 handler: +// list_hosts(及别名 list_online_hosts / search_hosts)→ 默认只看在线(defaultAll=false) +// list_all_hosts → 默认在线 + 离线(defaultAll=true) +// 过滤口径与旧实现一致:条件都可选、AND 组合、子串匹配、ASCII 不区分大小写。 +// query 一次性匹配 name/remark/ip;name、ip 保留给 search_hosts 的旧调用方。 +struct HostQueryFilter { + HostListFilter base; // group / os / client_type + std::string query, name, ip; + bool Any() const { + return base.Any() || !query.empty() || !name.empty() || !ip.empty(); + } +}; - // 过滤在分页之前:total 是命中数,totalAll 是全部在线数(与 get_audit_log 同口径)。 - HostListFilter filter = ReadHostListFilter(args); - Json::Value matched; - ApplyHostListFilter(all, filter, matched); - - PageWindow page = ResolvePageWindow(args); - Json::Value hosts; - ApplyPageWindow(matched, page, hosts); - if (filter.Any()) page.totalAll = (int)all.size(); - - Json::Value result(Json::objectValue); - Json::Value structuredContent(Json::objectValue); - structuredContent["hosts"] = hosts; - WritePageFields(structuredContent, page); - result["structuredContent"] = structuredContent; - - std::string text = PageSummary(page, filter.Any() ? u8"台主机匹配" : u8"台主机在线"); - if (filter.Any()) - text += std::string(u8"在线共 ") + std::to_string((int)all.size()) + std::string(u8" 台。"); - - Json::Value content(Json::arrayValue); - Json::Value item(Json::objectValue); - item["type"] = "text"; - item["text"] = text; - content.append(item); - result["content"] = content; - result["isError"] = false; - - return BuildResult(id, result); +HostQueryFilter ReadHostQueryFilter(const Json::Value& args) { + HostQueryFilter f; + f.base = ReadHostListFilter(args); + f.query = GetStringArg(args, "query"); + f.name = GetStringArg(args, "name"); + f.ip = GetStringArg(args, "ip"); + return f; } -// tools/call:list_all_hosts(在线 + 离线,纯内存,不建子连接) -std::string BuildListAllHosts(const Json::Value& id, const Json::Value& args, CMy2015RemoteDlg* parent) { - bool includeOnline = !(args.isObject() && args.isMember("online") && args["online"].isBool()) || args["online"].asBool(); - bool includeOffline = !(args.isObject() && args.isMember("offline") && args["offline"].isBool()) || args["offline"].asBool(); +void ApplyHostQueryFilter(const Json::Value& in, const HostQueryFilter& f, Json::Value& out) { + ApplyHostListFilter(in, f.base, out); + if (f.query.empty() && f.name.empty() && f.ip.empty()) return; + + Json::Value narrowed(Json::arrayValue); + for (Json::Value::ArrayIndex i = 0; i < out.size(); ++i) { + const Json::Value& h = out[i]; + if (!f.query.empty()) { + if (!ContainsCI(JsonStrField(h, "name"), f.query) && + !ContainsCI(JsonStrField(h, "remark"), f.query) && + !ContainsCI(JsonStrField(h, "ip"), f.query)) continue; + } + if (!f.name.empty() && + !ContainsCI(JsonStrField(h, "name"), f.name) && + !ContainsCI(JsonStrField(h, "remark"), f.name)) continue; + if (!f.ip.empty() && !ContainsCI(JsonStrField(h, "ip"), f.ip)) continue; + narrowed.append(h); + } + out = narrowed; +} + +// tools/call:list_hosts 及三个旧别名 +std::string BuildListHosts(const Json::Value& id, const Json::Value& args, + CMy2015RemoteDlg* parent, bool defaultAll) { + const bool hasOnline = args.isObject() && args.isMember("online") && args["online"].isBool(); + const bool hasInclude = args.isObject() && args.isMember("include_offline") && + args["include_offline"].isBool(); + const bool hasLegacy = args.isObject() && args.isMember("offline") && args["offline"].isBool(); + + bool includeOnline = hasOnline ? args["online"].asBool() : true; + bool includeOffline = hasInclude ? args["include_offline"].asBool() + : hasLegacy ? args["offline"].asBool() + : defaultAll; + // online=false 且没给任何「包含离线」开关:按 search_hosts 的旧语义只返回离线主机。 + if (!includeOnline && !hasInclude && !hasLegacy) includeOffline = true; Json::Value hosts(Json::arrayValue); CollectAllHosts(parent, hosts, includeOnline, includeOffline); + // 在线主机排前面:主机库可能有几千台历史记录,include_offline 默认只取第一页, + // 若沿用 m_ClientMap 的键序,真正能操作的在线主机会被埋进离线堆里,翻页才能看到。 + if (includeOnline && includeOffline && hosts.size() > 1) { + Json::Value ordered(Json::arrayValue); + for (Json::Value::ArrayIndex i = 0; i < hosts.size(); ++i) + if (hosts[i]["online"].asBool()) ordered.append(hosts[i]); + for (Json::Value::ArrayIndex i = 0; i < hosts.size(); ++i) + if (!hosts[i]["online"].asBool()) ordered.append(hosts[i]); + hosts = ordered; + } - // 过滤先于统计与分页:total/totalAll 与摘要里的在线/离线数都按命中条目算。 - HostListFilter filter = ReadHostListFilter(args); + HostQueryFilter filter = ReadHostQueryFilter(args); Json::Value matched; - ApplyHostListFilter(hosts, filter, matched); + ApplyHostQueryFilter(hosts, filter, matched); int onlineCount = 0; - for (unsigned int i = 0; i < matched.size(); ++i) { + for (Json::Value::ArrayIndex i = 0; i < matched.size(); ++i) { if (matched[i]["online"].asBool()) onlineCount++; } @@ -2852,64 +2839,19 @@ std::string BuildListAllHosts(const Json::Value& id, const Json::Value& args, CM WritePageFields(structuredContent, page); result["structuredContent"] = structuredContent; - Json::Value content(Json::arrayValue); - Json::Value item(Json::objectValue); - item["type"] = "text"; - std::string text = PageSummary(page, filter.Any() ? u8"台主机匹配" : u8"台主机"); - text += std::string(u8"其中在线 ") + std::to_string(onlineCount) + - std::string(u8",离线 ") + std::to_string(page.total - onlineCount) + std::string(u8"。"); + const char* unit = filter.Any() ? u8"台主机匹配" + : (includeOffline ? u8"台主机" : u8"台在线主机"); + std::string text = PageSummary(page, unit); + if (includeOffline) + text += std::string(u8"其中在线 ") + std::to_string(onlineCount) + + std::string(u8",离线 ") + std::to_string(page.total - onlineCount) + std::string(u8"。"); if (filter.Any()) text += std::string(u8"主机库共 ") + std::to_string((int)hosts.size()) + std::string(u8" 台。"); - item["text"] = text; - content.append(item); - result["content"] = content; - result["isError"] = false; - - return BuildResult(id, result); -} - -// tools/call:search_hosts -std::string BuildSearchHosts(const Json::Value& id, const Json::Value& args, CMy2015RemoteDlg* parent) { - Json::Value all(Json::arrayValue); - - std::string fName = GetStringArg(args, "name"); - std::string fIp = GetStringArg(args, "ip"); - std::string fGroup = GetStringArg(args, "group"); - std::string fOs = GetStringArg(args, "os"); - // online=true → 仅在线;online=false → 仅离线(历史主机);省略 → 仅在线(保持本工具原有行为, - // 想要两类都要请用 list_all_hosts)。 - bool hasOnline = args.isObject() && args.isMember("online") && args["online"].isBool(); - bool wantOnline = hasOnline ? args["online"].asBool() : true; - CollectAllHosts(parent, all, wantOnline, hasOnline && !wantOnline); - - Json::Value hosts(Json::arrayValue); - for (unsigned int i = 0; i < all.size(); ++i) { - const Json::Value& h = all[i]; - if (!fName.empty()) { - std::string name = JsonStrField(h, "name"); - std::string remark = JsonStrField(h, "remark"); - if (!ContainsCI(name, fName) && !ContainsCI(remark, fName)) continue; - } - if (!fIp.empty() && !ContainsCI(JsonStrField(h, "ip"), fIp)) continue; - if (!fGroup.empty() && !ContainsCI(JsonStrField(h, "group"), fGroup)) continue; - if (!fOs.empty() && !ContainsCI(JsonStrField(h, "os"), fOs)) continue; - hosts.append(h); - } - - PageWindow page = ResolvePageWindow(args); - Json::Value pageItems; - ApplyPageWindow(hosts, page, pageItems); - - Json::Value result(Json::objectValue); - Json::Value structuredContent(Json::objectValue); - structuredContent["hosts"] = pageItems; - WritePageFields(structuredContent, page); - result["structuredContent"] = structuredContent; Json::Value content(Json::arrayValue); Json::Value item(Json::objectValue); item["type"] = "text"; - item["text"] = PageSummary(page, u8"台主机匹配"); + item["text"] = text; content.append(item); result["content"] = content; result["isError"] = false; @@ -2920,7 +2862,7 @@ std::string BuildSearchHosts(const Json::Value& id, const Json::Value& args, CMy // tools/call:get_host_detail // // 登录时上报的 RES_* 技术字段(CPU 核数/内存/系统位数/账号/安装时间/分辨率…)只在 -// get_host_detail 里补充,不改 BuildHostJson —— 那是 Web UI 与 list_online_hosts 共用的 +// get_host_detail 里补充,不改 BuildHostJson —— 那是 Web UI 与 list_hosts 共用的 // 序列化函数,动它会改变已有调用方的输出形状。 std::string ResFieldUtf8(context* ctx, UINT cp, int idx) { CString v = ctx->GetAdditionalData(idx); @@ -3026,7 +2968,7 @@ std::string BuildGetHostDetail(const Json::Value& id, const Json::Value& args, C const Json::Value& h = all[i]; if (JsonStrField(h, "id") == sid) { // 复制后再补充技术字段:all[] 里的是本次调用内的临时对象,补字段不影响 - // BuildHostJson 本身(list_online_hosts 用同一份序列化,输出形状不变)。 + // BuildHostJson 本身(list_hosts 用同一份序列化,输出形状不变)。 Json::Value host = h; AppendHostTechnicalDetail(parent, strtoull(sid.c_str(), nullptr, 10), host); @@ -3091,7 +3033,7 @@ std::string BuildGetHostDetail(const Json::Value& id, const Json::Value& args, C } // list_processes / list_windows 的服务端过滤:name 是子串匹配(ASCII 不区分大小写, -// 口径同 list_online_hosts 的过滤),pid 是精确匹配;nameField 指定被匹配的字段 +// 口径同 list_hosts 的过滤),pid 是精确匹配;nameField 指定被匹配的字段 // (进程看映像名 "name",窗口看标题 "title")。两个条件都没给就原样返回。 Json::Value FilterByPidAndName(const Json::Value& items, const Json::Value& args, const char* nameField) { @@ -3143,7 +3085,7 @@ std::string BuildListProcesses(const Json::Value& id, const Json::Value& args, C Json::Value procs = ParseProcessList(data, cp); - // 过滤先于分页:total 是命中数,totalAll 是过滤前的总数(口径同 search_hosts)。 + // 过滤先于分页:total 是命中数,totalAll 是过滤前的总数(口径同 list_hosts)。 Json::Value matched = FilterByPidAndName(procs, args, "name"); PageWindow page = ResolvePageWindow(args); Json::Value pageItems; @@ -3196,7 +3138,7 @@ std::string BuildListWindows(const Json::Value& id, const Json::Value& args, CMy UINT cp = GetClientEncoding(ctx); Json::Value wins = ParseWindowList(data, cp); - // 过滤先于分页:total 是命中数,totalAll 是过滤前的总数(口径同 search_hosts)。 + // 过滤先于分页:total 是命中数,totalAll 是过滤前的总数(口径同 list_hosts)。 Json::Value matched = FilterByPidAndName(wins, args, "title"); PageWindow page = ResolvePageWindow(args); Json::Value pageItems; @@ -4786,7 +4728,7 @@ Json::Value BuildTerminalOpenInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value timeoutProp(Json::objectValue); timeoutProp["type"] = "integer"; @@ -4829,7 +4771,7 @@ Json::Value BuildTerminalExecInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); sid["type"] = "string"; @@ -4909,7 +4851,7 @@ Json::Value BuildTerminalCloseInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); sid["type"] = "string"; @@ -5298,7 +5240,7 @@ Json::Value BuildRemoteOpenInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value timeoutProp(Json::objectValue); timeoutProp["type"] = "integer"; @@ -5398,7 +5340,7 @@ Json::Value BuildRemoteCloseInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); sid["type"] = "string"; @@ -5878,7 +5820,7 @@ Json::Value BuildRemoteKeyboardInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); @@ -6312,7 +6254,7 @@ Json::Value BuildRemoteMouseInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); @@ -6741,7 +6683,7 @@ Json::Value BuildRemoteClipboardInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); @@ -6857,7 +6799,7 @@ Json::Value BuildRemoteLockScreenInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); sid["type"] = "string"; @@ -6967,7 +6909,7 @@ Json::Value BuildRemoteBlockInputInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value sid(Json::objectValue); @@ -7195,7 +7137,7 @@ Json::Value BuildDownloadFileInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value rp(Json::objectValue); @@ -7609,7 +7551,7 @@ Json::Value BuildReadFileInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value pathProp(Json::objectValue); @@ -8431,7 +8373,7 @@ Json::Value BuildHttpProbeInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value urlProp(Json::objectValue); urlProp["type"] = "string"; @@ -8875,7 +8817,7 @@ Json::Value BuildUploadFileInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id,取 list_online_hosts / search_hosts 返回的 id 字段"; + idProp["description"] = u8"主机 id,取 list_hosts 返回的 id 字段"; props["id"] = idProp; Json::Value lp(Json::objectValue); @@ -9242,7 +9184,7 @@ Json::Value BuildCopyFilesC2CInputSchema() { Json::Value src(Json::objectValue); src["type"] = "string"; - src["description"] = u8"源主机 id(文件从这里发出),取 list_online_hosts / search_hosts 返回的 id"; + src["description"] = u8"源主机 id(文件从这里发出),取 list_hosts 返回的 id"; props["src_id"] = src; Json::Value dst(Json::objectValue); @@ -11660,7 +11602,7 @@ Json::Value BuildHostSetRemarkInputSchema() { Json::Value props(Json::objectValue); Json::Value idProp(Json::objectValue); idProp["type"] = "string"; - idProp["description"] = u8"主机 id(list_online_hosts / list_all_hosts 返回的十进制字符串)。"; + idProp["description"] = u8"主机 id(list_hosts 返回的十进制字符串)。"; props["id"] = idProp; Json::Value remarkProp(Json::objectValue); remarkProp["type"] = "string"; @@ -11768,9 +11710,8 @@ struct ToolPlatform { // 遗漏由 check_platform_table.py 的工具数比对发现。 const ToolPlatform kToolPlatforms[] = { // ---- win+lnx+mac+apk ---- 只读写服务端本地数据,与客户端平台无关 - { "list_online_hosts", kPlatWin|kPlatLnx|kPlatMac|kPlatApk }, - { "search_hosts", kPlatWin|kPlatLnx|kPlatMac|kPlatApk }, - { "list_all_hosts", kPlatWin|kPlatLnx|kPlatMac|kPlatApk }, + // P1-1:主机列表三合一。旧名保留为别名(不进 tools/list,也不进平台表)。 + { "list_hosts", kPlatWin|kPlatLnx|kPlatMac|kPlatApk }, { "get_host_detail", kPlatWin|kPlatLnx|kPlatMac|kPlatApk }, { "get_audit_log", kPlatWin|kPlatLnx|kPlatMac|kPlatApk }, { "get_server_status", kPlatWin|kPlatLnx|kPlatMac|kPlatApk }, @@ -12148,9 +12089,11 @@ std::string DispatchSingleHostTool(const Json::Value& id, const std::string& too // P9:远程交谈工具族(独立开关 McpChat;门控在 McpChat::Call 内复核)。 if (McpChat::Handles(toolName)) return McpChat::Call(id, toolName, args, parent); - if (toolName == "list_online_hosts") return BuildListOnlineHosts(id, args, parent); - if (toolName == "list_all_hosts") return BuildListAllHosts(id, args, parent); - if (toolName == "search_hosts") return BuildSearchHosts(id, args, parent); + // P1-1:list_hosts 与三个旧别名共用一个 handler;list_all_hosts 默认为「在线 + 离线」。 + if (toolName == "list_hosts") return BuildListHosts(id, args, parent, false); + if (toolName == "list_online_hosts") return BuildListHosts(id, args, parent, false); + if (toolName == "search_hosts") return BuildListHosts(id, args, parent, false); + if (toolName == "list_all_hosts") return BuildListHosts(id, args, parent, true); if (toolName == "get_host_detail") return BuildGetHostDetail(id, args, parent); if (toolName == "list_processes") return BuildListProcesses(id, args, parent); if (toolName == "list_windows") return BuildListWindows(id, args, parent); diff --git a/tools/mcp_tools/make_tools_json.py b/tools/mcp_tools/make_tools_json.py index 867bc6d..a0f5a51 100644 --- a/tools/mcp_tools/make_tools_json.py +++ b/tools/mcp_tools/make_tools_json.py @@ -21,9 +21,8 @@ DST = sys.argv[2] # manage: 额外需要 McpManage(仅 McpMachine 族的两处用到) GATE = { # ---- McpServer.cpp:BuildToolsListResult 无条件段 ---- - "list_online_hosts": (None, False, False), - "search_hosts": (None, False, False), - "list_all_hosts": (None, False, False), + # P1-1:list_online_hosts / search_hosts / list_all_hosts 三合一(旧名为别名,不出现在 tools/list) + "list_hosts": (None, False, False), "get_host_detail": (None, False, False), "list_processes": (None, False, False), "list_windows": (None, False, False), @@ -142,9 +141,7 @@ _APKONLY = ["apk"] PLATFORMS = { # 服务端本地数据,与客户端平台无关 - "list_online_hosts": _APK, - "search_hosts": _APK, - "list_all_hosts": _APK, + "list_hosts": _APK, "get_host_detail": _APK, "get_audit_log": _APK, "get_server_status": _APK,