Feature: Add a get_server_status tool to the MCP server
Answering "did my rebuild actually take effect" or "why was that tool refused" used to mean reading list_online_hosts and get_audit_log and inferring the rest. A single read-only call now returns the server's own state: brand and version, the exe link time (taken from the file's last write, which unlike __DATE__ reflects the whole build), how long the process has been up, the address and port MCP is actually listening on, every MCP switch, online and offline host counts, the number of sessions in flight per family, and how many source IPs are currently blocked. The bind and port are recorded by Start rather than re-read from the configuration, so the tool reports what the listener really got. Session counters take each subsystem's lock in turn and release it immediately, so the numbers are an estimate of one moment, not a consistent snapshot. Nothing sensitive is exposed: the token and the command whitelist never appear, and the switches are reported as booleans only. The tool is registered as read-only, non-destructive, idempotent and server-local, which brings tools/list to 53 entries. The smoke test gains three checks for it, including one that fails if a token-shaped field ever appears in the output. Verified on the Debug instance: the summary line reports version, uptime and listener correctly, sessions.terminal goes 0 to 1 while a persistent terminal is open and back to 0 after terminal_close, and the smoke test passes 26/26. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
ae37e812ee
commit
5ce453797c
5 files changed
+231
-2
No files matched your search
@@ -323,7 +323,7 @@ struct ToolHints {
|
||||
bool openWorld; // false = 只读服务端本机状态(主机列表、审计日志),不触达外部主机
|
||||
};
|
||||
|
||||
// 52 个工具的语义登记表。新增工具必须在此登记(漏登记 → 走默认 destructiveHint=true)。
|
||||
// 53 个工具的语义登记表。新增工具必须在此登记(漏登记 → 走默认 destructiveHint=true)。
|
||||
const ToolHints kToolHints[] = {
|
||||
// --- 服务端本机只读 ---
|
||||
{ "list_online_hosts", true, false, true, false },
|
||||
@@ -332,6 +332,7 @@ const ToolHints kToolHints[] = {
|
||||
{ "get_host_detail", true, false, true, false },
|
||||
{ "get_activity_history", true, false, true, false },
|
||||
{ "get_audit_log", true, false, true, false },
|
||||
{ "get_server_status", true, false, true, false },
|
||||
// --- 主机只读 ---
|
||||
{ "list_processes", true, false, true, true },
|
||||
{ "list_windows", true, false, true, true },
|
||||
|
||||
Reference in new issue
Block a user