Write File
write_fileWrite content to a remote file over SSH using SFTP or sudo, with options to append, create parent directories, set permissions, and encode text.
Instructions
Write content to a remote file over SSH.
If use_sudo is True or sudo_password is provided, uses sudo via shell commands (tee). Otherwise, attempts to write using SFTP.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"host": "<host>",
"remote_path": "<remote_path>",
"content": "<content>"
},
"name": "write_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | Hostname, IP address, or SSH config alias | |
| port | No | SSH port (optional) | |
| append | No | Append to file instead of overwriting (default: False) | |
| errors | No | Error handling for encoding (default: strict) | strict |
| content | Yes | Content to write | |
| encoding | No | Text encoding (default: utf-8) | utf-8 |
| password | No | SSH password (optional) | |
| use_sudo | No | Use sudo for writing (tries passwordless if no sudo_password provided) | |
| username | No | SSH username (optional) | |
| make_dirs | No | Create parent directories if they don't exist (default: False) | |
| max_bytes | No | Maximum bytes to write (default: 2MB) | |
| permissions | No | Octal file permissions to set (e.g., 420 for 0644) | |
| remote_path | Yes | Path to the remote file | |
| key_filename | No | Path to SSH key file (optional) | |
| sudo_password | No | Password for sudo (optional, not needed if NOPASSWD configured) |