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:
1 parent
59f0f16f74
commit
c73db530f4
4 files changed
+543
-488
No files matched your search
@@ -10,7 +10,8 @@
|
||||
port 省略时自动探测 6545(明文后端)/ 6544(TLS 前端)
|
||||
|
||||
比对内容:name / description / inputSchema / outputSchema,逐字段深度比较,
|
||||
外加工具顺序。gate / write / manage / impl 是 tools.json 独有的元信息,不参与比对。
|
||||
外加工具顺序。gate / write / manage / impl 是 tools.json 独有的元信息,不参与比对;
|
||||
例外是 gate == "!machine" 的降级工具——它们只在 McpMachine=0 时出现,不进本次比对。
|
||||
"""
|
||||
import http.client
|
||||
import json
|
||||
@@ -119,14 +120,20 @@ def main():
|
||||
|
||||
doc = json.load(open(path, encoding="utf-8"))
|
||||
tools_json = doc["tools"]
|
||||
# gate == "!machine" 的工具只在 McpMachine=0 时出现,而黄金样本/活服务都是开关
|
||||
# 全开的抓取,按约定它们不该在这里出现(tools.json 是两份抓取的并集)。
|
||||
off_gated = {t["name"] for t in tools_json if t.get("gate") == "!machine"}
|
||||
tools_cmp = [t for t in tools_json if t["name"] not in off_gated]
|
||||
print(f"tools.json: {path} ({len(tools_json)} 个工具)")
|
||||
if off_gated:
|
||||
print(f" 其中 {len(off_gated)} 个 !machine 降级工具不计入本次比对: {sorted(off_gated)}")
|
||||
print(f"服务端: {len(tools_live)} 个工具")
|
||||
|
||||
if len(tools_json) != len(tools_live):
|
||||
print(f"!! 数量不一致: {len(tools_json)} vs {len(tools_live)}")
|
||||
if len(tools_cmp) != len(tools_live):
|
||||
print(f"!! 数量不一致: {len(tools_cmp)} vs {len(tools_live)}")
|
||||
|
||||
live_by_name = {t["name"]: t for t in tools_live}
|
||||
json_by_name = {t["name"]: t for t in tools_json}
|
||||
json_by_name = {t["name"]: t for t in tools_cmp}
|
||||
|
||||
only_live = sorted(set(live_by_name) - set(json_by_name))
|
||||
only_json = sorted(set(json_by_name) - set(live_by_name))
|
||||
@@ -156,7 +163,7 @@ def main():
|
||||
|
||||
# 顺序一致性:tools/list 的数组顺序会影响模型的选择倾向
|
||||
order_live = [t["name"] for t in tools_live]
|
||||
order_json = [t["name"] for t in tools_json]
|
||||
order_json = [t["name"] for t in tools_cmp]
|
||||
if order_live != order_json:
|
||||
print("!! 工具顺序不一致")
|
||||
for i, (x, y) in enumerate(zip(order_live, order_json)):
|
||||
@@ -168,7 +175,7 @@ def main():
|
||||
print("工具顺序: 一致")
|
||||
|
||||
if diffs == 0 and not only_live and not only_json:
|
||||
print(f"\nPASS: {len(tools_json)} 个工具完全一致")
|
||||
print(f"\nPASS: {len(tools_cmp)} 个工具完全一致")
|
||||
return 0
|
||||
print(f"\nFAIL: {diffs} 处差异")
|
||||
return 1
|
||||
|
||||
Reference in new issue
Block a user