@pyrokine/mcp-ssh 2.3.2 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,7 +96,7 @@ Add to your MCP settings (e.g., `~/.claude/settings.json` or client-specific con
96
96
  }
97
97
  ```
98
98
 
99
- ## Available Tools (30 tools)
99
+ ## Available Tools (35 tools)
100
100
 
101
101
  ### Connection Management
102
102
 
@@ -104,10 +104,14 @@ Add to your MCP settings (e.g., `~/.claude/settings.json` or client-specific con
104
104
  |---------------------|---------------------------------------------------|
105
105
  | `ssh_connect` | Establish SSH connection (supports ~/.ssh/config) |
106
106
  | `ssh_disconnect` | Close connection |
107
- | `ssh_list_sessions` | List active sessions |
107
+ | `ssh_list_sessions` | List brief sessions; optional detail/field selection |
108
108
  | `ssh_reconnect` | Reconnect a disconnected session |
109
109
  | `ssh_config_list` | List hosts from ~/.ssh/config |
110
110
 
111
+ `ssh_list_sessions()` returns only `alias`, canonical `identity`, `runAs`, `connected`, and `lastUsedAt`. Use `detail=true` for connection details or `fields=[...]` to select fields. Neither mode returns `keyPath`.
112
+
113
+ `ssh_reconnect` invalidates operations, PTYs, forwards, and cached transfer capability bound to the old client before the replacement connection is published. Automatic reconnect timers are bound to the session and client that scheduled them, so an old timer cannot disconnect a newer session with the same alias. A delayed `close` from the old client cannot leave stale resources attached to the alias. If a target connection is cancelled while a jump-host `forwardOut` is pending, a channel returned by the delayed callback is destroyed before the connection attempt fails.
114
+
111
115
  ### Command Execution
112
116
 
113
117
  | Tool | Description |
@@ -120,6 +124,16 @@ Add to your MCP settings (e.g., `~/.claude/settings.json` or client-specific con
120
124
  | `ssh_quick_exec` | One-shot: connect, execute, disconnect |
121
125
  | `ssh_exec_script` | Upload and run a temporary remote script |
122
126
 
127
+ ### Tracked operations
128
+
129
+ | Tool | Description |
130
+ |------------------------|--------------------------------------------------|
131
+ | `ssh_operation_start` | Start a tracked long-running remote command |
132
+ | `ssh_operation_status` | Read status, PID, exit code, and output counters |
133
+ | `ssh_operation_read` | Read bounded stdout and stderr by byte offset |
134
+ | `ssh_operation_cancel` | Verify the operation marker, then send TERM |
135
+ | `ssh_operation_list` | List unexpired operations, optionally by alias |
136
+
123
137
  ### File Operations
124
138
 
125
139
  | Tool | Description |
@@ -240,9 +254,11 @@ ssh_exec(alias="app-dev", command="whoami", useLoginUser=true)
240
254
  ```
241
255
 
242
256
  `ssh_connect` returns `identity`, `loginUser`, `runAs`, `reused`, `defaultEnvKeys`, `envKeys`, and `reusableSessions`
243
- for already connected aliases with the same `user@host:port` identity. Reusing an alias for a different identity is
244
- rejected with the existing and requested identities. Missing templates include available template names when they can be
245
- loaded. Missing `configHost` returns SSH config candidates and suggests `ssh_config_list`.
257
+ from the session that was actually published. Concurrent calls reuse an alias only when the complete session configuration
258
+ matches, including endpoint, authentication, `runAs`, environment, jump host, keepalive, and timeout settings. A conflicting
259
+ pending or active connection is rejected even when its `user@host:port` identity is unchanged. Missing templates include
260
+ available template names when they can be loaded. Missing `configHost` returns SSH config candidates and suggests
261
+ `ssh_config_list`.
246
262
 
247
263
  ### Jump Host (Bastion)
248
264
 
@@ -283,6 +299,26 @@ Timeout errors include the same head/tail fields from output produced before the
283
299
  process-control, service-control, credential-bearing, unbounded `find`, recursive `grep`, long pipelines, background
284
300
  tasks, direct `su - user -c`, or long-running patterns return a `commandRisk` block with `categories` and `signals`.
285
301
 
302
+ ### Tracked long-running commands
303
+
304
+ Use tracked operations when a command must continue beyond one synchronous tool call:
305
+
306
+ ```
307
+ ssh_operation_start(alias="server", command="long-running-job", maxOutputBytes=1048576, startTimeoutMs=30000)
308
+ ssh_operation_status(operationId="op_xxx")
309
+ ssh_operation_read(operationId="op_xxx", stdoutOffset=0, stderrOffset=0, maxBytes=65536)
310
+ ssh_operation_cancel(operationId="op_xxx")
311
+ ```
312
+
313
+ The start call returns an unpredictable `operationId`. The server creates the record before requesting the SSH channel, keeps bounded stdout and stderr buffers, records the remote PID after verifying a per-operation marker, and expires terminal records after `retentionMs`. `startTimeoutMs` bounds channel setup, defaults to 30 seconds, and accepts up to 10 minutes. A timeout returns the `operationId` in error details, keeps a queryable `unknown` record, and blocks another pending start on that alias until the original channel request settles or the alias is disconnected. `maxOutputBytes` defaults to 1 MiB and accepts up to 8 MiB. `retentionMs` defaults to 1 hour and accepts up to 24 hours. `ssh_operation_read.maxBytes` defaults to 64 KiB and accepts up to 1 MiB. Cancellation is refused until the marker and PID are verified. Stderr written by a shell profile before the marker is retained as operation output, including an unterminated preamble immediately followed by the marker. A line that uses the operation marker prefix with the wrong token or invalid process metadata ends the
314
+ record as `failed`, closes its channel, and starts the configured retention period. Delayed exec, sudo, SFTP, PTY-start,
315
+ and operation-start callbacks from a disconnected or replaced SSH session are rejected and their channels are destroyed.
316
+ A sudo callback that arrives after timeout is also closed before any password is written. Operation listeners are installed
317
+ inside the SSH exec callback before it returns, so a short command that emits its marker and closes immediately still enters
318
+ a terminal state with `finishedAt` and `expiresAt` set. If the SSH session disconnects while a tracked command is active,
319
+ its status becomes `unknown`; the server does not claim that the remote process stopped. `ssh_exec` keeps its existing
320
+ synchronous timeout behavior.
321
+
286
322
  ### Interactive Commands (PTY mode)
