Skip to main content
Glama

ssh_exec

Destructive

Run shell commands on a remote host over SSH and return exit code, stdout, and stderr for non-interactive tasks with optional working directory, stdin, sudo, and timeout.

Instructions

Run a shell command on a remote host and return exit_code, stdout and stderr.

The command runs non-interactively in the remote user's shell (no TTY; stdin is closed unless stdin is given), so use non-interactive flags such as apt-get -y. Each call is a fresh shell: use cwd or cd x && ... instead of relying on a previous cd. On timeout the command and its children are killed. For anything slower than a few minutes, or that must keep running (servers, builds, training, tail -f), use ssh_job_start instead.

Args: target: device name, ~/.ssh/config alias, or [user@]host[:port]. command: shell command line (multi-line scripts are fine). timeout: seconds before the command is killed (default from config, 60s). cwd: directory to run the command in. stdin: text fed to the command's standard input (e.g. file content for tee file). sudo: run as root. Uses the device's sudo_password if configured, else sudo -n.

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": {
      "target": "<target>",
      "command": "<command>"
    },
    "name": "ssh_exec"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNo
sudoNo
stdinNo
targetYes
commandYes
timeoutNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A5/5.0
Behavior5/5

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

Annotations only declare destructive/openWorld/not-readOnly; the description adds the operative behavior an agent actually needs: no TTY, stdin closed unless supplied, fresh shell per call with no state carryover, and that a timeout kills the command and its children. The sudo path is also disclosed (device sudo_password if configured, else `sudo -n`), which explains why a privilege escalation may fail.

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?

Front-loaded one-line purpose, then a compact paragraph of behavioral constraints, then a scannable Args block. The size is justified by six undocumented parameters; no sentence is filler, and the long-running caveat is placed where it will be read before invoking.

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

Completeness5/5

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

An output schema exists, so return values need no explanation, and annotations cover the safety profile. Given a high-risk remote-execution tool with zero schema descriptions, the description supplies exactly what is missing: invocation constraints, state model, termination behavior, and privilege handling.

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

Parameters5/5

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

Schema coverage is 0%, so the description carries the full burden and does: target is documented as a device name, ~/.ssh/config alias, or [user@]host[:port]; timeout is seconds with a 60s default; cwd and stdin get concrete semantics (file content for `tee file`); sudo explains the credential mechanism. All six parameters gain meaning absent from the bare schema.

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

Purpose5/5

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

The description opens with a specific verb ('Run a shell command') and resource ('on a remote host') and states the return payload (exit_code, stdout, stderr). It also distinguishes itself from the sibling ssh_job_start for long-lived work, so an agent can tell the two apart without opening either schema.

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

Usage Guidelines5/5

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

Explicit routing guidance: use non-interactive flags such as `apt-get -y`, use `cwd` or `cd x && ...` because each call is a fresh shell, and use ssh_job_start instead for anything slow or long-running (servers, builds, training, `tail -f`). Both when-to-use and the alternative are named.

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