ssh_file_read
Read remote file contents via SFTP to avoid shell and console encoding problems, ensuring correct Unicode and binary-safe transfers.
Instructions
Read file contents directly via SFTP.
This tool reads raw bytes from the remote file using SFTP and decodes them on the client side. Unlike command-based file reading (cat, Get-Content), SFTP completely bypasses shell and console encoding issues.
Why use this instead of ssh_cmd_run with cat/Get-Content?
Works correctly with Unicode on ALL platforms including Windows
Bypasses Windows PowerShell's OEM code page encoding problem
More efficient for binary-safe file transfer
No shell escaping issues with special characters in content
Returns: Dictionary with: - success: True if file was read successfully - content: The file contents as a string - size: Number of bytes read - encoding: The encoding used to decode the content
Long-running calls: if this takes longer than the server's wait cap (default 50s), it
returns {"status": "in_progress", "handle_id": ...} instead of the result - the work keeps
running. Get the result by polling ssh_cmd_check_status(handle_id=...), which returns this
tool's normal response once finished. Do not call it again meanwhile. Only one such
operation runs at a time; another one started meanwhile fails with a 'busy' error.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| encoding | No | Character encoding (default: utf-8) | utf-8 |
| max_size | No | Maximum file size in bytes (default: 10MB, 0 for no limit) | |
| file_path | Yes | Path to the file to read |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||