798456032eddc91b057c0d13b89c0cd2c51b14b5
85
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b7f87c958a |
Feature: support process management on rooted Android hosts
Android 7 起 /proc 是 hidepid=2 + SELinux,普通 APK 连其它 PID 都看不到, 因此进程管理做成 root-only:登录时探测 su(常见路径 + which su,都不行再 su -c id 兜底),有 root 才声明 CLIENT_CAP_PROCESS。否定结果只缓存 5 分钟, 避免用户误点一次「拒绝」后整个进程生命周期都用不了。 - 客户端:RootProcess.kt 通过 su 枚举 /proc、批量 kill;子连接协议与 Linux 一致(TOKEN_PSLIST / COMMAND_KILLPROCESS / 空 TOKEN_WSLIST)。 - 服务端:MCP list_processes/kill_process 与 GUI 进程管理对无能力位的 APK 直接回「需要 root」,不再下发 COMMAND_SYSTEM 后干等超时。 验证:Android 编译通过;模拟器上的 su 仅 root:shell 可执行,验证了非 root 拒绝路径(MCP -32005 + GUI 提示)。真 root 设备的枚举/kill 待实机验证。 Model: deepseek-flash Co-Authored-By: Claude Code <noreply@anthropic.com> |
||
|
|
28c0c9a2a6 |
Feature: add file management to the Android client
Android 客户端此前没有文件管理:声明了 CLIENT_CAP_V2 却没有实现,主控的 文件管理对话框和 MCP 的 list_files/download_file/upload_file 对 APK 只会 超时。本次复用 Linux/macOS 已在用的 common/FileManager.h,只补平台差异: - 盘符模型:P=应用私有目录、I=内部存储、S/T/...=SD 卡与 U 盘;V2 上传 通过 FileTransferV2::SetPathMapper 复用同一套映射。 - 文件通道线上是 GBK。NDK 的 iconv 要 API 28,客户端 minSdk 是 21,改走 JNI -> Java Charset(NativeText.kt),严格模式失败原样透传。 - Android 11+ 引导开启「所有文件访问」;未授权时只挂 P: 并回一条提示。 API <=29 用运行时存储权限 + requestLegacyExternalStorage。 - 顺带实现 COMMAND_SEARCH_FILE(深度 32、1 万条),并让 MCP 的 list_files/download_file/upload_file/read_file 对 APK 开闸。 验证:arm64/armeabi 与模拟器 ABI 编译通过;模拟器上用 MCP 完成列盘、 列目录、下载、上传、中文文件名往返,GUI 文件管理器正常显示 P:/I:/S:。 Model: deepseek-flash Co-Authored-By: Claude Code <noreply@anthropic.com> |
||
|
|
7172ab376d |
Feature: add build_client MCP tool and improve build dialog linkage
Add a service-local MCP tool, build_client, that patches a client template with this master's connect settings and writes the binary on the server. It covers ghost/TestRun/ServerDll/TinyRun plus Linux, macOS and Android, reusing the same byte path as CBuildDlg::OnBnClickedOk (CONNECT_ADDRESS overwrite, build-date check, embedded TLS anchor before UPX/padding). ShellCode AES and payload impersonation stay dialog-only. The tool is gated by a new McpBuild switch (default 0) and McpReadonly=0. It refuses to overwrite an existing file unless overwrite=true, protects the server binaries/settings.ini/upx.exe, validates names strictly and uses a unique UPX temp file so it cannot race the dialog. Results report the path, size, target, TLS-anchor status and follow-up tips. In the build dialog, Linux/macOS/Android targets now also grey out the install-location combo/label and run mode, save and restore the Windows compress choice, hide payload/download rows, grey the random-name and run-as-admin menu items, and fix the TLS-anchor label for posix targets. OnBnClickedOk is untouched; generated output is unchanged for every target. New UI strings were added to the en_US, zh_TW and de_DE language packs. McpBuild is off by default and changes require a server restart. Verified on a Debug x64 instance: MCP generation for Linux is patched correctly, Android and ghost anchor/error paths behave, and dialog-driven Linux/TestRun/SC_AES generation still succeeds. mcp/tools.json regenerated (55 tools); check_platform_table.py passes. Co-Authored-By: deepseek-flash |
||
|
|
06b93f7bdb |
Feat(client): complete the macOS feature set (phase 0 and 1)
Phase 0 makes implementations that already existed reachable. macOS now declares TERMINAL, SCREEN_CLIPBOARD, PROCESS and C2C_RECV_ACK; PROCESS is a new bit and Linux declares it too. SystemManager was dead code -- its constructor took a second argument and it did not derive IOCPManager, so the sub-connection skeleton could never instantiate it -- and now matches the createHandler/OnReceive contract, so COMMAND_SYSTEM really spawns a sub-connection (proc_listpids, SIGKILL). DataProcess always gets a NULL user, so main.mm keeps a g_pMainClient handle and the V2 C2C receiver finally answers TOKEN_C2C_RECV_RESULT. The server asks for SupportsTerminal() on MAC for exec_command / terminal_* and for SupportsProcess() for kill_process, so an old build gets "client is too old" instead of a command nobody answers; kToolPlatforms and mcp/tools.json follow. http_probe stays win/lnx: the terminal works on macOS, but the probe uses GNU-only base64 -w. Phase 1 is POSIX parity. ScreenPreview captures through CGDisplayCreateImage, scales and ships BGRX for the server to encode, and the capability is only declared when preflight or a real capture says the display is readable. ActivityHistory samples the frontmost layer-0 window once a second and prints the same records as Windows and Linux. COMMAND_SCREEN_KEYFRAME_REQ is now consumed by Linux (x264 IDR) and macOS (VideoToolbox force keyframe): the receive thread raises a flag, the capture thread -- which owns the encoder -- consumes it and puts it back if the frame never went out. The macOS quality level persists in NSUserDefaults because main.mm rewrites config.conf. Linux client and Debug x64 server rebuild green; check_platform_table PASS. Not built or run on a Mac. Co-Authored-By: deepseek-flash |
||
|
|
a818ace83c |
Fix(mcp): declare conditional tool arguments and surface probe headers
Several tools enforced argument requirements that existed only in prose, so a model had to send a bad call to learn them. A new AppendConditionalRequired helper emits allOf/if/then entries, and the schemas now say: - get_screenshot: mode=region needs width and height; mode=window needs hwnd. monitor keeps its default of 0. - remote_keyboard: action=type needs text; key_down/key_up/key_press need key. - remote_mouse: action=drag needs x2 and y2. - terminal_exec: command or session_id, at least one (anyOf), matching the handler's -32602 when both are missing. http_probe put the response headers only in structuredContent, which a client that reads the text block never sees; Location, Set-Cookie and Content-Type are exactly what a redirect or auth decision needs. The text block now starts with a headers section, bounded to 4096 bytes and 1200 bytes per line, backing off to a UTF-8 boundary when a line has to be cut. The full set stays in structuredContent.headers. mcp/tools.json mirrors the schemas and tools_minimal.json is regenerated. Verified against a fresh Debug build: verify_tools --live reports 49 tools identical. Co-Authored-By: deepseek-flash |
||
|
|
61b9031269 |
Fix(mcp): bound host_inspect, precheck remote_open, name the busy holder
Three smaller contract fixes that remove ways for an agent call to hang or fail without an explanation: - host_inspect with several aspects opens one sub-connection per aspect (5s ready + 12s list each), so all ten could run ~170s and outlive the caller's HTTP timeout. After 60s no new aspect is started; the running one finishes on its own timeout and the skipped ones land in errors.<aspect> with code -32001 and a "skipped:" message, so the model can retry with fewer aspects. - remote_open checked nothing before opening the hidden screen session. A Linux host that declares capability bits but not CLIENT_CAP_SCREEN_PREVIEW has no X11 display, so capture and injection cannot work: return -32005 immediately instead of waiting out timeout_ms and then reporting a sub-connection timeout. Android is deliberately excluded -- its SCREEN_PREVIEW bit tracks accessibility (API 30+ takeScreenshot for get_screenshot), while remote control uses MediaProjection capture and dispatchGesture, which can work without it. Old hosts with empty caps are still let through. - The -32003 busy errors in remote_open now append the DescribeBusy suffix (tool, elapsed), matching the other busy paths. tools.json descriptions are kept byte-identical to the C++ literals. Debug build green; check_platform_table, gen_go_tools --check and go test ./... pass. Co-Authored-By: deepseek-flash |
||
|
|
d49ebe521d |
Docs(mcp): correct claims in the server instructions agents rely on
The initialize.instructions text is the only guide a model gets (it cannot read docs/), and several statements disagreed with the code: - get_keylog was described as always visible; it is gated by McpKeylog and hidden when the switch is off. - Dangerous machine actions were not mentioned: freeze/thaw and stop/restart stay in tools/list but need McpMachineDangerous and return -32006 at call time. - -32006 was described as policy/admin-only; MFC also returns it when an old client lacks CLIENT_CAP_V2. The Go server returns -32005 for that case, so its own instructions now say so. - -32001 advice assumed every failure is a timeout; it also covers cancellations, http_probe parse failures and unconfirmed writes. - "Unsupported combos always return -32005 immediately" ignored paths that surface as -32001 once a sub-connection is involved. - Linux matrix listed all host_* as unsupported, but host_set_remark and host_set_watch_level only touch server-local data. - local_dir / local_path are paths on the controller, not the user's box. Also align the error table and platform distribution in the docs, and note that hidden fallback aliases remain callable. Debug build green; go test, check_platform_table and gen_go_tools --check pass. Co-Authored-By: deepseek-flash |
||
|
|
292c3191dc |
Fix(mcp): make declared schemas match what the handlers return
Several tool contracts disagreed with the runtime shape, which forces an
agent to guess instead of following outputSchema:
- get_server_status returned {"status": {...}} while outputSchema has the
fields at top level; return the status object directly.
- get_screenshot description claimed structuredContent.image carries the
base64 data; it only carries mimeType/width/height/bytes, the bytes are
in the content image block.
- host_control_service accepted service_name silently, but not in schema;
document the alias and add anyOf [{required:[name]},{required:[service_name]}]
so a call missing both fails at validation, not at execution.
- kill_network_connection dry_run invented dryRun/connection fields absent
from ActionOutputSchema; use the shared BuildDryRunResult shape.
- search_file outputSchema left files.items untyped; declare
path/name/modified/dir/size and the paging fields it already emits.
- chat_* id hints still named the removed list_online_hosts/search_hosts.
tools.json hunks keep the live-dump key order (alphabetical inside schemas),
tools_minimal.json is regenerated, and mcp_smoke.ps1 now reads the flat
structuredContent. Debug build green; check_platform_table, gen_go_tools
--check and go test ./... pass.
Co-Authored-By: deepseek-flash
|
||
|
|
5e012019ba |
Fix(mcp): list the whole directory before paging list_files
list_files stopped parsing at 500 entries, so a larger directory reported total=500 with hasMore=false and offsets past 500 returned nothing: the model was told a false limit and could not reach the tail. Parse the full TOKEN_FILE_LIST payload (100000 cap only to bound a pathological directory), page over it, and report truncated=true plus a summary note when the cap hits. Only an empty path now means list drives. Windows "." "/" "\" are normalized to empty in BuildListFiles, while Linux/macOS "/" is a real root directory and is listed; OnDriveList no longer keeps its own copy of the magic-path rule. The file-manager channel carries GBK both ways (Windows FindFirstFileA; common/FileManager.h runs gbkToUtf8 on incoming paths, utf8ToGbk on outgoing names). The old CP_UTF8 choice for LNX/MAC decoded GBK names wrongly and sent UTF-8 paths to a client that treats them as GBK. Paths now go out as GBK, or as raw UTF-8 when GBK cannot represent them (the client's iconv then passes the bytes through). Names decode GBK-first, UTF-8 on failure: UTF-8-first misreads ~18% of common hanzi whose GBK bytes are also valid UTF-8. Go's server gets the same contract: 100000 cap, truncated in structuredContent, and the cap check after a real record so an exact-cap listing with trailing padding is not called truncated. tools_minimal.json is regenerated; the Go truncation test and the design doc are updated. Debug server builds; check_platform_table, gen_go_tools --check and go test ./... pass. The Release instance was not rebuilt or restarted. Co-Authored-By: deepseek-flash |
||
|
|
42dd70fe20 |
Fix(mcp): make terminal busy and cancel semantics usable by an agent
exec_command answered -32003 "device busy" with no way forward: the message named neither the occupying session nor how to free it, and mcp_cancel_session could only target in-flight calls, so a persistent terminal left behind by an earlier session blocked the host until its idle timer expired. An agent had no route back to a working state. Build the busy text from the live session table: terminal sessions now report parent session_id, idle and elapsed seconds, and point at terminal_exec (or terminal_close with id and session_id) when a persistent session holds the host, or at mcp_cancel_session(request_id) when the occupier is a running exec_command. exec_command sweeps idle terminals before it begins a pending wait, so a session abandoned after 300s does not require a terminal_* call first; SweepIdleTerminals now requires started so it cannot reclaim a session that is still in BeginTermPending and hand the device to a second caller. Cancel becomes addressable and honest. id=0 is rejected with -32602 instead of being treated as "all hosts", the calling request is excluded from matched and released (previously the poll saw itself and released was never true), rows carry cancellable, and when nothing was cancelled the reply lists what matched and which close tool takes it. Instructions, tool description, inputSchema (anyOf request_id/id/session_id) and the released description now agree: kind=call only, persistent sessions close by id+session_id, pending and file_transfer entries are released by cancelling the call that owns them. tools.json is regenerated for the schema and description changes. Debug server builds, check_platform_table.py and gen_go_tools.py --check pass; the Release instance was not rebuilt or restarted. Co-Authored-By: deepseek-flash |
||
|
|
425d737ca0 |
Fix(mcp): harden terminal teardown and fill annotation gaps
OnTerminalClosed now erases the shell route and nulls the session pointer before OfflineProc returns that context to the pool, and WaitTerminalReady re-looks-up the session on every wake, failing with cleanup when it is gone, closed, or has no sub-connection. Before, a waiter could CancelIO a recycled context, or a late cleanup could unroute a connection that reused it. terminal_close only set closed and expected a waiter to clean up, so after a caller timeout the remote shell kept running and the slot stayed busy for an hour. A waiters counter now separates the cases: with a waiter the close hands off, without one it erases the session and cancels IO at once. WaitTermCommand's closed branch keeps a truncated tail pollable instead of dropping it, cancelling IO immediately, and the drained poll cleans up. The write side had the same hazard. exec_command, terminal_exec and http_probe wrote the command line after the prompt wait without rechecking the sub-connection; IsTermSubCtxLive now skips the write when the shell has died, and WaitTerminalDone reports closed on every failure path so callers never CancelIO a pointer that may be back in the pool. list_hosts, read_file and http_probe were missing from kToolHints and got destructive defaults; the first two are now read-only/idempotent, http_probe stays writable because its method can mutate the probed service. Verified on the isolated Debug instance: the truncated tail drains without gaps (12514 lines), a waiterless close frees the slot in 0.1s, and the terminal, exec_command, http_probe, 8a/8b/8c and verify_tools checks pass. Co-Authored-By: deepseek-flash |
||
|
|
5841f27df9 |
Feature(mcp): unify window and service controls behind one name per state
operate_window / host_control_window and control_service / host_control_service were two implementations of the same intent. tools/list now exposes exactly one of each pair, chosen by McpMachine: the host_control_* names when host management is enabled, the main-connection names when it is not. The advertised tool accepts the union of actions. host_control_window routes close/show to the main-connection implementation, which stays the only path with close/show semantics and requires McpManage; the machine path keeps its post-action verification for restore/hide/maximize/minimize/activate. host_control_service routes set_auto/set_manual the same way and rejects dry_run for them instead of pretending to run one. Both old names remain callable aliases, and service_name is accepted as an alias for the machine tool's name parameter. The manifest generator treats the two main-connection tools as !machine entries, so the two-capture union still covers both states. tools/list is 49 entries when everything is on (was 51) and 47 when host management is off; the response shrinks from 193,008 B to 168,634 B (-12.6%), short of the 15% estimate because state-conditional tools must stay in the manifest. The plan document records that measurement and the reason. Verified with a dedicated two-state test: visibility matrix, close/show and set_auto/set_manual routing through dry_run and validation paths, alias dispatch, and -32006 for host_* names when host management is off. Step 8a/8b regressions and verify_tools --live still pass. Co-Authored-By: deepseek-flash |
||
|
|
c73db530f4 |
Feature(mcp): hide the degraded list_* tools when host management is on
host_inspect now covers processes, windows and services, so with McpMachine=1 the older list_processes / list_windows / list_services entries only competed with it: same intent, two names, two long descriptions to read before choosing. They no longer appear in tools/list while host management is enabled, but their names still dispatch, so callers that cached them keep working. They must stay visible when McpMachine=0: that is the default state and the only way such a server can list processes, windows or services, so the entries sit behind !IsMachineEnabled() rather than being removed. list_network_connections is deliberately not folded in: it reads the connection-manager view (IPv6 rows, killable flag, numeric state) which host_inspect's IPv4-only network aspect does not provide. tools.json is now generated from two captures, all-switches-on plus McpMachine=0, because neither state contains the whole surface; the off-state entries are marked gate "!machine" and verify_tools.py skips them when comparing against an all-on server. tools/list went from 54 to 51 entries and from 183,336 B to 171,929 B (-6.2%). Co-Authored-By: deepseek-flash |
||
|
|
59f0f16f74 |
Feature(mcp): merge the ten host_list_* tools into host_inspect
The ten read-only host-management tools (host_list_processes, windows, network_state, software, browser_history, favorites, win32_services, driver_services, scheduled_tasks, host_get_hosts_file) each carried a name, description and schema for what is one connection to the host, one tab id per aspect and one paged list shape. Ten entries made tools/list hard to scan and took a large share of the description budget. They are now one tool, host_inspect(aspects[], ...), where aspects is a required, deduplicated array of the ten former names. A single aspect returns exactly what the old tool returned (same builder, same code path), so output is byte-identical; several aspects are fetched over separate managed sessions and merged into results.<aspect>, with failures isolated in errors.<aspect> and isError only when every aspect failed. Filters (pid/name/arch/title/url/publisher/folder/status/ start_type/process/protocol/ports/state/max_bytes) are still applied server-side before paging and are ignored by aspects they don't apply to. The old names stay as dispatch aliases so existing callers keep working but no longer appear in tools/list; the platform table, batch read-only list, tool hints, instructions, generator tables and the captured mcp/tools.json move to the new name (63 tools -> 54). The description also notes that win32_services / driver_services need an elevated client: a non-elevated one cannot open SCM and never answers, so the call times out after ~12 s. Co-Authored-By: deepseek-flash |
||
|
|
cac5adaafc |
Docs(mcp): distinguish client runtime log from business app logs
get_client_log reads the YAMA client's own in-memory ring buffer, but its description could easily be read as "the logs of whatever program runs on the host". That misreading sends callers looking for business logs into the wrong tool and back out empty-handed. The description now opens by saying this is not the business program's log, points at read_file with offset=-N for reading files on the host, and states that this tool is for client/connection troubleshooting. read_file's description gains the same explicit offset=-N hint at the tail where log-reading is recommended. Descriptions only - no behavior change. mcp/tools.json regenerated from the live capture. Co-Authored-By: deepseek-flash |
||
|
|
88269df548 |
Feature(mcp): merge the three host-list tools into list_hosts
list_online_hosts, search_hosts and list_all_hosts differed only in whether offline hosts were included and in which filter fields they accepted, which made the host-list surface confusing and duplicated three handlers over the same CollectAllHosts snapshot. They now share one tool, list_hosts(query?, online?=true, include_offline?=false, group?, os?, client_type?, limit?, offset?). The old names stay as aliases routed to the same handler, so existing callers keep working, but tools/list exposes only list_hosts. The legacy "offline" boolean of list_all_hosts is still honored, and list_all_hosts keeps its online+offline default. With offline history included the list is now ordered online-first: the host library holds thousands of records, so the default page of 100 would otherwise be all stale entries and the online hosts a caller can actually operate on would be buried behind paging. instructions, every id-description string, the platform table, the tools.json generator and the captured mcp/tools.json are updated to the new name (65 tools -> 63). Co-Authored-By: deepseek-flash |
||
|
|
613aa7291a |
Feature(mcp): add http_probe for private-network HTTP checks
Run an HTTP/HTTPS request inside a shell on a managed host and return a structured result: status code, headers, body (UTF-8 or base64), size and elapsed time, so interface health on the host or its subnet can be checked without a full remote-control session. The safety boundary is hard-coded on the server, not in the shell script: only http/https and IP literals (or localhost); only loopback and private ranges (127/8, ::1, 10/8, 172.16/12, 192.168/16) are accepted; redirects are not followed; the body is capped at 64KB; TLS certificates are verified. Domain names are refused on purpose - resolving them on the server would probe the wrong network. Windows runs a single-line PowerShell 2.0-compatible script based on HttpWebRequest. Accept/User-Agent/Referer are mapped to their dedicated properties because .NET rejects them through Headers.Add. Linux uses curl with temp files. Payloads cross the terminal channel as 56-character base64 chunks with a declared byte length. ConPTY re-emits the boundary character of lines wider than 80 columns, so single-line base64 arrives corrupted; the length check converts any remaining loss into an explicit error rather than silent garbage. The tool reuses an existing persistent terminal session. Sessions it creates itself are closed after the command and kept only when the probe timed out while still running. Platform gating: Windows and Linux only. Co-Authored-By: deepseek-flash |
||
|
|
697044d84b |
Feature(mcp): add read_file for byte-accurate remote text reads
read_file fetches a single remote file through the existing V2 download channel into a per-call temp directory, decodes it, and deletes the temp files on every exit path. It returns the file size, detected encoding, EOL style, total line count, the requested slice (negative offset counts from the end), a truncation flag and the whole file's SHA-256. Encoding auto-detection follows BOM -> UTF-8 validity -> GBK fallback, and utf-8/gbk/gb18030/latin1 can be forced. Files above 2MB and directories are rejected from the first chunk, so nothing is written to disk for them. The tool is gated by McpFileTransfer only: it never writes to the remote host, so it stays available in readonly mode. The V2 receive path now serves both download_file and read_file. Co-Authored-By: deepseek-flash |
||
|
|
0378e96470 |
Feature(mcp): let terminal_exec open or reuse a session implicitly
terminal_exec no longer requires session_id. Given a command and no session_id, it reuses the host's persistent terminal session or opens one through the same path as terminal_open, and reports session_id, is_pty and reused in the result so the caller can keep using it. Polling still requires the session token. terminal_open now returns the existing session with reused:true instead of -32003 when one is already active. An implicitly created session is invisible to the caller, so rejecting would silently lock the host's single terminal slot and leave exec_command failing with a busy error. A session that is still starting, or one owned by a one-shot exec_command, still answers -32003. The server instruction line that told models to always pair terminal_open with terminal_close is updated accordingly. Co-Authored-By: deepseek-flash |
||
|
|
3fe3a11494 |
Feature(mcp): keep terminal sessions on timeout and allow output polling
terminal_exec used to destroy the persistent session on timeout, so long commands (robocopy, upgrade scripts) could never be observed: the collected output was thrown away and the shell was killed. Waiting is now decoupled from the command: - WaitTermCommand delivers [delivered, ...) and no longer erases on timeout. It returns done:false plus the output produced so far; the session stays busy and polling continues until done:true with exit_code. - Calling terminal_exec with only session_id polls (no command); command is optional and the result gains session_id / done / truncated / dropped_bytes / elapsed_ms. - Request cancellation still destroys the session (-32800 path); shell exit and terminal_close deliver the remaining output and then clean up. - Chunks are capped at max_output_bytes (default 64KB, newline-aligned); the per-command buffer is capped at 8MB and reports dropped_bytes; busy sessions are force-reclaimed after an hour so a host cannot stay busy forever. - A finished command with undrained output returns -32003 with a drain hint instead of silently losing it when the next command clears the buffer. Verified on an isolated Debug instance against a Windows host: a 3s timeout on an 8s ping returns done:false + partial output and two polls finish it; a 277KB dir listing needs 5 polls and then accepts a new command; 200 echo lines delivered in 12 chunks arrive exactly once in order; cancel returns -32800 and destroys the session. tools.json regenerated (63 tools, PASS). Co-Authored-By: deepseek-flash |
||
|
|
b63c97c5eb |
Feature(mcp): allow sc qc/enumdepend/sdshow in default command whitelist
exec_command's read-only default whitelist only listed `sc query`, so service configuration inspection was rejected even though `sc qc` is a read. Add `sc qc`, `sc enumdepend` and `sc sdshow`; `sc start/stop/config/create/delete` stay rejected because matching is prefix based, and a comment says so. verify_tools.py --live now prints the tools/list response size plus the description / inputSchema / outputSchema breakdown, so shrinking tools/list can be measured against a running server. Verified on an isolated Debug instance (port 6555, local test client): sc qc/enumdepend/sdshow/query succeed; powershell, icacls, net user, net localgroup, sc start and `&` chaining still return -32007/-32012; tools.json still matches the live tools/list (63 tools, PASS). Co-Authored-By: deepseek-flash |
||
|
|
a801a2999a |
Feature: Support input blocking and privacy overlay on Android hosts
remote_block_input rejected anything but Windows because the Android client had no COMMAND_SCREEN_BLOCK_INPUT handler. This adds the overlay on the client and the server gating, and wires up COMMAND_SCREEN_BLANK. Client: the accessibility service hangs a full-screen TYPE_ACCESSIBILITY_OVERLAY on itself. block=true makes it transparent and touchable so it swallows physical taps; black=true paints it black. Both are absolute states, so repeated commands are idempotent, and the handler clears the overlay when the screen sub-connection dies (Android has no "released when the calling thread exits" fallback). During a remote gesture the overlay is flipped to FLAG_NOT_TOUCHABLE, mirroring Windows' BlockInput(false) wrap; the flag change and the injection must be separated by a short delay or the gesture is swallowed. Server: CLIENT_CAP_PRIVACY_OVERLAY distinguishes new APKs from old ones; Linux/macOS and old APKs still get -32005 up front. Tool masks, instructions and mcp/tools.json follow the change. COMMAND_SCREEN_BLANK is implemented but not exposed as a tool: MediaProjection captures the overlay, so blacking out the screen blinds the operator too and cannot emulate Windows' WDA_EXCLUDEFROMCAPTURE. Verified on the Android 15 emulator: blocked taps are swallowed while remote clicks still land, the block re-arms after each gesture, the watchdog auto-unblocks at the deadline, a dropped sub-connection clears the overlay, and a black overlay shows up in both screencap and get_screenshot. The committed ghost.apk is stale; rebuild before release. Co-Authored-By: deepseek-flash |
||
|
|
445bd8bbb9 |
Feature: Support the remote terminal on Android hosts
The terminal tools were Windows/Linux only because the Android client had no COMMAND_SHELL handler: the server opened a shell sub-connection and the command was silently dropped, leaving exec_command to time out. This adds the PTY path on the client and the matching server gating. Client: COMMAND_SHELL on the main connection spawns a terminal thread that opens an authenticated sub-connection, sends TOKEN_TERMINAL_START and keeps the PTY alive until the server closes it. common/PTYHandler.h is reused, with a minSdk-21 openpty built from posix_openpt/grantpt and /system/bin/sh (mksh) as the shell. A new CLIENT_CAP_TERMINAL bit lets the server reject old APKs up front with -32005. Server: the tool masks, instructions and docs matrix accept APK. While verifying, exec_command left a second echoed copy of the command line in stdout: mksh forks with ECHO still on, so input written before its line editor takes over is echoed by the line discipline in addition to the shell's own redraw. The server now waits for the shell's first output (the prompt) before sending the command and sentinel, which restores the single-echo assumption the cleaning step relies on. terminal_exec on a ready session is unaffected. Verified on the Android 15 emulator: exec_command returns clean stdout and real exit codes for id/uname/df/ls (including a failing command), and terminal_open keeps cwd across commands, pipes work and close is clean. The committed ghost.apk is stale and must be rebuilt before release; a rebuilt APK was used for this testing. Co-Authored-By: deepseek-flash |
||
|
|
915c587964 |
Feature: Support remote chat on Android hosts
The chat tools were Windows-only because the Android client had no COMMAND_CHAT handler: the server asked for a chat sub-connection and the command was silently dropped, leaving chat_open to time out. This adds the full path on the client and the matching server gating. Client: COMMAND_CHAT on the main connection spawns a chat thread that opens an authenticated sub-connection, sends TOKEN_CHAT_START and waits for the server to bind it. Incoming GBK lines are decoded and dispatched to ChatSession, which drives an in-app chat activity; when accessibility is available the activity is pulled to the front, otherwise a tappable notification is posted. Outgoing text is strictly GBK encoded so emoji and unmappable characters are rejected instead of becoming '?'. When the server ends the session the activity closes itself, matching the Windows client's DestroyWindow, and a new session starts from an empty log. Server: a new CLIENT_CAP_REMOTE_CHAT bit lets the server tell new APKs from old ones. ResolveHost now accepts Windows and Android hosts and rejects older APKs up front with -32005 rather than waiting for the command to expire. Tool platform masks, instructions, the docs matrix and mcp/tools.json follow the same change. Verified end to end on the Android 15 emulator: chat_open pops the activity, Chinese text from the server renders, a device reply reaches chat_wait, and ending the session from the master closes the activity instead of leaving a dead window. The committed ghost.apk is stale and must be rebuilt before release. Co-Authored-By: deepseek-flash |
||
|
|
29d7ee1a18 |
Feature: Support host uninstall on Android and expose uninstall_host
The server's "uninstall host" action is the single-byte TOKEN_UNINSTALL on the main connection. Windows clients have handled it for a long time; the Android client ignored it, so the menu entry silently did nothing there. Handle it in the Android client the only way Android allows: ask the system to uninstall the package. The client first replies with COMMAND_BYE and drops the connection, then opens the package installer's confirmation dialog through the accessibility service, or posts a notification that resumes the dialog from MainActivity when accessibility is off. The user still has to confirm on the device; if they cancel, the client has already left the server and must be reopened by hand. The manifest gains REQUEST_DELETE_PACKAGES, without which the installer activity refuses the request outright. New APKs advertise CLIENT_CAP_UNINSTALL so the server can reject old clients instead of sending a command nobody handles. The new MCP tool uninstall_host is gated on McpManage and McpReadonly=0, rejects Linux and macOS hosts, and offers the same wait=true verification as power_action, reporting went_offline once the host disappears from the online list. Verified on the emulator end to end: the tool returned went_offline after 200 ms, the system dialog appeared, confirming it removed the package. Co-Authored-By: deepseek-flash |
||
|
|
fd1b085279 |
Feature: Add remote lock screen for Android hosts
Implement the Ctrl+Alt+Del path on Android as a system lock screen. Android has no secure attention sequence, so COMMAND_SCREEN_CTRL_ALT_DEL is mapped in the client to GLOBAL_ACTION_LOCK_SCREEN and the server exposes it as the new MCP tool remote_lock_screen. The Android client resolves ControlService.lockScreen()/canLockScreen() in nativeInit and dispatches the command from the screen sub-connection through the usual attach/detach JNI path. The lock action is posted to the accessibility service handler because performGlobalAction must not run on the receiver thread. Login advertises the new CLIENT_CAP_LOCK_SCREEN bit only when the accessibility service is bound and the API level is 28+, so the server can reject old APKs and Windows/Linux hosts up front instead of reporting a lock that never happened. There is no receipt: a successful call only means the command was delivered, and the tool description tells the caller to confirm with get_screenshot. Server side adds the schema and handler next to remote_clipboard, audits the call, and gates it on client type plus the capability bit. Since it is the only APK-only tool, check_platform_table.py gains a documented exemption from the Windows baseline invariant, and make_tools_json.py learns an APK-only platform set. tools.json is regenerated from the live server and the plan document now counts 62 tools. Co-Authored-By: deepseek-flash |
||
|
|
0a0b709e8a |
Feature: Support remote clipboard and input on Android hosts
The MCP remote-control family (remote_open / remote_close / remote_mouse / remote_keyboard / remote_clipboard) previously stopped at Windows and Linux, even though the Android client already translated injected events into touch gestures and global actions. This wires up the missing piece and opens the five tools to APK hosts. Client side, the screen sub-connection now handles COMMAND_SCREEN_SET_CLIPBOARD: the native handler forwards the raw GBK bytes to CaptureService.onClipboardText, which decodes them, strips the trailing NUL that the human clipboard-sync senders append, and writes the system clipboard from a background app (allowed on Android 10+, only reads are restricted). Pasting cannot be a Ctrl+V combo, so VK_V is mapped to ACTION_PASTE on the focused node, falling back to the accessibility focus and then to the first editable node, since WebView and self-drawn inputs often do not flag FOCUS_INPUT or isEditable. A new capability bit CLIENT_CAP_SCREEN_CLIPBOARD (0x0800) tells the server the APK understands both paths, so builds without the handler get an explicit -32005 instead of a package that is silently dropped. action=type is rejected outright for APK hosts - physical key events would only turn 'v' into a paste - and the error points at remote_clipboard + key=V. The platform table, server instructions and the five tool descriptions now describe Android support, which keys actually act as global actions (ESC, HOME, APPS, PRINTSCREEN), and that injection needs the accessibility service while capture needs an authorized MediaProjection session, both without receipts. Verified on the API 35 emulator against a Debug server: ASCII and GBK Chinese text round-tripped through the clipboard into a focused Settings search field, type / expect_hwnd / window_hwnd returned -32005, and PRINTSCREEN produced a saved screenshot. check_platform_table.py and verify_tools.py --offline pass. Co-Authored-By: deepseek-flash |
||
|
|
f29150d20e |
Feature: Add screen preview to the Android client
get_screenshot and the server's online-list and hover thumbnails were gated to Windows and X11 Linux. The Android client now answers COMMAND_SCREEN_PREVIEW_REQ on the main connection with TOKEN_SCREEN_PREVIEW_RSP plus a JPEG, and advertises CLIENT_CAP_SCREEN_PREVIEW at login only when it can really capture. Capture goes through AccessibilityService.takeScreenshot (API 30+), enabled by canTakeScreenshot in the service config. MediaProjection is deliberately not reused: its VirtualDisplay already feeds the H.264 encoder and Android 14+ refuses a second one from the same projection, while accessibility capture runs alongside the live stream. The JPEG is scaled to maxWidth and encoded in Kotlin; native only copies the bytes and drops a request while one is in flight. Only mode=screen is supported, and capabilities are re-evaluated on every login so turning the service off withdraws the capability. Also fix two review findings: a screenshot callback that lands after the 3 s timeout now recycles its bitmap instead of leaking it, and the server's failure hint lists the possible Android causes instead of asserting disabled accessibility. Verified on the emulator against a local debug server: get_screenshot returns 640x1422 and 720x1600 JPEGs, the 120-wide list thumbnail works, and both MCP tool-table checkers pass with apk added for get_screenshot, get_activity_history and get_client_log. Co-Authored-By: deepseek-flash |
||
|
|
5ed1a07dc4 |
Feature: Add activity history to the Android client
get_activity_history was gated to Windows and Linux. The Android client now answers COMMAND_QUERY_ACTIVITY with a TOKEN_REPORT_ACTIVITY snapshot on the main connection, the same RPC shape as the other platforms; the server takes the first packet without CancelIO, so no sub-connection or request correlation is involved. The sampler reuses linux/LinuxActivityHistory.h, whose ActivityHistory class and formatters are platform-neutral, and is fed by a probe that asks the new ControlService.currentActivityTitle() once per second over JNI. The accessibility service already tracks the foreground package from TYPE_WINDOW_STATE_CHANGED; the title is "label (package)" with the label resolved once and cached, "Home" for the launcher, and idle for lock or screen-off, so no permission beyond the service users already enable is needed. Without the service the report says so instead of recording placeholder "Android" entries. Also scope the connection teardown to its own generation: a ConnectionThread that exits late (CaptureService restart) no longer clears the new run's g_running or g_pMainClient, and the report thread takes one local snapshot of the main client pointer. Verified on the emulator against a local debug server: five records (Settings, Chrome, launcher, Home) came back newest-first with dwell times, and disabling accessibility produced the permission hint. Co-Authored-By: deepseek-flash |
||
|
|
d365a4f948 |
Feature: Report client run logs from the Android client
Before this change the Android client's run log went to logcat only: Logger's init tried to create a log directory, enable was true, and the in-memory ring that MCP's get_client_log reads was never fed, so the tool returned an empty log for APK hosts. Logger now has an Android branch that skips the directory and file writer and keeps only the ring, which is always written regardless of enable. Mprintf carries the source file and line as on Windows/Linux, and both android_log (Mprintf) and a new android_log_tag (platform LOGI/LOGE, LOGI_SH/LOGE_SH) print to logcat and append to the ring. A new ClientLogThread opens a sub-connection on COMMAND_QUERY_LOG and lets ClientLogHandler send TOKEN_REPORT_LOG plus the full ring as the first packet. It has to be a sub-connection: the server takes the first packet and calls CancelIO, which would drop the main connection. The server side allows get_client_log on kPlatApk and decodes the payload as UTF-8 like the other POSIX clients. Verified on the emulator against a local debug server: get_client_log returned 21 UTF-8 lines including [file:line] Mprintf output, LOGI lines, and the ClientLogThread handshake. Co-Authored-By: deepseek-flash |
||
|
|
cdd9c56b3d |
Feature: Add window/region capture targets to remote_open
Pass the target HWND through the COMMAND_SCREEN_SPY token and send COMMAND_SCREEN_ROI after session start, so MCP remote control can stream just the target window or region instead of the scaled virtual desktop. The session records the target kind, remote_mouse refuses a redundant window_hwnd basis, and the cached resolution is refreshed per action so resized windows keep mapping correctly. Cold starts now clear the stale resolution cache used by the region handshake. |
||
|
|
5501889d33 |
Feature: Add window-relative remote_mouse coords and PTY pipes in terminal_exec
New Windows clients append an optional 20-byte WINDOWINFO_MCP_DESKTOP block (virtual desktop rect, magic 'VDCP') after the window list, so the server can map window-relative coordinates into the capture frame. remote_mouse accepts an optional window_hwnd; x/y and drag x2/y2 are then normalized against the intersection of the window and the virtual desktop, which is exactly the source rect of get_screenshot mode=window. The target window must be foreground by default, and window_hwnd/expect_hwnd must agree when both are given. structuredContent gains coordinateWindow and resolved (frame coords plus the basis rect), so callers can verify the mapping. terminal_exec now allows pipes, && and || in PTY sessions (ConPTY on Windows, POSIX PTY on Linux) because the sentinel runs on its own line; legacy non-PTY sessions still reject & and |. A read-only PeekTermSession lets the server reject unsupported syntax before BeginTermCommand. POSIX still rejects bare background & (&&, &>, 2>&1 stay allowed). Docs: Mcp_Design.md sections 12.1/20.2/22 and Mcp_Terminal_Design.md 4.4/4.6 are synchronized with the protocol, the new validation order, and the basis rect semantics. Co-Authored-By: deepseek-flash |
||
|
|
235a8a622c |
Feature: Add native region, window and monitor capture to get_screenshot
New Windows clients advertise CLIENT_CAP_SCREEN_REGION and accept a 24-byte ScreenPreviewReqEx appended to the existing 8-byte preview request, so get_screenshot can capture a region, a window or a single monitor at 1:1 resolution instead of only the scaled virtual desktop. Successful v2 responses append an optional ScreenCaptureMeta block reporting the source rect and scale, letting callers map coordinates back for remote input. Old clients and old servers keep the v1 byte stream unchanged. The 8192 px per-side bound only applies to native (1:1) capture, where it guards bitmap memory; scaled captures are unaffected so ultra-wide virtual desktops (for example triple 4K) still produce thumbnails and previews. max_width is clamped to [64,1920] as before instead of rejected, matching the documented schema. Co-Authored-By: deepseek-flash |
||
|
|
b2c0d81396 |
Feature: Add window info RPC for foreground checks and window activation
Add a capability-gated main-connection RPC (COMMAND_MCP_WINDOW_INFO=179 / TOKEN_MCP_WINDOW_INFO=180) that returns visible top-level windows with UTF-8 titles, screen rectangles, foreground flag and z-order, so MCP can verify focus before injecting input. New tool get_foreground_window; host_list_windows switches to the richer fields; host_control_window and operate_window gain action=activate; remote_keyboard and remote_mouse gain expect_hwnd, require_foreground and report_foreground. Old clients keep the previous behavior: the RPC is refused up front via CLIENT_CAP_WINDOW_INFO. The client caps a response at 96 windows (about 101 KB, under MAX_SEND_BUFFER). Signal the cut-off in the mode byte (0x80) instead of silently dropping windows: host_list_windows now reports truncated=true and says the list is incomplete, and activate verification reports state=unknown with reason=list_truncated rather than claiming the window is gone. expect_hwnd is checked only after the session is validated, so an invalid session_id no longer burns a window RPC and no longer reports a window error for a session that does not exist. Nullable output fields (foreground, window) are declared as ["object","null"] so strict clients do not reject responses. Co-Authored-By: deepseek-flash |
||
|
|
5eb44307ee |
Feature: Capture the virtual desktop for multi-monitor remote control
The MCP Observe/Act loop requires screenshots and mouse injection to share one coordinate space. Previously the client sent only the primary monitor while injection used virtual-desktop coordinates, so multi-monitor hosts were rejected outright. - Client: COMMAND_SCREEN_SPY param buffer[11] (wire index 12) now forces whole-virtual-desktop GDI capture; preview JPEGs also cover the virtual desktop including negative origins. - Server: advertise CLIENT_CAP_VIRTUAL_DESKTOP, gate multi-monitor remote control on that capability, and pass the flag when starting the session. Linux stays exempt (X root capture/injection are already consistent). |
||
|
|
d8048979e3 |
Feature: Report activity history on Linux clients
Implement COMMAND_QUERY_ACTIVITY -> TOKEN_REPORT_ACTIVITY with two backends picked at startup. With a desktop, a sampler thread reads the foreground window every second and books dwell time like the Windows client: under five seconds is dropped, five idle minutes close the window, the last 500 records stay newest first, each line being "[YYYY-MM-DD HH:MM:SS] [title] duration". It uses its own ActivityChecker because an Xlib connection cannot be shared with the heartbeat thread, and it is stopped before main's locals go away. A reachable X server is not enough: the window backend is only chosen when the root window carries _NET_SUPPORTING_WM_CHECK, so Xvfb or a bare X without an EWMH window manager falls back to the headless backend instead of sampling a window id that never appears. Without a desktop the answer is computed on demand: logins from "last -n 100 -F" plus bash/zsh history of root and /home/*, tagged [登录] or [命令] after a [来源] header. Both halves are merged and sorted by timestamp; three fifths of the budget goes to logins and reboot records are capped at ten, since a WSL or container writes one reboot per start. activity_commands=0 drops the command half. A single detached thread builds and sends it, only while the main link is up. The MCP gate now admits Linux for get_activity_history and documents both shapes. test/unit/linux covers the parsers, ordering and UTF-8 truncation; 15 cases pass. Co-Authored-By: deepseek-flash |
||
|
|
356aa27108 |
Feature: Reject MCP tool calls the target client cannot handle
tools/list 不带参数,无法按目标设备过滤工具列表。60 个工具里有 33 个只在 Windows 客户端上有实现,模型无从得知,只能下发命令后白等超时。 DispatchSingleHostTool 开头按 kToolPlatforms 表核对目标主机平台,不匹配立刻 返回 -32005;批量路径经由同一函数自动覆盖。主机不存在或离线时放行,把 -32002 留给工具自己报,避免同一个问题出现两种错误码。 支持面是刻意设计的阶梯:win 60/60、lnx 27、mac 16、apk 10。60 个工具全部含 win,所以 Windows 客户端永远不会被这道门禁拒绝,行为与改动前完全一致。 平台表按服务端实际放行来标,不按客户端能力标。两处会分叉的地方: - exec_command / terminal_* / kill_process:macOS 客户端有实现(main.mm:753 的 ShellworkingThread、SystemManager 的 KILLPROCESS),但服务端刻意拦着 (McpServer.cpp:3652「macOS 本轮不开放」、6870),故标 win+lnx。 - list_windows:Linux/macOS 的 SystemManager 都有 COMMAND_WSLIST 分支,但 BuildListWindows 把命令发在主连接上,而这两个平台的主循环只处理 COMMAND_SYSTEM (起子连接),WSLIST 只在子连接里才被处理,走不到。实测 Linux 上直接超时 -32001。那两个 case 是给 SystemDlg 用的,故标 win。 copy_files_c2c 是唯一的非对称工具(源端必须 Windows,目标端可 win/lnx/mac, 反向不支持),用 roles 按参数名分别声明,C++ 侧 CollectTargetReqs 对应处理。 配套 mcp/tools.json(60 个工具,version 2)与 tools/mcp_tools/ 下的抓取、生成、 比对、校验脚本。check_platform_table.py 校验 C++ 表、tools.json、instructions 三方一致,并把「Windows 全量」做成不变式。 已在 A6(Windows 11)与 Ubuntu24(Linux)上实测:Windows 侧 14/14 通过且无误拒, Linux 侧 11 项拒绝全部命中门禁,copy_files_c2c win->lnx 成功、lnx->win 被拒。 开关 McpPlatformGuard(默认 1),关闭只失去提前拦截,不影响任何执行路径。 |
||
|
|
dcb5ae25c6 |
Fix: Paginate get_activity_history results
The tool was the only list-type tool without pagination. The client keeps ACTIVITY_HISTORY_MAX=500 records and Dump() prepends the in-progress window, so a single call returned up to 501 lines of "[time] [title] duration" -- enough to blow up the caller's context, especially since titles carry personal browsing history. Records come back newest-first (m_records uses push_front and the current window is prepended), so the standard limit/offset window applies directly: offset=0 is the most recent page, no need to read total first and count backwards. That ordering is now stated in the tool description so the model can rely on it. - inputSchema: BuildGetHostDetailInputSchema -> BuildPagedHostListInputSchema (adds limit, default 100 / max 1000, and offset) - outputSchema: append AppendPageOutputProps plus truncated - implementation: rename the full split to `all`, slice via ResolvePageWindow and ApplyPageWindow, write back with WritePageFields - activityHistory is rebuilt from the window instead of returning the whole Dump() text -- otherwise the raw copy would bypass pagination entirely - 64 KB byte budget (same as get_client_log), trimmed from the end so the newest records survive; hasMore is computed as offset+kept < total rather than hardcoded true, since a single oversized tail record must not claim there is another page Batch calls need no extra work: the tool is already in IsBatchReadOnlyTool, and BuildBatchCall forwards limit/offset to each host, so ids + limit means "the latest N records of every host". Compiles clean; not yet exercised against a running server (the exe was locked by the live instance). Verification cases are listed in docs/Mcp_Test_Report_2026-10-29.md section 8. |
||
|
|
56a937fabb |
Fix: Three blocking defects found by the MCP tool survey
The survey in docs/Mcp_Test_Report_2026-10-29.md turned up three P0s, each
of which stopped a whole capability rather than degrading it. Two of them
were the same mistake: the input schema promised something the output
schema then rejected. The third was an output with no size limit, plus a
client that never implemented the command at all.
Batch calls could never succeed. A call carrying ids[] goes through
BuildBatchCall, which returns {tool, total, succeeded, failed, skipped,
results[]}; every tool declares only the single-host shape. The client
validates structuredContent against that declaration, so any batch call
failed with -32602: data must have required property 'host' - the input
schema advertises ids, the output schema kills it. Tools/call cannot fix
this one call at a time, so ApplyBatchOutputSchema runs at the end of
tools/list, next to ApplyToolAnnotations, and rewrites the schema of every
tool in the batch list to {type: object, anyOf: [single, batch]}. Placing
it at the end is what makes it cover all three registration points
(inline, McpMachine, McpChat) and any tool added later. IsBatchReadOnlyTool
moved from McpServer.cpp to McpInternal.cpp for the same reason: the list
is now read by tools/call and tools/list, and the two must not drift.
list_registry failed whenever path was omitted. The root-key branch
returns keys only, while the output schema listed values in required as
well, so the first usage the documentation describes - omit path, get the
five root keys - could not work. values is no longer required and the
schema says it is absent in that branch. The root branch also returns
path: "" now, so both branches carry the same field set and callers need
not branch.
get_client_log was unusable on both platforms, for two unrelated reasons.
Windows returned the whole 1000-line ring buffer, 90,473 characters, over
the client's result limit: fetched, then not deliverable. Linux and macOS
timed out because their clients never handled COMMAND_QUERY_LOG at all -
only client/ClientLogManager.cpp does - so TOKEN_REPORT_LOG never arrived.
Adding a limit alone would have left Linux broken; fixing the client alone
would have left Windows over the limit.
The server now takes limit (default 200, max 2000) and filter, and reads
backwards from the end: troubleshooting wants the last thing that happened,
not the first line after boot. A 64 KB byte budget sits under the line
count, because one line can be a stack dump; when the final line alone
exceeds it, the tail is returned and truncated says so. Responses carry
lines_total, lines_matched, lines_returned and truncated. The timeout
message now names the likely cause and two ways around it instead of
saying only "Timeout waiting for client log".
The POSIX clients get common/ClientLogHandler.h, a counterpart to the
Windows CClientLogManager, and one line each in linux/main.cpp and
macos/main.mm. It must open a sub-connection: MessageHandle's
TOKEN_REPORT_LOG branch takes the first packet and then calls CancelIO on
that connection, so answering on the main connection would close the main
connection and drop the client offline.
Verified against a server built at 21:17:21 with both clients rebuilt. A
batch get_host_detail over the two A6 records returns succeeded=2 with
per-host data; host_list_processes with ids returns 2 of 2, which exercises
the McpMachine registration point rather than the inline one; a mixed
Windows/Linux batch of get_client_log returns 2 of 2. list_registry with
no path returns the five root keys and path ""; with a path it still
returns its values. get_client_log on Windows goes from 1000 lines to 200
with truncated=true, and limit=3 with filter=ConnAuth yields 28 matched and
3 returned. On Ubuntu 24.04 it returns logs at all, and the client's own
log shows Enter ClientLogThread, TOKEN_REPORT_LOG, then Leave about a
second later when the server cancels the connection - paired, no leak.
The connector still caches an old input schema for get_client_log, so
limit and filter are rejected locally until it reconnects; the defaults
already cover the P0, and this is the same cache problem as the
copy_files_c2c.overwrite entry in the report's P1 list.
docs/Mcp_Design.md section 18 records the implementation and the reasoning;
section 7 of the test report carries the verification table.
Co-Authored-By: deepseek-flash
|
||
|
|
dc4fd792f6 |
Feature: Implement the Linux screen preview response
The Linux client now answers COMMAND_SCREEN_PREVIEW_REQ, so a host with an X11 desktop gets a thumbnail when it is double-clicked in the online list, a frame in the list's Preview column, and an image from the MCP get_screenshot tool. Previously only Windows clients advertised the capability and Linux hosts showed "预览不可用" after a four second wait. The client does not encode JPEG. Stock desktops ship libjpeg.so.8 whose struct layout is the distribution's ABI (JPEG_LIB_VERSION 80), while the in-tree jpeglib.h is libjpeg-turbo 3.1.1 (62), and libturbojpeg is not installed by default; dlopening the system library against that header fails with "Wrong JPEG library version: library is 80, caller expects 62". Instead the client sends raw pixels in a new screen preview format, SCREEN_PREVIEW_FMT_BGRX: top-down rows of B,G,R,X with no row padding, already scaled to the requested width. The server re-encodes to JPEG at the single ingress point, so the preview popup, the list thumbnail cache and the MCP tool keep consuming JPEG only. Capture follows the path ScreenHandler already uses: root window copied into an offscreen pixmap with an IncludeInferiors GC, then XGetImage, which avoids BadMatch under compositing window managers. The X11 type declarations and the dlopen loader moved out of ScreenHandler.h into linux/X11Loader.h so both users share one dlsym table. The full-size image is never materialized: a box filter reads straight from the XImage rows (honouring bytes_per_line) into the output buffer, scales to maxWidth without upscaling, and clamps the height to 1080 so a portrait 4K desktop cannot produce a 26 MB packet. Rows and columns come out even, which they are for JPEG anyway. The capability bit is now honest about the runtime. LOGIN_INFOR grows DefaultCaps()/SetCaps(), and the client recomputes the bits before every login and re-login: CLIENT_CAP_SCREEN_PREVIEW is set only when DISPLAY is present and the X server actually opens. A headless host therefore gets -32005 "Host does not support screen preview" from MCP instead of a timeout, and a host whose session appears after boot picks it up on the next reconnect. Requests are handled on a detached worker thread behind a single-flight guard (matching the Windows client), so a slow XGetImage never stalls the receive thread and a burst of requests degrades to "no preview" rather than queueing. If the worker thread cannot be created, the guard is released again, so one failure cannot leave every later request rejected as busy until the client restarts. The MCP design note claimed the capability was declared by Windows only, and the get_screenshot tool description said the same; both now say what the code does (Windows always, Linux when a display is reachable). Server side, NormalizeScreenPreviewPacket runs in MessageHandle before the MCP handoff and the PostMessage to the UI thread. It validates that width/height are within the values the server itself can ask for and that bytes equals width*height*4, converts with a stack Gdiplus::Bitmap over the packet's own pixels (no copy, and no DEBUG_NEW trouble), and rewrites the header to JPEG. The encoder output is read back by seeking the stream rather than GlobalSize, so the packet carries no heap-block padding after the EOI marker. Malformed packets are dropped; failure statuses pass through untouched so the existing code can report them. Tested against a Debug server with the WSL Ubuntu 24.04 build as the client. get_screenshot returned valid JPEGs at max_width 480 (480x142, 1.7 KB) and 1920 (1920x570, 17.9 KB), repeatably; the list showed a thumbnail for the GUI client and N/A for a second copy started without DISPLAY, which also answered -32005. The box filter and the BGRX to JPEG conversion were checked separately with quadrant fixtures: the browser over the synthetic B,G,R,X buffer recovers red/green/blue/white in the right channels and the downscale averages, handles non-integer ratios and row padding, and rejects 24bpp and upscaling. The captured frames come out black under WSLg because Xwayland keeps no root pixmap there; that is the compositor, not this code, and Xorg sessions capture normally. Co-Authored-By: deepseek-flash |
||
|
|
13c02fe50b |
Feature: Skip already-present targets in copy_files_c2c
The destination writes every chunk unconditionally, so a second call with the same arguments re-sent the whole file and returned exactly the same result as the first. Measured on an 11 MB log: the target's mtime moved and the entry count did not, and the caller had no way to tell a real transfer from a repeat. upload_file and download_file already answer this with overwrite/skipped; copy_files_c2c was the one that did not. The skip decision has to be made on the server, because the receiving end does not check whether the file exists. Before opening the transfer, a default call now lists one level of dst_dir through ListRemoteTopLevelNames - the helper upload_file already uses - and drops the paths whose basename is already there. If everything is dropped the call returns success without creating a transfer id at all, so no host is occupied and nothing is sent. overwrite=true restores the old unconditional behaviour. Name comparison follows the destination filesystem: folded on Windows, exact on POSIX. That needed a foldCase parameter on the helper, defaulted to true so upload_file keeps its behaviour. dst_dir is handed to the listing without its trailing separator, because the client concatenates "%s\*.*" and a trailing one produces "C://*.*", which FindFirstFile rejects. search_file hit the same thing. No protocol change and no client change: the packet layout, the receiver and both client platforms are untouched. Verified against a real server (build 2026-10-29 14:34:33) with a Windows 11 source and both an Ubuntu 24.04 and a Windows 11 destination. A second default call returns file_count=0, skipped=1, an empty transfer_id and skip_check_failed=false with the target's mtime unchanged; overwrite=true advances the mtime (1793276909 -> 1793281657) and reports skipped=0; a call into a non-existent directory creates it and lands the file flat; a Windows destination folds case, so a placeholder SETTINGS.INI makes a later settings.ini skip, while a POSIX destination leaves both files side by side. One documented case does not hold, and the expectation was mine rather than the code's. "Destination occupied by another tool" was supposed to fail the pre-check and still transfer with skip_check_failed=true, but BeginC2CTransfer consults the same m_Pending registry for src_id and dst_id, so the transfer is refused with -32003 before the fallback can carry it. The other door - a directory that can be written but not listed - showed the pre-check succeeding instead of failing: the Linux client reports EACCES as an empty directory rather than TOKEN_FILE_LIST_ERROR, so the call goes on to overwrite. skip_check_failed is therefore a timeout backstop that is hard to reach deliberately; the field stays, and 14.9.2 no longer claims that a busy host reaches the fallback. Section 14.9 of the design doc records the contract, those results, and one wrong turn worth keeping: an earlier round concluded that single-file C2C nested the whole absolute path under dst_dir, and added receiver-side hardening for it. The nesting came from the ad-hoc JSON-RPC test harness, which passed JSON on the command line where the shell folded \\ into \/ before Python parsed it, so the source client received a path with no backslashes left and its basename fallback - which looks for a backslash - returned the whole path. The same file sent through the real MCP client produces a clean basename. That hardening has been reverted; the defect was in the test, not the product. Co-Authored-By: deepseek-flash |
||
|
|
1c832ff7f2 |
Feature: Add MCP cancellation, progress notifications and dry runs
P11 closes the plan's last batch, entirely on the server side: no client change is required for any of it. Long-running tools now expose a cancellation flag that every wait loop checks in 500 ms slices. A cancelled tool returns through the cleanup branch it already had (late first packets still get absorbed, sub connections still get closed, pending entries still get deleted), so there is no second cleanup path to keep in sync, and the host is released within a second. Three sources set the flag: notifications/cancelled (matched on the exact JSON-RPC id, with a fallback to the display form so a request_id copied out of the session list round-trips), mcp_cancel_session (by request_id, host id or session id), and a failed SSE write when the client has gone away. The dispatcher rewrites a cancel-induced failure to -32800 so callers do not mistake it for a host fault. tools/call requests carrying _meta.progressToken are answered as text/event-stream on the same POST: the tool runs on its own thread and both the notifications/progress events and the final JSON-RPC response go out through one chunked provider. Requests without a token are unchanged. download_file reports files done vs. expected, upload_file reports bytes sent vs. total. Two new local-only tools, mcp_list_sessions and mcp_cancel_session, list and cancel in-flight sessions (calls, pending one-shots, terminal, remote control, file transfer, chat). They are deliberately not gated by the feature switches or readonly mode, since that is the only way out of a stuck request. The -32003 busy message now names the occupier: "Device busy: ... (tool=download_file, elapsed=12s)". power_action gains wait/wait_ms to verify the result against the main connection's presence (went_offline, came_back, elapsed_ms); not seeing the transition is reported as ok, not as a failure. kill_process, operate_window and the four host_control_* tools accept dry_run, which validates the target against one fresh snapshot and returns what would be affected without sending anything. Validation rejections now use -32012; -32008 stays as documented historical alias. One implementation note worth recording: the per-thread call context uses FLS, not thread_local. Any static thread_local in this server crashes the process about a second after start, because some threads come from shellcode/MemoryModule images that never ran PE TLS initialisation. Verified against a real Debug server and a real Windows client over MCP: the smoke test now passes 104 checks with 0 failures, including cancellation releasing the host in under a second, the cancelled request returning -32800, notifications/cancelled returning 202, 63 progress events with exact byte counts for a 64 MB upload, and a cleanly terminated SSE stream. Not exercised in this pass: power_action's wait=true path (it would take the test host down) and the -32006 readonly/switch-off section (every switch was on during the run). Co-Authored-By: deepseek-flash |
||
|
|
3d388f8e45 |
Feature: Add remote_block_input to MCP remote control
A GUI automation run is interrupted the moment a person at the host touches the mouse, and locking the host's keyboard and mouse is the standard answer. The client already implements COMMAND_SCREEN_BLOCK_INPUT and the MFC screen window already sends it, so the tool needs no client change: it puts the same two-byte packet [COMMAND_SCREEN_BLOCK_INPUT][0|1] on the hidden screen sub-connection that remote_open established. The gate is remote_open's own - McpRemoteControl=1 and McpReadonly=0 - because the ability to lock someone out deserves exactly the same door as the ability to drive their desktop, and Linux and Android clients are refused with -32005: they have no branch for this packet at all and would silently ignore it. Locking a host out is only acceptable if every way back in is closed, so the session now carries its own lock state and three paths release it. block=false releases it directly. block=true always carries a deadline (max_block_ms, default 300000, clamped to 1000..3600000) and a watchdog thread started with the MCP server sweeps every 500ms for expired locks, sends the release and records it; the next remote_block_input reports it as auto_unblocked so the model learns that its lock lapsed instead of assuming it is still held. remote_close and the idle reclaim both send block=false before they tear the sub-connection down, because once that connection is gone the server has no channel left and a live client process stays blocked - all three release paths write an audit line, since none of them is something a person can see. The send happens outside the MCP lock, and the watchdog takes the session's busy flag while it releases, so it cannot interleave with an injection or race a close; a failed send keeps the lock marked and retries five seconds later rather than hammering a dead connection every tick, and a session that dies under the watchdog is erased the same way an injection would erase it. Verified against a real Windows client over MCP on a Debug x64 build: block then unblock, block with a 1.5-2s deadline left to expire and reported back as auto_unblocked with the watchdog audit entry at the expected second, block with a ten-minute deadline then remote_close with "(input lock forced off)" in the audit, and the five refusals (missing block, non-boolean block, max_block_ms out of range, unknown session, offline host). The smoke test gained [4d] for those refusals; 54 checks pass. Two limits are worth stating plainly. BlockInput only works when the calling process is elevated (or UIAccess), the client ignores the API's return value, so on an ordinary client the lock silently does nothing and the tool can only promise that the command was delivered - both the tool description and the server instructions say so. And the idle-reclaim release, like the two verified paths, is only exercised at a 300s idle timeout; it shares the same send helper and was reviewed rather than timed out live. Bin/settings.ini was restored byte-exact and the Release instance was left alone. Co-Authored-By: deepseek-flash |
||
|
|
27b5431130 |
Feature: Add the file-write tools behind their own switch
P10-B adds delete_path, move_path and create_folder, and the switch they need. Reusing McpFileTransfer would have been wrong: uploading overwrites a file, deleting destroys a tree, and an operator who wants one may well not want the other. McpFileWrite is therefore a separate key, off by default, wired the way every other switch is - read from settings.ini at startup, reported as get_server_status.switches.file_write, and exposed with its own checkbox in the MCP settings dialog. The tools additionally require readonly to be off: a read-only server has no business modifying a host. No client change was needed: COMMAND_DELETE_FILE, COMMAND_DELETE_DIRECTORY, COMMAND_CREATE_FOLDER and COMMAND_RENAME_FILE already existed in the Windows file manager. The chain reuses the file-manager sub-connection and adds a phase - the main connection asks for the drive list, the sub-connection's first packet hands it to OnDriveList which sends the write command, and the client's TOKEN_*_FINISH ack moves the pending request from phase 0 to 1, where the tool sends COMMAND_LIST_FILES for the parent so the ack and the confirmation share one timeout. Only the IO thread touches the sub-connection; the tool thread just waits on the shared condvar, which keeps the sub-connection's lifetime out of its reach. The confirmation exists because the client answers unconditionally: it ignores the return values of DeleteFile, MoveFile and MakeSureDirectoryPathExists and there is no error token. ok therefore only means "the command arrived", and verified is the real answer - true when the parent listing shows the expected post-state, false when it shows the opposite, null when the listing itself did not come back (timeout or disconnect), since reporting that as false would be a lie. Linux, macOS and Android hosts are refused outright: those clients decode these paths as GBK while the server speaks UTF-8 to them for list_files, so a non-ASCII path would corrupt rather than fail. Paths are validated as UTF-8, converted to GBK exactly once, and reject %VAR%, relative paths, drive and share roots, and - for delete_path and for move_path's source - the Windows, Program Files, ProgramData, $Recycle.Bin and System Volume Information trees. create_folder gets no system-directory ban, because writing there is the same permission upload_file already has. Two defects surfaced while exercising this against a real client: create_folder's wire path has to end with a backslash, because MakeSureDirectoryPathExists treats a non-terminated last component as a file name and only creates the intermediate levels; and ResolveFileOpVerified(LookupInListing(...), isDir, ...) read isDir before the lookup ever set it - argument evaluation order is unspecified and MSVC evaluates right to left - so every create_folder reported verified=false even when the directory existed. Verified on a Debug x64 build against a Windows client over MCP: nested create_folder, upload, rename, delete, delete a tree, the failure shapes (delete with recursive=false on a directory, create_folder onto an existing file name, delete of a non-existent target) and every refusal (drive root, C:\Windows\Temp, C:\Users, %TEMP%, relative, empty, over-long, from==to, offline host, non-numeric id), with a Chinese-named directory created, renamed and deleted end to end; no file-manager window appeared in the server process during any of it. The smoke test gained section [4c], opt-in through -FileWriteDir, which asserts verified and never ok and walks a sandbox through the same path; two runs passed 69 checks with the sandbox removed afterwards. Bin/settings.ini was restored byte-exact and the Release instance was left alone. Co-Authored-By: deepseek-flash |
||
|
|
bb55f52b29 |
Feature: Add instructions, capability reporting and filters to MCP
P10-A is the first batch of the next MCP phase: the server now tells a model
how it expects to be driven instead of leaving the rules to be inferred from
per-tool descriptions.
initialize carries the instructions field that MCP 2025-06-18 defines, in
five sections: where host ids come from, which switch hides which tool, what
each error code implies for the next action, typical orchestrations, and
safety. Every statement was checked against the implementation rather than
derived from the tool descriptions, and four did not survive: the host_*
family only supports name/pid filters in part (named per tool now), read-only
mode does not hide host_set_remark and host_set_watch_level (they touch only
the local host store and are refused with -32006 when called), -32003 is one
lock keyed by device id rather than one per capability, and there is no
"screen stream" tool to pick instead of get_screenshot. The string is built
from u8 literals because the project compiles with /execution-charset:.936.
get_host_detail returns a capabilities object (platform, screenPreview,
remoteControl, fileTransferV2, c2cPaths, registry), each flag tied to a gate
that already exists in the dispatcher, so a model no longer discovers a
host's limits by calling and reading -32005. remoteControl mirrors the two
conditions remote_* actually applies (Windows or Linux, and not
multi-monitor), not the preview bit. Making the flags honest exposed
list_registry rejecting only LNX and MAC, so an APK host passed and then
waited out the timeout; it now uses the same is-Windows predicate the bit is
computed from. That predicate existed as identical local copies in
McpMachine.cpp and McpChat.cpp and now lives in McpInternal.
list_processes and list_windows take an optional name and pid, filtered on
the server before the page window is applied, with total counting matches
and totalAll still reporting the unfiltered count. The two tools get their
own schema builder so list_services does not advertise a filter it would
silently ignore, and the pid descriptions differ because a pid means the
process itself for one tool and its owner for the other.
get_keylog gains set_offline and clear, the two commands the client already
implements on the keyboard sub-connection but nothing on the MCP side ever
sent, plus offlineRecord from the ready packet's byte 1. Both writes are
gated on McpReadonly=0 and validated before COMMAND_KEYBOARD goes out, so a
refused call cannot leave a running keyboard session behind; the tool's
annotations change from read-only to writable and destructive, and the
server instructions gain the matching sentence.
Four capabilities are exposed twice through two different sub-connection
chains, so each pair's descriptions now say which one to reach for first and
when the other is the only option: the host_* trio carries more fields and
filters on the server, the list_* trio is the McpMachine=0 fallback, and
operate_window is the only one that can close a window. No tool was merged:
the split is what lets McpMachine be switched off on its own. search_file's
description drops the stale MAX_PATH-overflow warning (fixed in
|
||
|
|
4d2abf34d0 |
Feature: Support the Tier 1 MCP tools on Linux clients
All of these tools already had a working wire protocol on the Linux
client (SystemManager.h, common/PTYHandler.h, ScreenHandler.h); only the
server-side client-type gates rejected LNX hosts. kill_process,
exec_command, terminal_open/exec/close and remote_open/close/mouse/
keyboard/clipboard now accept LNX and reject only MAC (plus APK where it
applied). No client change, no capability bit.
exec_command and terminal_exec needed platform-aware plumbing because a
POSIX shell understands none of the Windows constructs: the sentinel is
now "PS1=" / the command / "echo __MCP_DONE_<nonce>__$?" over the Linux
PTY, with output decoded as UTF-8. The PS1= line exists because
interactive bash prints its prompt after every line it reads, which
otherwise leaks into stdout; its echo sits ahead of the command echo and
is removed together with it. The Windows ConPTY and legacy non-PTY forms
are unchanged.
The default command whitelist is now platform-specific: identically named
POSIX commands can write files or change system state (find -exec,
sort -o, hostname), so kDefaultCmdWhitelistPosix only lists commands that
stay read-only even with arguments. env is deliberately excluded, since
"env <program>" runs arbitrary programs and would defeat the whitelist
entirely. An explicit McpCmdWhitelist still overrides both platforms. The
forbidden metacharacter set is split the same way: on Linux it covers
& | < > ; backtick and $( / ${ / !, where ! triggers history expansion in
interactive bash. ^ is not a POSIX metacharacter, so read-only commands
like "grep -v ^# /etc/hosts" are accepted on Linux while Windows keeps
rejecting them.
Input injection had to be sent one MSG64 per COMMAND_SCREEN_CONTROL
packet. The protocol allows batching and the Windows client handles it,
but linux/ScreenHandler.h only processes the first message of a packet,
so a batch left key_press stuck down (X11 autorepeat), click
half-pressed and type emitting only its first character. Splitting the
packets is equivalent for Windows, which processes one message at a time
anyway, and keeps already-deployed Linux clients working without an
upgrade.
Verified on a Debug server against a WSL Ubuntu 24.04 client and a
Windows client: exec_command returned real exit codes (0/1/2) with clean
output, -32007/-32008 negatives, and the POSIX-only ^ allowance;
persistent terminals kept cwd and environment, returned 1 for false and
the last exit code for ";" chains, and closed idempotently; kill_process
killed a test process, returned an empty remaining list and skipped
pid 1; remote_open reported 3840x1140, remote_mouse mapped (0.5,0.5) to
(1920,570), xev showed balanced press/release pairs for keys and buttons,
and a Chinese clipboard round-trip came back as UTF-8. The Windows
regression of the same tools was unchanged, including the multi-monitor
gate on remote_open.
Co-Authored-By: deepseek-flash
|
||
|
|
3a158a241c |
Feature: Support upload_file and download_file on Linux and macOS hosts
Both tools used to reject LNX/MAC targets outright. The server now gates on the target client type instead: a POSIX target must pass an absolute POSIX remote path without a backslash or a ".." segment (-32602 otherwise), while Windows targets keep their exact previous behaviour. upload_file needed no new client command; the POSIX receiver already handles COMMAND_SEND_FILE_V2 and derives the destination from the packet name. It now also reports a real receiver_ack: the upload session records dstClientID/transferID, and OnC2CRecvResult matches the 176 acknowledgement from Linux targets, so a destination write failure becomes -32011 and a missing ack (with bytes in flight) becomes -32001. download_file needed two pieces on the POSIX side, both shared by Linux and macOS through common/FileTransferV2.h: a FileCompletePacketV2 per file with a streaming SHA-256 (new self-contained common/sha256_posix.h, since BCrypt is Windows-only) so the server can count completed files and verify digests, and a TOKEN_DOWNLOAD_ERROR reply when the requested paths do not exist or are denied, which the server maps to -32009/-32010 within milliseconds instead of waiting for the stall watchdog. Zero-byte files were lost when uploading to POSIX targets because the worker sends no data chunk for them and the complete packet carries no path, so the receiver had nothing to create. The server now injects a zero-length final chunk for each empty file, only for POSIX targets; Windows targets keep their existing behaviour. Also fixes a download completion edge case found while testing: the client decides entry order, so a directory may arrive after all files (an empty subdirectory, for example), and the directory branch only completed when the directory count alone covered totalFiles. The check is now filesDone + directoryCount >= totalFiles. Verified end to end against a WSL Linux client and a Windows client: upload and download of a tree with a 3 MB binary, a Chinese filename, an empty file and an empty subdirectory all round-trip with matching SHA-256; the documented error paths (-32602, -32009, -32011, -32001) and the Windows upload/download/C2C regressions were exercised as well. Co-Authored-By: deepseek-flash |
||
|
|
4146c73657 |
Feature: Make Linux a copy_files_c2c destination
The C2C file transfer tool required both ends to be Windows clients. A Linux client can already land the files: the Windows source worker builds every entry name by plain string concatenation of dst_dir and the relative path, so a POSIX dst_dir such as /tmp/recv arrives as "/tmp/recv\sub\file", which the POSIX receiver normalizes to "/" and writes below an absolute path. What was missing was the server gate and any way to tell whether the writes succeeded. The server now accepts LNX/MAC destinations instead of rejecting them, and validates dst_dir by destination type: an absolute Windows path for Windows targets, an absolute POSIX path without backslashes for POSIX targets. The paths and dst_dir arguments also reject embedded NULs, and a POSIX dst_dir is converted to CP936 exactly so unencodable characters fail loudly instead of silently becoming '?'. To make receiver_ack meaningful, a Linux client that receives a C2C transfer now reports what it wrote. It tracks the outcome per transferID, counting a directory entry, the last chunk of a file and the completion packet of an empty file as the three ways an item is settled, with done sets so that source retries and the trailing completion packet never double count. When every item is settled it sends one C2CSendResultPacket back on its main connection under the new TOKEN_C2C_RECV_RESULT (176), with the first errno in the win32err field and the mapped FEV2_* status. A dedicated token is used instead of reusing 175 because a host can be the destination of one transfer while being the source of another, and a destination result must never latch the source side's done flag. The server waits up to five seconds for that acknowledgement after the source reports success, and only for destinations advertising the new CLIENT_CAP_C2C_RECV_ACK capability bit (Linux only, macOS reports nothing). A failed acknowledgement becomes -32011 with the status, errno and received file count; a missing acknowledgement stays an error only for transfers that actually moved bytes, since a transfer of empty files alone gives the receiver nothing to learn totalFiles from. Windows destinations are unchanged and skip the wait entirely. Verified on the debug instance: Windows to Linux (WSL Ubuntu 24.04) with subdirectories, an empty directory, a Chinese file name and a 3 MB binary lands with matching SHA-256 and receiver_ack true; a Windows-style dst_dir returns -32602; an unwritable POSIX destination returns -32011; the existing Windows to Windows cases still pass with receiver_ack false and the same latency. Co-Authored-By: deepseek-flash |
||
|
|
c271911fcb |
Feature: Add copy_files_c2c to transfer files between clients directly
Adds the 54th MCP tool, copy_files_c2c, which asks the source client to push a set of files straight to another online client. Previously the only way to move files between two clients was to download them to the server machine and upload them again, so the data crossed the wire twice and needed free disk on the server. With C2C the server only relays packets and never parses or stores the payload. Protocol. Two new ids in common/commands.h: COMMAND_C2C_SEND_FILES (174), carrying the destination directory followed by a NUL-separated path list, and TOKEN_C2C_SEND_RESULT (175), a fixed 45-byte result packet sent back over the same sub-connection the transfer used. Clients advertise support with the LOGIN_INFOR capability bit CLIENT_CAP_C2C_PATHS (0x0008), exposed server side as Context::SupportsC2CPaths(). File transfer V2 already knew how to push to dstClientID, so the destination side needed no change at all; existing V2 receive paths keep working, and older clients simply do not advertise the bit and are rejected with a clear error instead of hanging. Client. OnC2CSendFiles expands environment variables, collects directories recursively, opens its own sub-connection (with sub-connection auth), and runs FileBatchTransferWorkerV2 in a detached thread, then reports the result on that same connection. Every early exit now reports a structured failure rather than staying silent. The worker needs the process-level InitFileUpload call that the receive path performs lazily, and a source client may never have opened a file manager or received an upload, so the initialization is factored into EnsureV2TransferInited() and called from both paths. Server. copy_files_c2c mirrors the existing upload tool: gates, id parsing, capability checks, path validation, then a session keyed on the source host that WaitC2CDone polls until the result packet arrives. The C2C relay branch used to attach a CDlgFileSend progress dialog to the source's sub-connection; NotifyProc then routed every later packet on that connection to the dialog, which parsed the result packet as a V1 file chunk and dropped it, so the tool always timed out even though the files had arrived. IsC2CTransferPending() now suppresses dialog creation for MCP-driven transfers only, leaving manual Ctrl+V transfers untouched. Errors map to -32001 for a source-side transfer failure, -32010 for access denied, -32009 for a missing path and -32002 for an offline destination. Both hosts must be Windows: the destination is restricted too, because the source embeds dst_dir in each V2 chunk name as an absolute Windows path and only the Windows receiver applies it literally. A Linux or macOS receiver never gets a target directory here (the clipboard flow sets one with COMMAND_C2C_PREPARE, which this path does not send), so it would strip the drive letter and write under / instead. Supporting that needs a prepare packet carrying an explicit path plus an upgrade of those clients, so for now the tool rejects them with -32005 rather than writing somewhere wrong. Verified end to end on the Debug build: three files including a non-ASCII name, an empty directory and a 3 MB binary arrived with matching SHA-256 in 3.2 s, a non-existent destination directory was created, and the negative cases returned the documented codes. mcp_smoke.ps1 passes 41/41 with two new assertions and 27/27 in -SkipHost mode. Design notes, error table and limitations are in docs/Mcp_FileTransfer_Design.md section 14 and docs/Mcp_Design.md section 15. Co-Authored-By: deepseek-flash |
||
|
|
27d40f5678 |
Fix: Expose tool payloads in the content text block
List and query tools put only a human summary in content and kept the real payload in structuredContent. Clients that hand just content to the model (WorkBuddy does) therefore never saw a host id: search_hosts answered "1 host matched" and every follow-up tool was out of reach, and guessed ids 1-3100 could never work because host ids are 64-bit snowflake values. BuildResult now appends the serialized structuredContent as a second text block, as the MCP spec recommends for tools with structured output. The append sits in the single result choke point, so every tool in McpServer, McpMachine and McpChat gains it, including future ones; empty action results such as remote_mouse keep their bare "ok". Tools whose text already carries the payload expose only the difference: exec_command and terminal_exec add exit_code, get_keylog adds counters, get_activity_history exposes records without the duplicated raw dump, and the hosts file reader drops its copy of the content. The override rides in a $ key that BuildResult consumes and removes, so responses change only by the extra block. Verified on a Debug instance: list_all_hosts, search_hosts, get_server_status and list_registry return parseable JSON in content[1] with ids intact, and tools/mcp_smoke.ps1 -SkipHost passes 27/27 with four new assertions. Co-Authored-By: deepseek-flash |