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
@@ -419,6 +419,15 @@ public:
|
||||
bool IsReadonly() const { return m_readonly; }
|
||||
const std::string& GetCmdWhitelist() const { return m_cmdWhitelist; }
|
||||
|
||||
// 监听地址/端口(Start 时记录,供 get_server_status 报告)。
|
||||
const std::string& GetBind() const { return m_bind; }
|
||||
int GetPort() const { return m_port; }
|
||||
|
||||
// get_server_status:在飞会话与鉴权封禁计数。每类各取一次自己的锁,
|
||||
// 返回前全部释放——调用方拿到的是「大致同一时刻」的估算值,不用来同步。
|
||||
void GetRuntimeCounters(int& pending, int& terminal, int& screenCtrl,
|
||||
int& fileXfer, int& chat, int& blockedIps);
|
||||
|
||||
private:
|
||||
CMcpServer();
|
||||
~CMcpServer();
|
||||
@@ -460,6 +469,8 @@ private:
|
||||
std::thread m_thread;
|
||||
std::atomic<bool> m_running{false};
|
||||
std::string m_token;
|
||||
std::string m_bind; // Start 传入的监听地址
|
||||
int m_port = 0; // Start 传入的监听端口
|
||||
CMy2015RemoteDlg* m_parent = nullptr;
|
||||
|
||||
// 挂起请求注册表(受 m_PendingMutex 保护,键 = device_id)。
|
||||
|
||||
Reference in new issue
Block a user