Feature(mcp): hide the degraded list_* tools when host management is on

host_inspect now covers processes, windows and services, so with
McpMachine=1 the older list_processes / list_windows / list_services
entries only competed with it: same intent, two names, two long
descriptions to read before choosing. They no longer appear in
tools/list while host management is enabled, but their names still
dispatch, so callers that cached them keep working.

They must stay visible when McpMachine=0: that is the default state and
the only way such a server can list processes, windows or services, so
the entries sit behind !IsMachineEnabled() rather than being removed.
list_network_connections is deliberately not folded in: it reads the
connection-manager view (IPv6 rows, killable flag, numeric state) which
host_inspect's IPv4-only network aspect does not provide.

tools.json is now generated from two captures, all-switches-on plus
McpMachine=0, because neither state contains the whole surface; the
off-state entries are marked gate "!machine" and verify_tools.py skips
them when comparing against an all-on server. tools/list went from 54
to 51 entries and from 183,336 B to 171,929 B (-6.2%).

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-12 17:28:28 +01:00
1 parent 59f0f16f74
commit c73db530f4
4 files changed
+543 -488

No files matched your search

+15 -9
View File
@@ -2122,6 +2122,12 @@ std::string BuildToolsListResult(const Json::Value& id) {
Json::Value result(Json::objectValue);
Json::Value tools(Json::arrayValue);
// P2-2:主机管理开启时,list_processes / list_windows / list_services 由 host_inspect
// 的 processes / windows / win32_services 项覆盖,不再出现在 tools/list;但名字仍在
// 分派处可用(见 Call),老调用方不会断。关闭主机管理时它们必须出现——那是这台
// 服务端唯一能列进程/窗口/服务的路径(McpMachine 默认关)。
const bool showDegradedLists = !McpServer().IsMachineEnabled();
// 1) list_hosts(P1-1:合并 list_online_hosts / search_hosts / list_all_hosts;
// 旧名作为别名保留在分发处,不出现在 tools/list)
{
@@ -2145,11 +2151,11 @@ std::string BuildToolsListResult(const Json::Value& id) {
tools.append(tool);
}
// 4) list_processes(P2b:主连接 RPC,进程列表)
{
// 4) list_processes(P2b:主连接 RPC,进程列表;P2-2:主机管理开启时由 host_inspect 取代)
if (showDegradedLists) {
Json::Value tool(Json::objectValue);
tool["name"] = "list_processes";
tool["description"] = u8"获取指定在线主机的进程列表(PID、映像名称、架构、程序完整路径)。通过主连接下发命令、子连接回传,一次性返回。可选 name(映像名子串,ASCII 不区分大小写)/ pid(精确)在服务端过滤,过滤在分页之前生效:total 为命中数、totalAll 为过滤前的总数。结果按 limit/offset 分页。定位是 McpMachine=0(主机管理工具关闭)时的降级路径,字段较少;若 host_inspect 出现在 tools/list 里,一律优先用它的 processes 项。";
tool["description"] = u8"获取指定在线主机的进程列表(PID、映像名称、架构、程序完整路径)。通过主连接下发命令、子连接回传,一次性返回。可选 name(映像名子串,ASCII 不区分大小写)/ pid(精确)在服务端过滤,过滤在分页之前生效:total 为命中数、totalAll 为过滤前的总数。结果按 limit/offset 分页。仅在 McpMachine=0(主机管理工具关闭)时出现——那是本服务端唯一能列进程的路径;开启主机管理后改用 host_inspect 的 processes 项(字段更全、支持 arch 过滤)。";
tool["inputSchema"] = BuildFilteredPagedHostListInputSchema(
u8"按映像名子串过滤,ASCII 不区分大小写(如 chrome)",
@@ -2159,11 +2165,11 @@ std::string BuildToolsListResult(const Json::Value& id) {
tools.append(tool);
}
// 5) list_windows(P2b:主连接 RPC,窗口列表)
{
// 5) list_windows(P2b:主连接 RPC,窗口列表;P2-2:主机管理开启时由 host_inspect 取代)
if (showDegradedLists) {
Json::Value tool(Json::objectValue);
tool["name"] = "list_windows";
tool["description"] = u8"获取指定在线主机的顶层窗口列表(句柄、窗口标题、窗口状态、所属进程 PID)。一次性返回。可选 name(窗口标题子串,ASCII 不区分大小写)/ pid(所属进程,精确)在服务端过滤,过滤在分页之前生效:total 为命中数、totalAll 为过滤前的总数。结果按 limit/offset 分页。定位是 McpMachine=0(主机管理工具关闭)时的降级路径;若 host_inspect 出现在 tools/list 里,一律优先用它的 windows 项。";
tool["description"] = u8"获取指定在线主机的顶层窗口列表(句柄、窗口标题、窗口状态、所属进程 PID)。一次性返回。可选 name(窗口标题子串,ASCII 不区分大小写)/ pid(所属进程,精确)在服务端过滤,过滤在分页之前生效:total 为命中数、totalAll 为过滤前的总数。结果按 limit/offset 分页。仅在 McpMachine=0(主机管理工具关闭)时出现;开启主机管理后改用 host_inspect 的 windows 项(字段更全,含窗口矩形与 z 序)。";
tool["inputSchema"] = BuildFilteredPagedHostListInputSchema(
u8"按窗口标题子串过滤,ASCII 不区分大小写(如 notepad);匹配的是标题不是进程名",
@@ -2221,11 +2227,11 @@ std::string BuildToolsListResult(const Json::Value& id) {
tools.append(tool);
}
// 9) list_services(P3:服务链路,仅 Windows,一次性子链接)
{
// 9) list_services(P3:服务链路,仅 Windows,一次性子链接;P2-2:主机管理开启时由 host_inspect 取代)
if (showDegradedLists) {
Json::Value tool(Json::objectValue);
tool["name"] = "list_services";
tool["description"] = u8"获取指定在线 Windows 主机的服务列表(显示名、服务名、可执行文件路径、运行状态、启动类型)。仅 Windows 客户端支持;一次性返回,结果按 limit/offset 分页。不支持服务端过滤。定位是 McpMachine=0(主机管理工具关闭)时的降级路径,字段较少(无描述、登录身份);若 host_inspect 出现在 tools/list 里,一律优先用它的 win32_services 项。";
tool["description"] = u8"获取指定在线 Windows 主机的服务列表(显示名、服务名、可执行文件路径、运行状态、启动类型)。仅 Windows 客户端支持;一次性返回,结果按 limit/offset 分页。不支持服务端过滤。仅在 McpMachine=0(主机管理工具关闭)时出现;开启主机管理后改用 host_inspect 的 win32_services 项(字段更全:描述、登录身份)。注意两者都要求客户端以管理员权限运行,否则拿不到服务列表。";
tool["inputSchema"] = BuildPagedHostListInputSchema();
tool["outputSchema"] = BuildServiceListOutputSchema();