diff --git a/ReadMe.md b/ReadMe.md
index 48af7f1..8e714ee 100644
--- a/ReadMe.md
+++ b/ReadMe.md
@@ -378,6 +378,34 @@ nohup ./server_linux_amd64 --port 6543 --http-port 9001 > yama.log 2>&1 &
## 更新日志
+### v1.3.9 (2026.9.2)
+
+**MCP 服务端集成(AI 远程管理)& 远程控制与文件传输闭环 & 主控增强**
+
+**新功能:**
+- **MCP 服务端集成**:本地 `127.0.0.1:6544` 暴露 JSON-RPC 2.0 接口,Bearer Token 鉴权,「扩展 > MCP 设置」对话框配置启用 / 端口 / 绑定 / Token;23 个工具覆盖「观测 → 执行 → 控制 → 传输」全链路,默认关闭、分级开关(只读 / 白名单 / 终端 / 远程控制 / 文件传输)全面审计
+- **MCP 观测类工具(只读)**:search_hosts、get_host_detail、list_processes、list_windows、get_activity_history、list_files、get_screenshot(可选 max_width)、list_services、get_client_log、list_registry、get_audit_log;单飞请求注册表 20s 超时 + 编码修正(clientType / clientID 定位)
+- **MCP 远程终端工具**:exec_command 一次性执行 + terminal_open / terminal_exec / terminal_close 持久终端(cwd / 环境保留,空闲 300s 清扫),哨兵判定与 timeout_ms 解析修复
+- **MCP 远程控制工具**:remote_open / remote_close 会话 + remote_keyboard(key_down / up / press / type)、remote_mouse(move / click / drag / scroll)、remote_clipboard 注入;与人工 Web 查看双向互斥,会话状态机 busy / closed 加固
+- **MCP 文件传输工具**:download_file(V2 协议 + SHA-256 校验)、upload_file(主连接上传),客户端侧 `COMMAND_SEND_FILE_V2` 懒初始化 `InitFileUpload` 修复上传截断
+- **客户端活动历史**:记录活跃窗口历史(上限 500 条、跳过 <5s),主机「客户端管理」子菜单新增「活动历史」对话框,Unicode 编辑控件正确渲染 UTF-8 标题
+- **日志右键菜单三连**:消息日志右键新增「在线通知」「拉黑 IP」「解封 IP」,IPv4 提取即时生效
+- **列表排序记忆**:主机列表、进程 / 窗口列表排序偏好持久化(`list\*Sort` 注册表键),下次启动默认沿用
+
+**改进:**
+- 重复连接 standby 处理:重复登录暂存 standby 待旧连接超时 / 断线后晋升,避免循环重连与误报离线
+- 远程桌面 / 虚拟屏幕对话框标题显示主机备注而非 IP(无备注回退 IP)
+- 主机列表三态排序(升序 → 降序 → 恢复默认,默认序按在线时间重建)
+- 在线主机右键三个菜单项新增图标(位图数组 63→66)
+
+**Bug 修复:**
+- 客户端屏幕控制批解析错误:记录数是 7 的倍数时误判 MSG32 致注入错乱(`%48==0` 优先)
+- 心跳延迟更新 use-after-free:跨 PostMessage 持有 IoRefCount + memcpy 显式截断
+- ONLINELIST_PRIVILEGE 枚举错位损坏历史数据库(权限列移至 16)
+- 远程桌面光标跨对话框污染(改 `OnSetCursor` 逐窗口路由)
+- 客户端日志对话框 EDIT 上限停止刷新(`SetLimitText(0)`)
+- 窗口管理器视图检查读取陈旧状态、进程列表架构列排序无效、FRP / NAT 下窗口标题乱码
+
### v1.3.8 (2026.8.3)
**SYSTEM 权限客户端 & 主控可用性增强 & Bug 修复**
diff --git a/ReadMe_EN.md b/ReadMe_EN.md
index ad63b83..1212016 100644
--- a/ReadMe_EN.md
+++ b/ReadMe_EN.md
@@ -378,6 +378,34 @@ Valid : 2026-02-01 to 2028-02-01
## Changelog
+### v1.3.9 (2026.9.2)
+
+**MCP Server Integration (AI Remote Management) & Remote Control / File Transfer Loop & Master Enhancements**
+
+**New features:**
+- **MCP server integration**: local JSON-RPC 2.0 endpoint on `127.0.0.1:6544` with Bearer token auth, configured via "Extensions > MCP Settings"; 23 tools spanning observe → execute → control → transfer, disabled by default with per-tier gates (read-only / whitelist / terminal / remote control / file transfer) and full audit logging
+- **MCP read-only observation tools**: search_hosts, get_host_detail, list_processes, list_windows, get_activity_history, list_files, get_screenshot (optional max_width), list_services, get_client_log, list_registry, get_audit_log; single-flight pending registry with 20s timeout, plus encoding fixes (clientType / clientID resolution)
+- **MCP remote terminal tools**: one-shot exec_command plus persistent terminal_open / terminal_exec / terminal_close (cwd and environment preserved, 300s idle sweep); sentinel detection and timeout_ms parsing fixes
+- **MCP remote control tools**: remote_open / remote_close sessions plus remote_keyboard (key_down / up / press / type), remote_mouse (move / click / drag / scroll), and remote_clipboard injection; two-way mutual exclusion with human Web viewing and a hardened busy/closed session state machine
+- **MCP file transfer tools**: download_file (V2 protocol + SHA-256 verification) and upload_file (main-connection upload); client-side lazy `InitFileUpload` in `COMMAND_SEND_FILE_V2` fixes truncated uploads
+- **Client activity history**: records active-window history (capped at 500 entries, skips <5s); new "Activity History" item under the host's Client Management menu with a Unicode edit control for correct UTF-8 title rendering
+- **Log context-menu trio**: right-click "Online Notify", "Ban IP", and "Unban IP" on the message log, with IPv4 extraction applied immediately
+- **Sort preference memory**: host list and process/window list sort preferences persisted (`list\*Sort` registry keys), restored on next launch
+
+**Improvements:**
+- Duplicate connections parked as standby and promoted after the old connection times out / disconnects, avoiding reconnect loops and false offline notifications
+- Remote desktop and virtual screen dialog titles show the host remark instead of the IP (falling back to IP)
+- Three-state host list sorting (ascending → descending → restore default, default rebuilt by online time)
+- Icons added to three online-host context menu items (bitmap array 63→66)
+
+**Bug fixes:**
+- Client screen-control batch misparse: record count that is a multiple of 7 was misclassified as MSG32, garbling injected input (`%48==0` checked first)
+- Heartbeat deferred-update use-after-free: IoRefCount held across PostMessage plus explicit memcpy truncation
+- ONLINELIST_PRIVILEGE enum shift corrupted the history host database (column moved to 16)
+- Remote desktop cursor cross-contamination across dialogs (routed via `OnSetCursor` per window)
+- Client log dialog stopped refreshing past the EDIT control limit (`SetLimitText(0)`)
+- Window manager view check reading stale state, process-list architecture column sort no-op, and FRP/NAT window-title mojibake
+
### v1.3.8 (2026.8.3)
**SYSTEM-level Client & Master Usability Enhancements & Bug Fixes**
diff --git a/ReadMe_TW.md b/ReadMe_TW.md
index 49c4d12..6144cb6 100644
--- a/ReadMe_TW.md
+++ b/ReadMe_TW.md
@@ -378,6 +378,34 @@ nohup ./server_linux_amd64 --port 6543 --http-port 9001 > yama.log 2>&1 &
## 更新日誌
+### v1.3.9 (2026.9.2)
+
+**MCP 伺服端整合(AI 遠端管理)& 遠端控制與檔案傳輸閉環 & 主控增強**
+
+**新功能:**
+- **MCP 伺服端整合**:本地 `127.0.0.1:6544` 暴露 JSON-RPC 2.0 介面,Bearer Token 鑑權,「擴充 > MCP 設定」對話框設定啟用 / 連接埠 / 綁定 / Token;23 個工具覆蓋「觀測 → 執行 → 控制 → 傳輸」全鏈路,預設關閉、分級開關(唯讀 / 白名單 / 終端 / 遠端控制 / 檔案傳輸)全面稽核
+- **MCP 觀測類工具(唯讀)**:search_hosts、get_host_detail、list_processes、list_windows、get_activity_history、list_files、get_screenshot(可選 max_width)、list_services、get_client_log、list_registry、get_audit_log;單飛請求登錄表 20s 逾時 + 編碼修正(clientType / clientID 定位)
+- **MCP 遠端終端工具**:exec_command 一次性執行 + terminal_open / terminal_exec / terminal_close 持久終端(cwd / 環境保留,閒置 300s 清掃),哨兵判定與 timeout_ms 解析修復
+- **MCP 遠端控制工具**:remote_open / remote_close 工作階段 + remote_keyboard(key_down / up / press / type)、remote_mouse(move / click / drag / scroll)、remote_clipboard 注入;與人工 Web 查看雙向互斥,工作階段狀態機 busy / closed 加固
+- **MCP 檔案傳輸工具**:download_file(V2 協定 + SHA-256 校驗)、upload_file(主連線上傳),用戶端側 `COMMAND_SEND_FILE_V2` 懶初始化 `InitFileUpload` 修復上傳截斷
+- **用戶端活動歷史**:記錄活躍視窗歷史(上限 500 條、跳過 <5s),主機「用戶端管理」子選單新增「活動歷史」對話框,Unicode 編輯控件正確渲染 UTF-8 標題
+- **訊息右鍵選單三連**:訊息記錄右鍵新增「線上通知」「封鎖 IP」「解封 IP」,IPv4 提取即時生效
+- **列表排序記憶**:主機列表、處理程序 / 視窗列表排序偏好持久化(`list\*Sort` 登錄檔鍵),下次啟動預設沿用
+
+**改進:**
+- 重複連線 standby 處理:重複登入暫存 standby 待舊連線逾時 / 斷線後晉升,避免循環重連與誤報離線
+- 遠端桌面 / 虛擬螢幕對話框標題顯示主機備註而非 IP(無備註回退 IP)
+- 主機列表三態排序(升冪 → 降冪 → 恢復預設,預設序按上線時間重建)
+- 線上主機右鍵三個選單項目新增圖示(位圖陣列 63→66)
+
+**Bug 修復:**
+- 用戶端螢幕控制批次解析錯誤:記錄數是 7 的倍數時誤判 MSG32 致注入錯亂(`%48==0` 優先)
+- 心跳延遲更新 use-after-free:跨 PostMessage 持有 IoRefCount + memcpy 顯式截斷
+- ONLINELIST_PRIVILEGE 列舉錯位損壞歷史資料庫(權限列移至 16)
+- 遠端桌面游標跨對話框污染(改 `OnSetCursor` 逐視窗路由)
+- 用戶端記錄對話框 EDIT 上限停止刷新(`SetLimitText(0)`)
+- 視窗管理員檢視檢查讀取陳舊狀態、處理程序列表架構欄排序無效、FRP / NAT 下視窗標題亂碼
+
### v1.3.8 (2026.8.3)
**SYSTEM 權限用戶端 & 主控可用性增強 & Bug 修復**
diff --git a/client/Script.rc b/client/Script.rc
index 0c0dc9b..cbf8bb1 100644
--- a/client/Script.rc
+++ b/client/Script.rc
@@ -88,7 +88,7 @@ IDR_WAVE WAVE "Res\\msg.wav"
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,3,8
+ FILEVERSION 1,0,3,9
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@@ -106,7 +106,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "FUCK THE UNIVERSE"
VALUE "FileDescription", "A GHOST"
- VALUE "FileVersion", "1.0.3.8"
+ VALUE "FileVersion", "1.0.3.9"
VALUE "InternalName", "ServerDll.dll"
VALUE "LegalCopyright", "Copyright (C) 2019-2026"
VALUE "OriginalFilename", "ServerDll.dll"
diff --git a/client/TestRun.rc b/client/TestRun.rc
index 5b24a46..1832284 100644
Binary files a/client/TestRun.rc and b/client/TestRun.rc differ
diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc
index 14d6916..4657c80 100644
Binary files a/server/2015Remote/2015Remote.rc and b/server/2015Remote/2015Remote.rc differ
diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj b/server/2015Remote/2015Remote_vs2015.vcxproj
index c404ef5..62d22c9 100644
--- a/server/2015Remote/2015Remote_vs2015.vcxproj
+++ b/server/2015Remote/2015Remote_vs2015.vcxproj
@@ -518,6 +518,7 @@
+
@@ -534,6 +535,7 @@
+
@@ -552,6 +554,7 @@
+
diff --git a/server/2015Remote/2015Remote_vs2015.vcxproj.filters b/server/2015Remote/2015Remote_vs2015.vcxproj.filters
index 1636b89..4ae1c0e 100644
--- a/server/2015Remote/2015Remote_vs2015.vcxproj.filters
+++ b/server/2015Remote/2015Remote_vs2015.vcxproj.filters
@@ -88,6 +88,8 @@
+
+
@@ -196,6 +198,8 @@
+
+
@@ -338,5 +342,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/server/2015Remote/McpSettingsDlg.cpp b/server/2015Remote/McpSettingsDlg.cpp
index f186055..92f65e1 100644
--- a/server/2015Remote/McpSettingsDlg.cpp
+++ b/server/2015Remote/McpSettingsDlg.cpp
@@ -294,7 +294,17 @@ void CMcpSettingsDlg::LayoutControls(int cx, int cy)
m_editWhitelist.MoveWindow(margin + labelW, y - 2, cx - margin * 2 - labelW, whitelistH);
y += whitelistH + gap;
- int bottomY = cy - margin - btnH;
- m_btnCancel.MoveWindow(cx - margin - btnW, bottomY, btnW, btnH);
- m_btnOK.MoveWindow(cx - margin - btnW * 2 - gap, bottomY, btnW, btnH);
+ // 确定 / 取消按钮紧跟白名单下方,不再锚定到底部,避免白名单与按钮之间出现大段空白。
+ m_btnCancel.MoveWindow(cx - margin - btnW, y, btnW, btnH);
+ m_btnOK.MoveWindow(cx - margin - btnW * 2 - gap, y, btnW, btnH);
+ y += btnH + margin;
+
+ // 收缩对话框到内容实际高度并重新居中,消除底部空白。
+ if (y < cy) {
+ CRect wnd;
+ GetWindowRect(&wnd);
+ SetWindowPos(NULL, 0, 0, wnd.Width(), y + (wnd.Height() - cy),
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+ CenterWindow();
+ }
}
diff --git a/server/2015Remote/UIBranding.h b/server/2015Remote/UIBranding.h
index 9af49bb..4ed20c1 100644
--- a/server/2015Remote/UIBranding.h
+++ b/server/2015Remote/UIBranding.h
@@ -46,7 +46,7 @@
// 程序版本号 [建议格式: X.Y.Z]
// 影响:关于对话框、标题栏
-#define BRAND_VERSION "1.3.8"
+#define BRAND_VERSION "1.3.9"
// 启动画面名称 [建议大写,更有 Logo 感]
// 影响:启动画面 Logo 文字(大号艺术字体渲染)
diff --git a/server/2015Remote/lang/en_US.ini b/server/2015Remote/lang/en_US.ini
index 1d9fe1d..03b2514 100644
--- a/server/2015Remote/lang/en_US.ini
+++ b/server/2015Remote/lang/en_US.ini
@@ -1987,10 +1987,15 @@ MCP
˿Ϊ 1-65535 =Port must be a number between 1 and 65535
Token Ϊ=Token cannot be empty
MCP ѱ档=MCP settings saved.
-/˿/ַ/Token/ֻ//־ն˵ĸĶЧ=Changes to enable/port/bind/token/read-only/whitelist/persistent terminal take effect after restart.
+/˿/ַ/Token/ֻ//־ն/Զ̿/ļĸĶЧ=Changes to enable/port/bind address/token/read-only/whitelist/persistent terminal/remote control/file transfer take effect after restart.
ֻģʽִУ=Read-only mode (disable command execution)
=Command whitelist
MCPִ=MCP command execution
ó־նˣȫް=Enable persistent terminal (full commands, no whitelist)
-־ն˽ֻģʽرʱЧ=Persistent terminal takes effect only when read-only mode is off.
+־նԶ̿ƽֻģʽرʱЧ=Persistent terminal and remote control take effect only when read-only mode is off.
MCP־ն=MCP persistent terminal
+MCPԶ̿=MCP remote control
+MCPļ=MCP file transfer
+Token=Token
+Զ̿ƣAI ٿ棩=Enable remote control (AI controls the desktop)
+ļ䣨download_file=Enable file transfer (download_file)
diff --git a/server/2015Remote/lang/zh_TW.ini b/server/2015Remote/lang/zh_TW.ini
index 57a42da..5bc825f 100644
--- a/server/2015Remote/lang/zh_TW.ini
+++ b/server/2015Remote/lang/zh_TW.ini
@@ -1978,10 +1978,15 @@ MCP
˿Ϊ 1-65535 =BӲ 1-65535 Ĕ
Token Ϊ=Token ܞ
MCP ѱ档=MCP Oу档
-/˿/ַ/Token/ֻ//־ն˵ĸĶЧ=/BӲ/λַ/Token/Ψx//־ýK˵׃ӳʽЧ
+/˿/ַ/Token/ֻ//־ն/Զ̿/ļĸĶЧ=/BӲ/λַ/Token/Ψx//־ýK/h˿/nݔ׃ӳʽЧ
ֻģʽִУ=ΨxģʽУ
=
MCPִ=MCP
ó־նˣȫް=ó־ýKˣoΣ
-־ն˽ֻģʽرʱЧ=־ýK˃HΨxģʽP]rЧ
+־նԶ̿ƽֻģʽرʱЧ=־ýKch˿ƃHΨxģʽP]rЧ
MCP־ն=MCP־ýK
+MCPԶ̿=MCPh˿
+MCPļ=MCPnݔ
+Token=Token
+Զ̿ƣAI ٿ棩=h˿ƣAI ٿ棩
+ļ䣨download_file=Ùnݔdownload_file