Skip to main content
Glama

Write File

write_file

Write 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

NameRequiredDescriptionDefault
hostYesHostname, IP address, or SSH config alias
portNoSSH port (optional)
appendNoAppend to file instead of overwriting (default: False)
errorsNoError handling for encoding (default: strict)strict
contentYesContent to write
encodingNoText encoding (default: utf-8)utf-8
passwordNoSSH password (optional)
use_sudoNoUse sudo for writing (tries passwordless if no sudo_password provided)
usernameNoSSH username (optional)
make_dirsNoCreate parent directories if they don't exist (default: False)
max_bytesNoMaximum bytes to write (default: 2MB)
permissionsNoOctal file permissions to set (e.g., 420 for 0644)
remote_pathYesPath to the remote file
key_filenameNoPath to SSH key file (optional)
sudo_passwordNoPassword for sudo (optional, not needed if NOPASSWD configured)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.2+p1

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and it does add real value by disclosing two distinct execution paths: sudo via shell (tee) versus SFTP. However, it omits the destructive implications (overwrites by default unless append=true), the default 2MB write ceiling that can truncate content, and any failure/permission-error behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, front-loaded with the core action, followed by the mechanism branching. No filler and nothing repeated from the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 15-parameter mutation tool with no annotations and no output schema, the description covers the mechanism but not the risk profile: silent truncation at the default max_bytes, overwrite-versus-append default behavior, and what a failure looks like. The fully documented schema covers parameter meanings, keeping this adequate rather than deficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds a cross-parameter interaction the schema cannot express: use_sudo or sudo_password switches the write from SFTP to a sudo shell command with tee. That materially changes how the agent should interpret and combine those parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource plus the transport ('Write content to a remote file over SSH'), which cleanly separates it from the read_file sibling. It stops short of naming the sibling or the scope boundary explicitly, so it is clear but not fully differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to prefer this over alternatives such as execute_command (which could also write files via shell redirection), nor any prerequisites or exclusions. The only routing logic given is internal mechanism selection (sudo vs SFTP), which is behavioral rather than when-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.