287
323
 
288
324
  For commands that need a terminal:
@@ -353,18 +389,36 @@ ssh_read_file(alias="server", remotePath="/var/log/app.log", lineRange="120-180"
353
389
  ```
354
390
 
355
391
  `ssh_upload` returns local path policy diagnostics, remote parent probing, remote target metadata, and optional
356
- verification checks. `atomic=true` uploads to a same-directory temporary file, then renames it to the target path.
357
- `verifySize`, `verifyMd5`, `verifyMode`, `verifyOwner`, and `verifyMtime` add explicit post-transfer checks.
392
+ verification checks. `atomic=true` writes an unpredictable same-directory temporary path with exclusive SFTP creation,
393
+ returns `diagnostics.tempRemotePath`, verifies the temporary file, and renames it only after every requested check passes.
394
+ Responses distinguish `finalRemotePath` from the actual verification target: `verifiedRemotePath` identifies the path that
395
+ was probed, and atomic verification also returns `verifiedTempRemotePath`. `verification.actual.remotePath` continues to
396
+ describe the file that was actually verified, even after that temporary path has been renamed. Interpret the final state
397
+ with `targetReplaced` and `targetReplacementStatus`. An existing target is replaced with the OpenSSH
398
+ `posix-rename@openssh.com` extension; a new target uses standard SFTP
399
+ rename. If the client cannot send the rename request, the response reports `operationStatus="failed"`,
400
+ `targetReplaced=false`, and `targetReplacementStatus="not_replaced"`. An error returned after the request was sent cannot
401
+ prove whether the server committed it, so the response reports `operationStatus="unknown"`, `targetReplaced=null`, and
402
+ `targetReplacementStatus="unknown"`; inspect the target before retrying. Temporary-file cleanup is attempted in both
403
+ cases. `verifySize`, `verifyMd5`, `verifyMode`, `verifyOwner`, and `verifyMtime` add explicit transfer checks. Parent and
404
+ target probes, recursive directory creation, file hashing, rename, and temporary-file cleanup use SFTP. The standard
405
+ upload path works on SFTP-only servers and does not require GNU `stat`, `md5sum`, `sha256sum`, `mkdir`, `mv`, or `rm`
406
+ commands. Explicit directory manifest verification still runs remote shell commands.
407
+
408
+ `ssh_download` writes to a same-directory temporary file and renames it over the requested local path after the SFTP
409
+ stream closes and the transferred byte count matches the size reported by SFTP `stat`. A failed, truncated, or aborted
410
+ download removes the temporary file and leaves an existing local target unchanged. SFTP directory listings reject empty
411
+ names, `.` and `..`, NUL bytes, and path separators before constructing child paths.
412
+
358
413
  Command execution results include `emptyOutputFailure=true` when the remote command exits non-zero without
359
- stdout/stderr,
360
- with the effective user, cwd, and a suggested follow-up read command when available.
414
+ stdout/stderr, with the effective user, cwd, and a suggested follow-up read command when available.
361
415
  `ssh_read_file` defaults to 1 MiB and rejects `maxBytes` above 16 MiB before remote transfer. It returns `total_size`,
362
416
  `read_offset`, `read_bytes`, `remaining_bytes`, `sample_kind`, and `truncated` so callers can distinguish a full read
363
417
  from a head, tail, byte range, or line range sample.
364
418
 
365
- ### Directory Sync (with rsync)
419
+ ### Directory sync with rsync or SFTP
366
420
 
367
- Smart sync automatically detects rsync availability and uses it for efficient incremental transfer:
421
+ Smart sync selects rsync only for a direct connection with a validated key path or usable SSH agent. Password, inline-key, jump-host, and other routes that cannot be passed safely to OpenSSH use SFTP directly:
368
422
 
369
423
  ```
370
424
  // Sync local directory to remote (upload)
@@ -374,7 +428,7 @@ ssh_sync(
374
428
  remotePath="/remote/project",
375
429
  direction="upload"
376
430
  )
377
- // Returns: { method: "rsync", filesTransferred: 42, ... }
431
+ // Returns selectedTransport, decisionReason, stage durations, and transfer counters
378
432
 
379
433
  // Sync with exclude patterns
380
434
  ssh_sync(
@@ -398,16 +452,44 @@ ssh_sync(..., dryRun=true)
398
452
 
399
453
  // Upload one file and verify remote owner/mode after transfer
400
454
  ssh_sync(..., direction="upload", verifyOwner="appuser", verifyMode="0644")
401
- ```
402
455
 
403
- If rsync is not available on remote or local, it automatically falls back to SFTP. Sync responses include `transport`,
404
- `duration`, `dryRun`, `stats`, and `commandSummary`. SFTP single-file transfers include a `verification` object with
405
- local and remote size, mode or permissions, mtime, owner/group, and SHA-256 comparison when the remote has `sha256sum`.
406
- For upload single-file sync, `verifyOwner` and `verifyMode` add an `ownerMode` verification block based on remote file
407
- metadata. Directory sync does not recursively scan owner/mode; it returns a skipped verification note instead.
456
+ // Verify a directory with bounded manifests
457
+ ssh_sync(
458
+ ...,
459
+ verify={count: true, sha256: true, owner: true, mode: true, staleFiles: true}
460
+ )
408
461
 
409
- **Note**: rsync mode uses SSH key/agent authentication and sets `StrictHostKeyChecking=accept-new`.
410
- If you require strict host key verification and management, use SFTP mode instead.
462
+ // Verify that entries present before --delete were removed
463
+ ssh_sync(..., delete=true, verify={deletions: true})
464
+ ```
465
+
466
+ A directory source always means “copy the source directory contents into the destination root” in both rsync and SFTP
467
+ mode. Directory sources reject `recursive=false`. Relative exclude patterns are evaluated against the path below the
468
+ source root; patterns without `/` match each basename.
469
+
470
+ Directory verification builds bounded local and remote manifests. It can compare entry count, a SHA-256 root manifest,
471
+ owner, mode, stale entries, and deletion results. `verify.deletions=true` requires `delete=true`; it records the destination
472
+ before transfer and only checks whether those deletion candidates disappeared. `staleFiles` independently checks every
473
+ extra destination entry. The response contains summaries and at most 20 mismatch samples, not the full manifest. The
474
+ default limits are 10,000 entries, 256 MiB per hashed file, and 1 GiB total hashed bytes. Set `verify.maxEntries`,
475
+ `verify.maxFileBytes`, and `verify.maxTotalBytes` to raise them, up to 50,000 entries, 4 GiB per file, and 16 GiB total.
476
+ Symlinks or unsupported filesystem entries that were skipped make verification explicitly `skipped` instead of
477
+ reporting a partial match.
478
+
479
+ If verification is requested, a mismatch, skipped check, or verification error sets top-level `success=false` while
480
+ `transferSuccess` still reports whether transfer completed. `verificationStatus`, `verificationSuccess`, and
481
+ `failedChecks` describe the verification outcome. SFTP single-file transfers also include local and remote size,
482
+ mode or permissions, mtime, owner/group, and a streamed SFTP SHA-256 comparison. `verifyOwner` and `verifyMode` apply
483
+ to upload single-file sync; use `verify.owner` and `verify.mode` for directory manifests.
484
+
485
+ Rsync is selected only for a direct connection with a validated key path or usable SSH agent. Password, inline-key, and
486
+ jump-host sessions use SFTP because their route or credentials cannot be passed safely to a separate OpenSSH process.
487
+ `preflightTimeout`, `connectTimeout`, and `operationTimeout` independently bound capability probing, rsync SSH setup, and
488
+ the overall transfer; their defaults are 10 seconds, 30 seconds, and 10 minutes. When the session is not eligible for
489
+ rsync, the response returns `rsyncProbe.status="skipped"` with the route decision reason instead of omitting the probe.
490
+ Rsync mode sets
491
+ `StrictHostKeyChecking=accept-new`. SFTP does not support `delete=true`; such a request fails explicitly instead of
492
+ claiming deletion. If you require strict host key verification and management, use SFTP mode.
411
493
 
412
494
  ### Persistent PTY Sessions (top, tmux, etc.)
413
495
 
@@ -447,6 +529,8 @@ ssh_pty_write(ptyId="pty_1_xxx", data="\x02d")
447
529
 
448
530
  `ssh_pty_read` and `ssh_pty_list` expose `lastInputAt`, `lastOutputAt`, `lastReadAt`, `unreadRawBytes`,
449
531
  `rawBufferLimit`, and `foregroundProcess` so long-running sessions can be monitored without reading the full raw stream.
532
+ When a finite command exits naturally, its final screen remains readable with `active=false` until explicit close or the
533
+ closed-session retention expires (5 minutes by default, configurable with `SSH_MCP_PTY_CLOSED_RETENTION_MS`).
450
534
 
451
535
  Common control sequences:
452
536
 
@@ -468,13 +552,31 @@ ssh_forward_local(alias="server", localPort=13306, remoteHost="<service-host>",
468
552
  // Remote forward: expose local dev server (3000) to remote port 8080
469
553
  ssh_forward_remote(alias="server", remotePort=8080, localHost="127.0.0.1", localPort=3000)
470
554
 
555
+ // Ask the SSH server to allocate a remote port; use remotePort from the result
556
+ ssh_forward_remote(alias="server", remotePort=0, localHost="127.0.0.1", localPort=3000)
557
+
471
558
  // List all forwards
472
559
  ssh_forward_list()
473
560
 
474
- // Close forward
475
- ssh_forward_close(forwardId="fwd_1_xxx")
561
+ // Close after the listener is released
562
+ ssh_forward_close(forwardId="fwd_1_xxx", mode="graceful", timeoutMs=5000)
563
+
564
+ // Destroy active connections, then release the listener
565
+ ssh_forward_close(forwardId="fwd_1_xxx", mode="force", timeoutMs=5000)
476
566
  ```
477
567
 
568
+ A successful close means the local `server.close` or remote `unforwardIn` callback completed. The result includes
569
+ `listenerReleased`, `remoteUnforwarded`, `activeConnections`, `closeMode`, and `retryable`. Timeout or callback failure
570
+ keeps the forward in `ssh_forward_list`, so the same `forwardId` can be retried. After a successful local close, the port
571
+ can be rebound immediately. `remotePort=0` returns the actual allocated port and uses that port for incoming connection
572
+ routing and `unforwardIn`.
573
+
574
+ Forward creation is tracked before `listen` or `forwardIn` completes. Disconnect cancels pending creation, closes a local
575
+ listener if it appears later, and removes a remotely allocated listener returned by a delayed callback. A forward stops
576
+ accepting new local or remote connections as soon as close begins. Delayed `forwardOut`, close, and unforward callbacks
577
+ check the same lifecycle record before changing state, so a closed forward cannot reappear in `ssh_forward_list`. Each local
578
+ connection tracks both the local socket and the SSH `forwardOut` channel. Closing or failing either side destroys the other, and force close returns only after both sides are destroyed and `activeConnections` reaches zero. Pending `forwardOut` requests are limited to 32 per alias, and a close waits for every callback. If the SSH server never answers a channel-open request, close times out, keeps the forward retryable, and rejects another local forward on the same alias so pending ssh2 channels cannot accumulate. Disconnect the alias to release a channel request that never completes.
579
+
478
580
  ## Configuration Options
479
581
 
480
582
  ### Connection Options
@@ -492,6 +594,10 @@ ssh_forward_close(forwardId="fwd_1_xxx")
492
594
  | `defaultEnv` | object | - | Default env for this session |
493
595
  | `runAs` | string | - | Default execution user |
494
596
  | `keepaliveInterval` | number | 30000 | Keepalive interval in ms |
597
+ | `readyTimeout` | number | 30000 | Wait for SSH ready in ms, max 600000 |
598
+ | `jumpHost.readyTimeout` | number | top-level value | Jump-host ready timeout, max 600000 |
599
+
600
+ Connection failures return `failureStage`, `retryable`, and a bounded suggestion. `failureStage` is one of `preflight`, `authentication`, `ready_timeout`, `transport_or_handshake`, or `unknown`; multi-hop failures may also include `connectionStep` as `key_read`, `jump_connect`, `jump_forward`, or `target_connect`.
495
601
 
496
602
  ### Exec Options
497
603
 
@@ -506,6 +612,11 @@ ssh_forward_close(forwardId="fwd_1_xxx")
506
612
  | `useLoginUser` | boolean | false | Skip session-level runAs |
507
613
  | `loadProfile` | boolean | true | Load target user's shell profile for runAs |
508
614
 
615
+ When `cwd` or `env` is set, the generated shell command chains `cd` and each validated `export` with `&&`, then runs the
616
+ entire requested command as one escaped `eval` argument in the active login shell. A failed directory change or export
617
+ prevents every part of the requested command from running, including text after `;`, newlines, or `||`, while Bash/Zsh
618
+ syntax keeps the same interpreter semantics as a direct SSH command.
619
+
509
620
  ## Security
510
621
 
511
622
  ### Path Whitelist for Key/Config Files
@@ -534,8 +645,10 @@ directories (recommended for shared environments), set `SSH_MCP_FILE_OPS_ALLOW_D
534
645
  export SSH_MCP_FILE_OPS_ALLOW_DIRS=/tmp:/home/me/work
535
646
  ```
536
647
 
537
- When set, any local path outside the whitelist is rejected. Symlinks are resolved via `realpath` to prevent escape.
538
- When unset, no restriction is applied (preserves flexibility).
648
+ When set, any local path outside the whitelist is rejected and symlinks are resolved via `realpath`.
649
+ `ssh_sync(direction="upload", followSymlinks=true)` is rejected before transport selection while the whitelist is active.
650
+ A symlink can change between validation and transfer, and rsync cannot bind the validated target to the later `-L` read.
651
+ Keep `followSymlinks=false`, or copy regular files into an allowed directory before syncing.
539
652
 
540
653
  ### File Size Limits
541
654
 
@@ -550,11 +663,12 @@ Files exceeding these limits are rejected before being read.
550
663
 
551
664
  | `followSymlinks` | SFTP path | rsync path |
552
665
  |-------------------|------------------------------------------------------------|-----------------------------------------------------------------------------|
553
- | `false` (default) | Skipped, returned in `skippedSymlinks`, printed as warning | Copied as-is (rsync default: preserves the symlink without dereferencing) |
666
+ | `false` (default) | Skipped, returned in `skippedSymlinks`, printed as warning | Skipped via `--no-links` |
554
667
  | `true` | Followed: link target contents are uploaded | Followed via rsync `-L` / `--copy-links`: link target contents are uploaded |
555
668
 
556
- Both default modes are safe (neither uploads link target contents). The divergence is whether the destination keeps the
557
- symlink: SFTP omits it entirely, rsync preserves it as a symlink.
669
+ Both transports skip device and special filesystem entries. SFTP returns `skippedUnsupported` and up to 10 sample paths;
670
+ rsync uses `--no-devices --no-specials`. Directory verification also reports skipped symlinks and unsupported entries and
671
+ does not treat an incomplete manifest as a match.
558
672
 
559
673
  ## Project Structure
560
674
 
package/README_zh.md CHANGED
@@ -96,7 +96,7 @@ claude mcp add ssh -- node /path/to/mcp-ssh/dist/index.js
96
96
  }
97
97
  ```
98
98
 
99
- ## 可用工具(30 个)
99
+ ## 可用工具(35 个)
100
100
 
101
101
  ### 连接管理
102
102
 
@@ -104,10 +104,14 @@ claude mcp add ssh -- node /path/to/mcp-ssh/dist/index.js
104
104
  |---------------------|-----------------------------|
105
105
  | `ssh_connect` | 建立 SSH 连接(支持 ~/.ssh/config) |
106
106
  | `ssh_disconnect` | 关闭连接 |
107
- | `ssh_list_sessions` | 列出活跃会话 |
107
+ | `ssh_list_sessions` | 列出精简会话,可选详情或字段筛选 |
108
108
  | `ssh_reconnect` | 重新连接断开的会话 |
109
109
  | `ssh_config_list` | 列出 ~/.ssh/config 中的 Host |
110
110
 
111
+ `ssh_list_sessions()` 默认只返回 `alias`、规范化 `identity`、`runAs`、`connected` 和 `lastUsedAt`,使用 `detail=true` 获取连接详情,或通过 `fields=[...]` 选择字段,任何模式都不返回 `keyPath`
112
+
113
+ `ssh_reconnect` 会在发布替代连接前,使绑定旧 client 的 operation、PTY、forward 和传输能力缓存失效;自动重连 timer 绑定发起调度的 session 和 client,不会断开同一 alias 下后来发布的新会话;旧 client 延迟到达的 `close` 不会让过期资源继续挂在同一 alias 下;通过 jump host 建立目标连接时,如果取消发生在 `forwardOut` pending 阶段,延迟 callback 返回的 channel 会先销毁再结束连接请求
114
+
111
115
  ### 命令执行
112
116
 
113
117
  | 工具 | 描述 |
@@ -120,6 +124,16 @@ claude mcp add ssh -- node /path/to/mcp-ssh/dist/index.js
120
124
  | `ssh_quick_exec` | 一次性执行:连接、执行、断开 |
121
125
  | `ssh_exec_script` | 上传并执行远端临时脚本 |
122
126
 
127
+ ### 可跟踪任务
128
+
129
+ | 工具 | 描述 |
130
+ |------------------------|------------------------------|
131
+ | `ssh_operation_start` | 启动可跟踪的长时间远端命令 |
132
+ | `ssh_operation_status` | 读取状态、PID、退出码和输出计数 |
133
+ | `ssh_operation_read` | 按字节偏移读取有上限的 stdout 和 stderr |
134
+ | `ssh_operation_cancel` | 校验任务 marker 后发送 TERM |
135
+ | `ssh_operation_list` | 列出未过期任务,可按 alias 过滤 |
136
+
123
137
  ### 文件操作
124
138
 
125
139
  | 工具 | 描述 |
@@ -238,9 +252,7 @@ ssh_exec(alias="app-dev", command="whoami && echo $APP_ENV")
238
252
  ssh_exec(alias="app-dev", command="whoami", useLoginUser=true)
239
253
  ```
240
254
 
241
- `ssh_connect` 返回 `identity`、`loginUser`、`runAs`、`reused`、`defaultEnvKeys`、`envKeys`,以及同一 `user@host:port` identity
242
- 下已连接 alias 的 `reusableSessions`,同一个 alias 连接到不同 identity 会被拒绝,并返回现有 identity 和请求
243
- identity,template 缺失时返回可用模板名,`configHost` 缺失时返回 SSH config 候选并提示调用 `ssh_config_list`
255
+ `ssh_connect` 返回实际发布会话的 `identity`、`loginUser`、`runAs`、`reused`、`defaultEnvKeys`、`envKeys`,以及同一 `user@host:port` identity 下已连接 alias 的 `reusableSessions`,并发调用只有在完整会话配置一致时才复用同一 alias,包括 endpoint、认证、`runAs`、环境变量、jump host、keepalive 和 timeout;pending 或 active 连接的配置冲突时会被拒绝,即使 `user@host:port` identity 相同,template 缺失时返回可用模板名,`configHost` 缺失时返回 SSH config 候选并提示调用 `ssh_config_list`
244
256
 
245
257
  ### 跳板机
246
258
 
@@ -279,6 +291,19 @@ ssh_connect(
279
291
  destructive、process-control、service-control、credential-bearing、未限制 `find`、递归 `grep`、长管道、后台任务、直接
280
292
  `su - user -c` 或长运行模式的命令会返回带 `categories` 和 `signals` 的 `commandRisk`
281
293
 
294
+ ### 可跟踪的长时间命令
295
+
296
+ 需要命令跨越一次同步工具调用继续执行时,使用 operation 工具组:
297
+
298
+ ```
299
+ ssh_operation_start(alias="server", command="long-running-job", maxOutputBytes=1048576, startTimeoutMs=30000)
300
+ ssh_operation_status(operationId="op_xxx")
301
+ ssh_operation_read(operationId="op_xxx", stdoutOffset=0, stderrOffset=0, maxBytes=65536)
302
+ ssh_operation_cancel(operationId="op_xxx")
303
+ ```
304
+
305
+ start 返回不可预测的 `operationId`,服务端在请求 SSH channel 前创建记录,保存有硬上限的 stdout 和 stderr,并在校验每个任务独立的 marker 后记录远端 PID;`startTimeoutMs` 限制 channel 建立等待,默认 30 秒、最大 10 分钟,超时错误的 details 返回 `operationId`,对应记录进入可查询的 `unknown` 终态,在旧 channel request 返回或 alias 断开前拒绝同 alias 的另一次 pending start;`maxOutputBytes` 默认 1 MiB、最大 8 MiB,`retentionMs` 默认 1 小时、最大 24 小时,`ssh_operation_read.maxBytes` 默认 64 KiB、最大 1 MiB,marker 和 PID 未完成校验时拒绝取消,shell profile 在 marker 前写入的 stderr 会保留为任务输出,包括未换行 preamble 后紧接 marker 的情况;使用 operation marker 前缀但 token 不匹配、长度超限或进程元数据无效时,记录进入 `failed` 终态、关闭 channel 并开始 retention 计时;断开或替换 SSH session 后才返回的 exec、sudo、SFTP、PTY start 和 operation start callback 都会被拒绝并销毁 channel,sudo callback 在 timeout 后返回时也会先关闭,不会写入密码;operation listener 会在 SSH exec callback 返回前安装,极短命令即使立即输出 marker 并关闭,也会进入终态并设置 `finishedAt` 和 `expiresAt`;SSH 会话在 tracked command 运行期间断开后状态变为 `unknown`,不会声称远端进程已经停止,`ssh_exec` 保持原有同步 timeout 行为
306
+
282
307
  ### 交互式命令(PTY 模式)
283
308
 
284
309
  用于需要终端的命令:
@@ -348,16 +373,15 @@ ssh_read_file(alias="server", remotePath="/var/log/app.log", offset=1048576, max
348
373
  ssh_read_file(alias="server", remotePath="/var/log/app.log", lineRange="120-180")
349
374
  ```
350
375
 
351
- `ssh_upload` 返回本地路径策略诊断、远端父目录探测、远端目标元数据和可选校验结果,`atomic=true` 会先上传到同目录临时文件,再
352
- rename 到目标路径,`verifySize`、`verifyMd5`、`verifyMode`、`verifyOwner`、`verifyMtime` 会追加显式传输后校验,命令执行结果在远端命令非零退出且没有
353
- stdout/stderr 时返回
354
- `emptyOutputFailure=true`,同时给出 effective user、cwd 和可用的后续读取建议,`ssh_read_file` 默认读取 1 MiB,`maxBytes` 超过
355
- 16 MiB 时会在远端传输前拒绝,返回 `total_size`、`read_offset`、`read_bytes`、
356
- `remaining_bytes`、`sample_kind` 和 `truncated`,调用方可以区分完整读取、头部样本、尾部样本、字节范围和行范围
376
+ `ssh_upload` 返回本地路径策略诊断、远端父目录探测、远端目标元数据和可选校验结果,`atomic=true` 使用不可预测的同目录临时路径和 SFTP 独占创建,返回 `diagnostics.tempRemotePath`,先对临时文件完成全部请求的校验,再 rename 到目标路径;响应使用 `finalRemotePath` 表示最终目标,`verifiedRemotePath` 表示实际执行校验的路径,atomic 校验还会返回 `verifiedTempRemotePath`,`verification.actual.remotePath` 始终描述真正被校验的文件,即使该临时路径随后已被 rename,最终状态需要结合 `targetReplaced` 和 `targetReplacementStatus` 判断;已有目标通过 OpenSSH `posix-rename@openssh.com` 扩展替换,新目标使用标准 SFTP rename;客户端无法发出 rename 请求时返回 `operationStatus="failed"`、`targetReplaced=false` 和 `targetReplacementStatus="not_replaced"`,请求发出后的错误无法证明服务端是否已提交,返回 `operationStatus="unknown"`、`targetReplaced=null` 和 `targetReplacementStatus="unknown"`,重试前应先检查目标内容;两种失败都会尝试清理临时文件;`verifySize`、`verifyMd5`、`verifyMode`、`verifyOwner`、`verifyMtime` 会追加显式传输校验,父目录和目标探测、递归建目录、文件哈希、rename、临时文件清理都使用 SFTP,普通上传不依赖 GNU `stat`、`md5sum`、`sha256sum`、`mkdir`、`mv` 或 `rm`,可用于禁用 exec 的 SFTP-only 服务和 BSD 系统,显式目录 manifest 校验仍会执行远端 shell 命令
377
+
378
+ `ssh_download` 先写入目标同目录的临时文件,SFTP 流关闭且传输字节数与 SFTP `stat` 报告的大小一致后再 rename 到本地目标;下载失败、提前截断或取消时会删除临时文件,已有本地目标保持原内容,SFTP 目录列表在构造子路径前会拒绝空名称、`.`、`..`、NUL 和路径分隔符
379
+
380
+ 命令执行结果在远端命令非零退出且没有 stdout/stderr 时返回 `emptyOutputFailure=true`,同时给出 effective user、cwd 和可用的后续读取建议,`ssh_read_file` 默认读取 1 MiB,`maxBytes` 超过 16 MiB 时会在远端传输前拒绝,返回 `total_size`、`read_offset`、`read_bytes`、`remaining_bytes`、`sample_kind` 和 `truncated`,调用方可以区分完整读取、头部样本、尾部样本、字节范围和行范围
357
381
 
358
- ### 目录同步(rsync)
382
+ ### 使用 rsync 或 SFTP 同步目录
359
383
 
360
- 智能同步会自动检测 rsync 可用性,使用 rsync 进行高效增量传输:
384
+ 智能同步只在直连且存在已校验 key path 或可用 SSH agent 时选择 rsync,password、inline key、jump host 和其他无法安全交给 OpenSSH 的路由直接使用 SFTP:
361
385
 
362
386
  ```
363
387
  // 同步本地目录到远程(上传)
@@ -367,7 +391,7 @@ ssh_sync(
367
391
  remotePath="/remote/project",
368
392
  direction="upload"
369
393
  )
370
- // 返回: { method: "rsync", filesTransferred: 42, ... }
394
+ // 返回 selectedTransport、decisionReason、各阶段耗时和传输计数
371
395
 
372
396
  // 带排除模式
373
397
  ssh_sync(
@@ -391,16 +415,24 @@ ssh_sync(..., dryRun=true)
391
415
 
392
416
  // 上传单文件后校验远端 owner/mode
393
417
  ssh_sync(..., direction="upload", verifyOwner="appuser", verifyMode="0644")
418
+
419
+ // 使用有界 manifest 校验目录
420
+ ssh_sync(
421
+ ...,
422
+ verify={count: true, sha256: true, owner: true, mode: true, staleFiles: true}
423
+ )
424
+
425
+ // 校验传输前存在且应由 --delete 删除的条目已经消失
426
+ ssh_sync(..., delete=true, verify={deletions: true})
394
427
  ```
395
428
 
396
- 如果远程或本地没有 rsync,会自动回退到 SFTP,同步响应包含 `transport`、`duration`、`dryRun`、`stats`、`commandSummary` 和
397
- `diagnostics`,其中 `diagnostics` 包含本地路径策略和远端父目录探测结果,SFTP 单文件传输会返回 `verification`,包含本地和远端的
398
- size、mode 或 permissions、mtime、owner/group,以及远端支持 `sha256sum` 时的 SHA-256 对比,upload 单文件同步可用
399
- `verifyOwner` 和 `verifyMode` 追加基于远端元数据的 `ownerMode` 校验,目录同步不递归扫描 owner/mode,会返回 skipped
400
- verification 说明
429
+ 目录源路径在 rsync 和 SFTP 模式下都表示“把源目录内容同步到目标根目录”,目录源使用 `recursive=false` 会被明确拒绝,相对排除模式按源目录下的相对路径匹配,不含 `/` 的模式匹配每一级 basename
430
+
431
+ 目录校验会生成有界的本地和远端 manifest,可比较条目数、SHA-256 root manifest、owner、mode、旧文件和删除结果,`verify.deletions=true` 必须同时设置 `delete=true`,工具会在传输前记录目标目录,只检查这些删除候选是否消失,`staleFiles` 则独立检查目标端全部额外条目,响应只返回摘要和最多 20 个 mismatch 样本,不返回完整 manifest,默认上限为 10000 个条目、单文件 256 MiB、总哈希字节 1 GiB,可通过 `verify.maxEntries`、`verify.maxFileBytes` 和 `verify.maxTotalBytes` 提高到最多 50000 个条目、单文件 4 GiB、总哈希字节 16 GiB,遇到被跳过的 symlink 或不支持的文件系统条目时,校验会明确返回 `skipped`,不会报告部分匹配成功
432
+
433
+ 请求校验后,mismatch、skipped 或校验错误都会令顶层 `success=false`,`transferSuccess` 仍单独表示传输是否完成,`verificationStatus`、`verificationSuccess` 和 `failedChecks` 描述校验结果,SFTP 单文件同步还会返回本地和远端的 size、mode 或 permissions、mtime、owner/group,以及通过 SFTP 流读取计算的 SHA-256 对比,upload 单文件使用 `verifyOwner` 和 `verifyMode`,目录逐项校验使用 `verify.owner` 和 `verify.mode`
401
434
 
402
- **注意**:rsync 模式使用 SSH 密钥/代理认证,并设置 `StrictHostKeyChecking=accept-new`(首次连接会自动接受主机密钥),
403
- 如需严格的主机密钥验证与管理,请使用 SFTP 模式
435
+ 只有直连且存在已校验 key path 或可用 SSH agent 时才选择 rsync,password、inline key 和 jump host 会使用 SFTP,因为独立 OpenSSH 进程无法安全继承对应路由或认证材料,`preflightTimeout`、`connectTimeout` 和 `operationTimeout` 分别限制能力预检、rsync SSH 建连和完整传输,默认值为 10 秒、30 秒和 10 分钟,不具备 rsync 条件的 session 会返回 `rsyncProbe.status="skipped"` 和路由判定原因,不再省略 probe,rsync 模式设置 `StrictHostKeyChecking=accept-new`,SFTP 不支持 `delete=true`,此类请求会明确失败,不会报告已经删除,如需严格的主机密钥验证与管理,请使用 SFTP 模式
404
436
 
405
437
  ### 持久化 PTY 会话(top、tmux 等)
406
438
 
@@ -439,7 +471,8 @@ ssh_pty_write(ptyId="pty_1_xxx", data="\x02d")
439
471
  ```
440
472
 
441
473
  `ssh_pty_read` 和 `ssh_pty_list` 返回 `lastInputAt`、`lastOutputAt`、`lastReadAt`、`unreadRawBytes`、`rawBufferLimit`、
442
- `foregroundProcess`,便于观察长时间运行的会话,无需读取完整 raw 流
474
+ `foregroundProcess`,便于观察长时间运行的会话,无需读取完整 raw 流,有限命令自然结束后仍可读取最终 screen,返回 `active=false`,
475
+ 直到显式 close 或 closed session 保留期结束,默认 5 分钟,可通过 `SSH_MCP_PTY_CLOSED_RETENTION_MS` 调整
443
476
 
444
477
  常用控制序列:
445
478
 
@@ -461,13 +494,23 @@ ssh_forward_local(alias="server", localPort=13306, remoteHost="<service-host>",
461
494
  // 远程转发:将本地开发服务器 (3000) 暴露到远程端口 8080
462
495
  ssh_forward_remote(alias="server", remotePort=8080, localHost="127.0.0.1", localPort=3000)
463
496
 
497
+ // 由 SSH 服务器动态分配远程端口,使用返回结果中的 remotePort
498
+ ssh_forward_remote(alias="server", remotePort=0, localHost="127.0.0.1", localPort=3000)
499
+
464
500
  // 列出所有转发
465
501
  ssh_forward_list()
466
502
 
467
- // 关闭转发
468
- ssh_forward_close(forwardId="fwd_1_xxx")
503
+ // listener 释放后返回成功
504
+ ssh_forward_close(forwardId="fwd_1_xxx", mode="graceful", timeoutMs=5000)
505
+
506
+ // 销毁活跃连接后释放 listener
507
+ ssh_forward_close(forwardId="fwd_1_xxx", mode="force", timeoutMs=5000)
469
508
  ```
470
509
 
510
+ 关闭成功表示本地 `server.close` 或远端 `unforwardIn` callback 已完成,结果包含 `listenerReleased`、`remoteUnforwarded`、`activeConnections`、`closeMode` 和 `retryable`,超时或 callback 失败时 forward 仍保留在 `ssh_forward_list`,可以使用同一 `forwardId` 重试,本地转发关闭成功后端口可立即重新 bind,`remotePort=0` 会返回实际分配端口,后续连接路由和 `unforwardIn` 都使用该端口
511
+
512
+ forward 在 `listen` 或 `forwardIn` 完成前就进入生命周期管理,disconnect 会取消 pending creation;延迟返回的本地 listener 会被关闭,延迟分配的远端 listener 会被移除;close 开始后立即拒绝新的本地或远端连接,`forwardOut`、close 和 unforward 的延迟 callback 修改状态前会检查同一生命周期记录,已关闭的 forward 不会重新出现在 `ssh_forward_list`;每条本地转发连接同时跟踪本地 socket 和 SSH `forwardOut` channel,任一端关闭或失败都会销毁另一端,force close 只在两端都销毁且 `activeConnections` 归零后返回;每个 alias 最多允许 32 个 pending `forwardOut` 请求,close 会等待全部 callback;如果 SSH 服务端始终不回应 channel-open,请求会超时并保留可重试的 forward,同时拒绝同 alias 新建 local forward,避免 ssh2 pending channel 继续累积,此时断开 alias 才能释放始终不返回的底层请求
513
+
471
514
  ## 配置选项
472
515
 
473
516
  ### 连接选项
@@ -485,6 +528,10 @@ ssh_forward_close(forwardId="fwd_1_xxx")
485
528
  | `defaultEnv` | object | - | 连接级默认环境变量 |
486
529
  | `runAs` | string | - | 默认执行用户 |
487
530
  | `keepaliveInterval` | number | 30000 | 心跳间隔(毫秒) |
531
+ | `readyTimeout` | number | 30000 | 等待 SSH ready 的超时,最大 600000 毫秒 |
532
+ | `jumpHost.readyTimeout` | number | 继承顶层值 | 跳板机等待 SSH ready 的超时,最大 600000 毫秒 |
533
+
534
+ 连接失败返回 `failureStage`、`retryable` 和限量建议,`failureStage` 为 `preflight`、`authentication`、`ready_timeout`、`transport_or_handshake` 或 `unknown`,多跳连接还可能返回 `connectionStep`,取值为 `key_read`、`jump_connect`、`jump_forward` 或 `target_connect`
488
535
 
489
536
  ### 执行选项
490
537
 
@@ -499,6 +546,8 @@ ssh_forward_close(forwardId="fwd_1_xxx")
499
546
  | `useLoginUser` | boolean | false | 跳过连接级 runAs |
500
547
  | `loadProfile` | boolean | true | runAs 时加载目标用户 shell 配置 |
501
548
 
549
+ 传入 `cwd` 或 `env` 时,生成的 shell 命令会用 `&&` 连接 `cd` 和每个通过校验的 `export`,再把完整用户命令作为当前登录 shell 的一个转义后 `eval` 参数执行;目录切换或环境变量注入失败后,用户命令的任何部分都不会执行,包括 `;`、换行或 `||` 后的内容,同时 Bash/Zsh 专有语法保持与直接 SSH 命令相同的解释器语义
550
+
502
551
  ## 安全
503
552
 
504
553
  ### 私钥/配置文件路径白名单
@@ -525,7 +574,7 @@ export SSH_MCP_ALLOWED_KEY_DIRS=/opt/secrets:/var/lib/keys
525
574
  export SSH_MCP_FILE_OPS_ALLOW_DIRS=/tmp:/home/me/work
526
575
  ```
527
576
 
528
- 设置后,白名单外的本地路径会被拒绝,symlink 会通过 `realpath` 解析以防逃逸;未设置时不做限制(保留灵活性)
577
+ 设置后,白名单外的本地路径会被拒绝,symlink 会通过 `realpath` 解析;白名单生效时,`ssh_sync(direction="upload", followSymlinks=true)` 会在选择 transport 前被拒绝,symlink 可在校验和传输之间改变目标,rsync 也无法把预检目标绑定到后续 `-L` 读取;应保持 `followSymlinks=false`,或先把普通文件复制到允许目录再同步
529
578
 
530
579
  ### 文件大小上限
531
580
 
@@ -540,10 +589,10 @@ export SSH_MCP_FILE_OPS_ALLOW_DIRS=/tmp:/home/me/work
540
589
 
541
590
  | `followSymlinks` | SFTP 路径 | rsync 路径 |
542
591
  |------------------|----------------------------------------|--------------------------------------------|
543
- | `false`(默认) | 跳过,写入 `skippedSymlinks` 字段,warning 中提示 | 按 symlink 本身复制(rsync 默认:保留链接,不上传目标内容) |
592
+ | `false`(默认) | 跳过,写入 `skippedSymlinks` 字段,warning 中提示 | 通过 `--no-links` 跳过 |
544
593
  | `true` | 跟随:上传链接目标内容 | 通过 rsync `-L` / `--copy-links` 跟随:上传链接目标内容 |
545
594
 
546
- 两个默认模式都安全(都不会上传链接目标内容),差异仅在于目标端是否保留 symlink:SFTP 完全跳过不传,rsync 保留为 symlink
595
+ 两种传输都会跳过 device 和特殊文件系统条目,SFTP 返回 `skippedUnsupported` 和最多 10 个样本路径,rsync 使用 `--no-devices --no-specials`,目录校验也会报告被跳过的 symlink 和不支持条目,不会把不完整 manifest 当成匹配成功
547
596
 
548
597
  ## 项目结构
549
598
 
@@ -0,0 +1,7 @@
1
+ export type CommandRisk = {
2
+ level: 'medium' | 'high';
3
+ categories: string[];
4
+ signals: string[];
5
+ suggestion: string;
6
+ };
7
+ export declare function classifyCommandRisk(command: string, timeout?: number): CommandRisk | undefined;
@@ -0,0 +1,106 @@
1
+ function pushRisk(categories, signals, category, signal) {
2
+ categories.add(category);
3
+ signals.push(signal);
4
+ }
5
+ function hasBackgroundOperator(command) {
6
+ let quote;
7
+ let escaped = false;
8
+ for (let index = 0; index < command.length; ++index) {
9
+ const character = command[index];
10
+ if (escaped) {
11
+ escaped = false;
12
+ continue;
13
+ }
14
+ if (character === '\\' && quote !== "'") {
15
+ escaped = true;
16
+ continue;
17
+ }
18
+ if (quote) {
19
+ if (character === quote) {
20
+ quote = undefined;
21
+ }
22
+ continue;
23
+ }
24
+ if (character === "'" || character === '"') {
25
+ quote = character;
26
+ continue;
27
+ }
28
+ if (character !== '&') {
29
+ continue;
30
+ }
31
+ const previous = command[index - 1];
32
+ const next = command[index + 1];
33
+ if (previous === '&' || next === '&' || previous === '>' || previous === '<' || next === '>') {
34
+ continue;
35
+ }
36
+ return true;
37
+ }
38
+ return false;
39
+ }
40
+ export function classifyCommandRisk(command, timeout) {
41
+ const signals = [];
42
+ const categories = new Set();
43
+ const pipeCount = (command.match(/\|/g) ?? []).length;
44
+ const lowerCommand = command.toLowerCase();
45
+ const background = hasBackgroundOperator(command);
46
+ const continuous = /\b(?:tail\s+-f|journalctl\s+-f|watch|top|htop)\b/.test(command);
47
+ const unboundedFind = /\bfind\b/.test(command) && !/\s-maxdepth\s+\d+/.test(command);
48
+ const recursiveGrep = /\bgrep\s+(?:-\S*R|--recursive)\b/.test(command);
49
+ if (command.length > 500) {
50
+ pushRisk(categories, signals, 'complexity-signal', 'long_command');
51
+ }
52
+ if (pipeCount >= 3) {
53
+ pushRisk(categories, signals, 'complexity-signal', 'long_pipeline');
54
+ }
55
+ if (recursiveGrep) {
56
+ pushRisk(categories, signals, 'long-running', 'recursive_grep');
57
+ }
58
+ if (unboundedFind) {
59
+ pushRisk(categories, signals, 'long-running', 'unbounded_find');
60
+ }
61
+ if (/\b(?:python|python3|node|perl|ruby)\b/.test(command)) {
62
+ pushRisk(categories, signals, 'script-execution', 'interpreter_script');
63
+ }
64
+ if (/\bsleep\s+\d{2,}\b/.test(command) || continuous) {
65
+ pushRisk(categories, signals, 'long-running', continuous ? 'continuous_command' : 'long_sleep');
66
+ }
67
+ if (background) {
68
+ pushRisk(categories, signals, 'process-control', 'background_task');
69
+ }
70
+ const recursiveRemove = /\brm\b(?=[^\n;|&]*(?:\s-[a-z]*r[a-z]*\b|\s--recursive\b))/.test(lowerCommand);
71
+ if (recursiveRemove || /\b(?:dd\s+if=|mkfs|fdisk|parted|shutdown|reboot)\b/.test(lowerCommand)) {
72
+ pushRisk(categories, signals, 'destructive', 'destructive_command');
73
+ }
74
+ const processControl = /\b(?:pkill|killall)\b/.test(lowerCommand) || /\bkill\s+(?!-0(?:\s|$))/.test(lowerCommand);
75
+ if (processControl) {
76
+ pushRisk(categories, signals, 'process-control', 'process_control');
77
+ }
78
+ if (/\b(?:systemctl|service|docker|kubectl)\s+(?:restart|stop|kill|delete|rm|down)\b/.test(lowerCommand)) {
79
+ pushRisk(categories, signals, 'service-control', 'service_control');
80
+ }
81
+ if (/\b(?:password|passwd|token|authorization|cookie|secret|private[_-]?key)\b/i.test(command)) {
82
+ pushRisk(categories, signals, 'credential-bearing', 'credential_bearing');
83
+ }
84
+ if (/\bsu\s+-?\s*[a-zA-Z_][a-zA-Z0-9_-]*\s+-c\b/.test(command)) {
85
+ pushRisk(categories, signals, 'user-switch', 'direct_su_command');
86
+ }
87
+ if (signals.length === 0) {
88
+ return undefined;
89
+ }
90
+ const boundedTimeout = timeout !== undefined && timeout > 0 && timeout <= 300_000;
91
+ const high = categories.has('destructive') ||
92
+ categories.has('service-control') ||
93
+ categories.has('process-control') ||
94
+ continuous ||
95
+ ((unboundedFind || recursiveGrep) && !boundedTimeout);
96
+ return {
97
+ level: high ? 'high' : 'medium',
98
+ categories: Array.from(categories),
99
+ signals,
100
+ suggestion: signals.includes('direct_su_command')
101
+ ? '建议使用 ssh_exec 的 runAs 参数或 ssh_exec_as_user,避免手写 su 命令造成引用和环境加载差异'
102
+ : high
103
+ ? '长任务使用 ssh_operation_start,交互命令使用 ssh_pty_start,破坏性操作执行前确认目标范围'
104
+ : '如输出较大,请设置 maxOutputSize 或重定向到远端文件后分块读取',
105
+ };
106
+ }