Feature(mcp): unify window and service controls behind one name per state

operate_window / host_control_window and control_service / host_control_service were two
implementations of the same intent. tools/list now exposes exactly one of each pair,
chosen by McpMachine: the host_control_* names when host management is enabled, the
main-connection names when it is not.

The advertised tool accepts the union of actions. host_control_window routes close/show
to the main-connection implementation, which stays the only path with close/show
semantics and requires McpManage; the machine path keeps its post-action verification
for restore/hide/maximize/minimize/activate. host_control_service routes
set_auto/set_manual the same way and rejects dry_run for them instead of pretending to
run one. Both old names remain callable aliases, and service_name is accepted as an
alias for the machine tool's name parameter.

The manifest generator treats the two main-connection tools as !machine entries, so the
two-capture union still covers both states. tools/list is 49 entries when everything is
on (was 51) and 47 when host management is off; the response shrinks from 193,008 B to
168,634 B (-12.6%), short of the 15% estimate because state-conditional tools must stay
in the manifest. The plan document records that measurement and the reason.

Verified with a dedicated two-state test: visibility matrix, close/show and
set_auto/set_manual routing through dry_run and validation paths, alias dispatch, and
-32006 for host_* names when host management is off. Step 8a/8b regressions and
verify_tools --live still pass.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-12 17:40:51 +01:00
1 parent c73db530f4
commit 5841f27df9
5 files changed
+218 -141

No files matched your search

+11 -4
View File
@@ -20,8 +20,11 @@ DST = sys.argv[2]
OFF_SRC = sys.argv[3] if len(sys.argv) > 3 else None
# 只在 McpMachine=0 时出现的降级工具(gate = "!machine")。改动这个集合要同步更新
# McpServer.cpp 里 showDegradedLists 那段。
MACHINE_OFF_FALLBACKS = {"list_processes", "list_windows", "list_services"}
# McpServer.cpp 里 showDegradedLists / showMainControls 两段。
# P2-2:operate_window / control_service 与 host_inspect / host_control_* 之间同样按
# McpMachine 二选一暴露(动作并集,两套名字都可调用)。
MACHINE_OFF_FALLBACKS = {"list_processes", "list_windows", "list_services",
"operate_window", "control_service"}
# gate: 该工具要求哪个服务端开关为开(null = 无条件出现)
# write: 需要 !McpReadonly
@@ -34,6 +37,8 @@ GATE = {
# ---- McpMachine=0 时的降级路径(P2-2)----
# 开启主机管理后它们由 host_inspect 的 processes / windows / win32_services 项取代,
# 所以只在开关关闭时进 tools/list(名字仍可作为别名调用)。
# 同理,operate_window / control_service(见下方单开关段)在开启后被
# host_control_window / host_control_service 取代。
"list_processes": ("!machine", False, False),
"list_windows": ("!machine", False, False),
"list_services": ("!machine", False, False),
@@ -82,8 +87,10 @@ GATE = {
# ---- manage(McpServer 侧的危险操作)----
"kill_process": ("manage", True, False),
"operate_window": ("manage", True, False),
"control_service": ("manage", True, False),
# P2-2:主机管理开启时由 host_control_window / host_control_service 承担
# (后两者也接受 close/show、set_auto/set_manual),所以只在 McpMachine=0 时暴露。
"operate_window": ("!machine", True, True),
"control_service": ("!machine", True, True),
"power_action": ("manage", True, False),
"uninstall_host": ("manage", True, False),