Feature: Add list_processes, list_windows and get_activity_history MCP tools

Add three read-only P2b MCP tools over the existing protocol. list_processes and list_windows trigger the client via COMMAND_SYSTEM / COMMAND_WSLIST on the main connection and receive TOKEN_PSLIST / TOKEN_WSLIST on a one-shot sub-link; get_activity_history uses the main-connection RPC COMMAND_QUERY_ACTIVITY -> TOKEN_REPORT_ACTIVITY. A per-host single-flight pending registry (m_Pending) with a 20s timeout correlates each response to its request and rejects a concurrent request for the same host with -32003. Parsers stop on the first empty record to ignore the client's LocalSize trailing zero padding, and window titles are decoded per the client UTF-8 capability bit. MessageHandle only adds if-guarded branches, so the MFC dialogs are untouched. Sync Mcp_Phase2_Design.md with the mode A'/A architecture, the verification notes, and the registry-backed config location.

Co-Authored-By: deepseek-v4-pro
This commit is contained in:
yuanyuanxiang
2026-08-19 09:58:58 +02:00
parent 86c4f14cf4
commit 6ba6b0289d
4 changed files with 626 additions and 54 deletions

View File

@@ -5473,6 +5473,13 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
break;
}
case TOKEN_REPORT_ACTIVITY: {
// P2bMCP 挂起时接管。历史活动为「主连接 RPC」无子链接响应回主 context
// 不能 CancelIO会断开主连接仅同步拷贝后 break。
uint64_t devId = ContextObject->GetClientID();
if (McpServer().IsPending(devId)) {
McpServer().TakeMainResponse(devId, ContextObject->GetBuffer(0), ContextObject->GetBufferLength());
break;
}
// 一次性快照:直接打开“历史活动”对话框展示,不占用 hDlg避免与运行日志对话框冲突
std::string text((char*)(szBuffer + 1), len > 1 ? len - 1 : 0);
CActivityDialog* dlg = new CActivityDialog(this, ContextObject->GetServer(), ContextObject);
@@ -6351,6 +6358,14 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
}
case TOKEN_WSLIST: // 窗口管理【x】
case TOKEN_PSLIST: { // 进程管理【x】
// P2bMCP 挂起时接管。进程/窗口列表无请求 id按 device_id 匹配并同步拷贝
// (此时 IO 线程阻塞在 NotifyProc缓冲尚未被覆盖拷贝安全
uint64_t devId = ContextObject->GetClientID();
if (McpServer().IsPending(devId)) {
McpServer().TakeMainResponse(devId, ContextObject->GetBuffer(0), ContextObject->GetBufferLength());
ContextObject->CancelIO(); // 用完即关,避免子链接泄漏(仿 WebService 终端关闭)
break;
}
g_2015RemoteDlg->SendMessage(WM_OPENSYSTEMDIALOG, 0, (LPARAM)ContextObject);
break;
}