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
@@ -139,6 +139,15 @@ Check 'get_audit_log 条数不超过 limit' (@($audit.result.structuredContent.e
|
||||
$auditFiltered = Rpc '' $null 'get_audit_log' @{ type = 'zzz-no-such-type'; limit = 5 }
|
||||
Check 'get_audit_log 过滤未命中返回 0 条' ($auditFiltered.error -eq $null -and @($auditFiltered.result.structuredContent.entries).Count -eq 0)
|
||||
|
||||
$status = Rpc '' $null 'get_server_status' @{}
|
||||
$st = $status.result.structuredContent.status
|
||||
Check 'get_server_status 正常返回' ($status.error -eq $null -and $null -ne $st)
|
||||
$basePort = 6544
|
||||
if ($Base -match ':(\d+)(/|$)') { $basePort = [int]$Matches[1] }
|
||||
Check 'get_server_status 版本/端口/开关齐全' `
|
||||
([string]$st.version -ne '' -and [int]$st.port -eq $basePort -and $null -ne $st.switches -and $null -ne $st.sessions)
|
||||
Check 'get_server_status 不含 token' (($st | ConvertTo-Json -Depth 6) -notmatch '(?i)token')
|
||||
|
||||
if (-not $HostId) {
|
||||
$first = @($sc.hosts)[0]
|
||||
if ($first) { $HostId = [string]$first.id }
|
||||
|
||||
Reference in new issue
Block a user