Skip to main content
Glama
SSH MCP Server

SSH MCP Server

by YawLabs

ssh_multi_exec

Execute a shell command on multiple remote SSH hosts in parallel, returning per-host status and output so you can compare results without separate calls.

Instructions

Execute a command on multiple remote hosts in parallel. Runs at most SSH_MCP_MAX_POOL_SIZE hosts at once (default 100) and works through a longer list as slots free up. timeout is per host: it bounds each host's command, not the whole call. Each parallel slot works through its share of the list one host at a time, so with the pool to itself a call can take up to about ceil(hosts / SSH_MCP_MAX_POOL_SIZE) x (timeout + connect time). The connection pool is shared with every other tool; when it is full this call waits for slots instead of failing, and gives up only when none of its own hosts holds a slot and a full timeout has passed with none of them starting or finishing. The hosts waiting at that point (up to one per parallel slot) and every host still queued then report Connection pool is full; the queued ones are never attempted. Rerun those hosts once the other calls finish, or raise SSH_MCP_MAX_POOL_SIZE. Returns a summary first (one status line per host: exit code, signal, or ERROR), then each host's output, so a proxy that cuts long results keeps every host's status. The whole result is flagged isError when ANY host failed to run the command or exited non-zero -- unlike the single-host exec tool, which reports a non-zero exit only in its status block and does not set isError. Use this instead of running the same command against each host one call at a time — it's faster and shows results side by side. Use env to set environment variables for this call without modifying the command string. Subject to SSH_MCP_COMMAND_WHITELIST / SSH_MCP_COMMAND_BLACKLIST if configured (policy is checked once, against the env-prefixed command, before fan-out). While a whitelist is active, shell control syntax and leading variable assignments are refused unless the server sets SSH_MCP_COMMAND_ALLOW_SHELL_SYNTAX=1. Policy is a best-effort guard rail, not a security boundary.

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": {
      "hosts": "<hosts>",
      "command": "<command>"
    },
    "name": "ssh_multi_exec"
  }
}

Input Schema

NameRequiredDescriptionDefault
envNoEnvironment variables to set for this command. Injected as a `KEY='value' ...` prefix; works on any sshd regardless of AcceptEnv config. VALUES are POSIX-single-quoted, so any byte is safe in a value. KEYS cannot be quoted (a shell assignment prefix requires a bare name), so each key must match /^[A-Za-z_][A-Za-z0-9_]*$/ (the POSIX name grammar) — a key outside that grammar is rejected and the call fails before anything is sent to a host. Command policy is checked against the PREFIXED command, so a `^`-anchored whitelist pattern stops matching once this is set, and while a whitelist is active the call is refused by default because variables such as LD_PRELOAD or PATH change what an allowed command runs.
portNoSSH port (default: 22)
hostsYesList of SSH hostnames or IPs
commandYesShell command to execute on all hosts
timeoutNoPer-host command timeout in milliseconds (default: 30000): bounds each host's command, not the whole call. Also the call's no-progress budget on a full pool (see the tool description).
passwordNoSSH password. STRONGLY prefer key-based auth (privateKeyPath or ssh-agent). Passwords pass through MCP protocol frames as plaintext and may be logged by the transport or host process.
usernameNoSSH username (default: current user)
privateKeyPathNoPath to SSH private key

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.20.0
    • changedInput schema / properties / env / description
      Previous value: -"Environment variables to set for this command. Injected as a `KEY='value' ...` prefix; works on any sshd regardless of AcceptEnv config. VALUES are POSIX-single-quoted, so any byte is safe in a value. KEYS cannot be quoted (a shell assignment prefix requires a bare name), so each key must match /^[A-Za-z_][A-Za-z0-9_]*$/ (the POSIX name grammar) — a key outside that grammar is rejected and the call fails before anything is sent to a host. Command policy is checked against the PREFIXED command, so a `^`-anchored whitelist pattern stops matching once this is set."New value: +"Environment variables to set for this command. Injected as a `KEY='value' ...` prefix; works on any sshd regardless of AcceptEnv config. VALUES are POSIX-single-quoted, so any byte is safe in a value. KEYS cannot be quoted (a shell assignment prefix requires a bare name), so each key must match /^[A-Za-z_][A-Za-z0-9_]*$/ (the POSIX name grammar) — a key outside that grammar is rejected and the call fails before anything is sent to a host. Command policy is checked against the PREFIXED command, so a `^`-anchored whitelist pattern stops matching once this is set, and while a whitelist is active the call is refused by default because variables such as LD_PRELOAD or PATH change what an allowed command runs."
  2. Changed1 schema field changedv0.18.1
    • addedInput schema / properties / hosts / minItems
      Added value: +1
  3. Changed2 schema fields changedv0.17.0
    • addedInput schema / properties / env
      Added value: +{
      +  "additionalProperties": {
      +    "type": "string"
      +  },
      +  "description": "Environment variables to set for this command. Injected as a `KEY='value' ...` prefix; works on any sshd regardless of AcceptEnv config. VALUES are POSIX-single-quoted, so any byte is safe in a value. KEYS cannot be quoted (a shell assignment prefix requires a bare name), so each key must match /^[A-Za-z_][A-Za-z0-9_]*$/ (the POSIX name grammar) — a key outside that grammar is rejected and the call fails before anything is sent to a host. Command policy is checked against the PREFIXED command, so a `^`-anchored whitelist pattern stops matching once this is set.",
      +  "propertyNames": {
      +    "type": "string"
      +  },
      +  "type": "object"
      +}
    • changedInput schema / properties / timeout / description
      Previous value: -"Command timeout in milliseconds (default: 30000)"New value: +"Per-host command timeout in milliseconds (default: 30000): bounds each host's command, not the whole call. Also the call's no-progress budget on a full pool (see the tool description)."
  4. Addedv0.9.1

TDQS

A4.8/5.0
Behavior5/5

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

No annotations exist, so the description carries the full disclosure burden and does so: pool concurrency limits and default, per-host vs whole-call timeout semantics, shared-pool contention and the precise give-up condition, which hosts report `Connection pool is full` and that queued ones are never attempted, result ordering, and isError being set when ANY host fails. It also flags the best-effort nature of the command policy and the whitelist interaction with env prefixes.

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

Conciseness4/5

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

Front-loaded with the core action and the cost model, and nearly every sentence adds operational information an agent cannot get elsewhere. It loses a point because the pool-exhaustion sentence ("gives up only when none of its own hosts holds a slot and a full `timeout` has passed...") is a dense run-on that would read better split or compressed.

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?

For a parallel-execution tool with 8 parameters, no annotations, and no output schema, the description covers risks (pool contention, partial failure), return shape (summary line per host first, then outputs), and error signaling. Nothing needed to invoke it correctly appears to be missing.

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; the description still adds value by explaining that `timeout` bounds each host rather than the call and by giving the approximate ceiling formula ceil(hosts / MAX_POOL_SIZE) x (timeout + connect time), which lets an agent size `timeout` against the host count. It also gives usage semantics for `env` (sets variables for this call without editing the command string) beyond the schema's formatting rules.

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?

Opens with a specific verb and resource: "Execute a command on multiple remote hosts in parallel." The fan-out scope immediately distinguishes it from the single-host sibling, and the description later explicitly contrasts its isError behavior with "the single-host exec tool."

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?

States when to choose this tool: "Use this instead of running the same command against each host one call at a time — it's faster and shows results side by side," which names the alternative pattern and the condition that selects it. It also gives remediation guidance for pool exhaustion ("Rerun those hosts... or raise SSH_MCP_MAX_POOL_SIZE") and names the policy env vars that gate eligibility.

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