Skip to main content
Glama

exec

Run commands on remote Linux hosts over SSH, including parallel execution, sudo, PowerShell, stdin, and Docker containers.

Instructions

在主机上执行命令,效果同 ssh <host> '<cmd>';cmd 不用带最外层的引号。可用主机:

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>"
    },
    "name": "exec"
  }
}

Input Schema

NameRequiredDescriptionDefault
cmdNo
cmdsNo最多 10 条互不依赖的命令同时执行,如 {"ps":"docker ps","disk":"df -h /"};结果按标签分段,各带退出码。有先后依赖的步骤写进同一条 cmd
connNo这次单独改连接参数,只能配一台主机:port、user、identity(本机私钥路径,只用这把)、jump(跳板,须是上面的别名)、hostname(改连的地址,对端主机密钥须和该别名记录的一致)、password(密码登录,只试一次)。带 conn 时不复用已有连接
hostYes主机别名;传数组则在几台主机上同时执行
pswdNosudo 要的密码,一般是登录用户自己的;只试一次
sudoNo以 root 身份运行,家目录也换成 root 的;sudo 要密码时再传 pswd
shellNo默认 posix,主机列表里标了 shell 的主机用标的那个。PowerShell 脚本以 base64 编码传送,不受引号影响
stdinNo传给 cmd 的标准输入,脚本放这里就不用处理引号:cmd 写 "python3 -"、"sh -s" 或 "sqlite3 -readonly x.db"
redactNo给输出里的密钥值打码(password=、token:、Bearer ...),默认 true
timeoutNo秒,默认 60,最多 3600
containerNo在这个 docker 容器里执行
max_charsNo每路输出的字符上限,默认 4000

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed15 schema fields changedv0.3.0
    • addedInput schema / properties / cmds
      Added value: +{
      +  "additionalProperties": {
      +    "type": "string"
      +  },
      +  "description": "最多 10 条互不依赖的命令同时执行,如 {\"ps\":\"docker ps\",\"disk\":\"df -h /\"};结果按标签分段,各带退出码。有先后依赖的步骤写进同一条 cmd",
      +  "propertyNames": {
      +    "type": "string"
      +  },
      +  "type": "object"
      +}
    • addedInput schema / properties / conn
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "这次单独改连接参数,只能配一台主机:port、user、identity(本机私钥路径,只用这把)、jump(跳板,须是上面的别名)、hostname(改连的地址,对端主机密钥须和该别名记录的一致)、password(密码登录,只试一次)。带 conn 时不复用已有连接",
      +  "properties": {
      +    "hostname": {
      +      "pattern": "^[\\w.:-]+$",
      +      "type": "string"
      +    },
      +    "identity": {
      +      "minLength": 1,
      +      "type": "string"
      +    },
      +    "jump": {
      +      "type": "string"
      +    },
      +    "password": {
      +      "type": "string"
      +    },
      +    "port": {
      +      "maximum": 65535,
      +      "minimum": 1,
      +      "type": "integer"
      +    },
      +    "user": {
      +      "pattern": "^[\\w.-]+$",
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
    • addedInput schema / properties / container
      Added value: +{
      +  "description": "在这个 docker 容器里执行",
      +  "type": "string"
      +}
    • addedInput schema / properties / host / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "items": {
      +      "type": "string"
      +    },
      +    "minItems": 1,
      +    "type": "array"
      +  }
      +]
    • addedInput schema / properties / host / description
      Added value: +"主机别名;传数组则在几台主机上同时执行"
    • removedInput schema / properties / host / type
      Removed value: -"string"
    • changedInput schema / properties / max_chars / description
      Previous value: -"Per-stream output cap, default 8000"New value: +"每路输出的字符上限,默认 4000"
    • addedInput schema / properties / pswd
      Added value: +{
      +  "description": "sudo 要的密码,一般是登录用户自己的;只试一次",
      +  "type": "string"
      +}
    • addedInput schema / properties / redact
      Added value: +{
      +  "description": "给输出里的密钥值打码(password=、token:、Bearer ...),默认 true",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / shell
      Added value: +{
      +  "description": "默认 posix,主机列表里标了 shell 的主机用标的那个。PowerShell 脚本以 base64 编码传送,不受引号影响",
      +  "enum": [
      +    "posix",
      +    "pwsh",
      +    "powershell"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / stdin
      Added value: +{
      +  "description": "传给 cmd 的标准输入,脚本放这里就不用处理引号:cmd 写 \"python3 -\"、\"sh -s\" 或 \"sqlite3 -readonly x.db\"",
      +  "type": "string"
      +}
    • addedInput schema / properties / sudo
      Added value: +{
      +  "description": "以 root 身份运行,家目录也换成 root 的;sudo 要密码时再传 pswd",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / timeout / description
      Previous value: -"Seconds, default 60"New value: +"秒,默认 60,最多 3600"
    • changedInput schema / properties / timeout / maximum
      Previous value: -600New value: +3600
    • changedInput schema / required
      Previous value: -[
      -  "host",
      -  "cmd"
      -]New value: +[
      +  "host"
      +]
  2. First observedv0.1.0

TDQS

B3/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full disclosure burden, yet it says nothing about the fact that this mutates the remote host, requires authentication, or is dangerous without care. The ssh equivalence and the quoting hint are genuinely useful behavioral context, but for an unrestricted remote-execution tool that is far short of adequate.

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

Conciseness3/5

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

The body is appropriately short and front-loads the essential definition before the quoting caveat. However, the sentence trails off with a dangling "可用主机:" and a list of available hosts that is missing, so the description ends incomplete and wastes the final clause.

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

Completeness2/5

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

This is a 12-parameter, nested-schema, unannotated mutation tool with no output schema, so the description needs to carry substantial weight. Instead it covers only the basic semantics and leaves the promised host list, safety expectations, authentication, and result format entirely unaddressed.

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

Parameters3/5

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

Schema description coverage is 92%, so nearly every one of the 12 parameters is already documented in the schema, which sets the baseline at 3. The description adds one real clarification that the schema does not: cmd should not include the outermost quotes. That is a marginal addition on top of an already well-documented schema.

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?

The description gives a specific verb plus resource ("在主机上执行命令") and anchors it with a concrete analogy ("效果同 `ssh <host> '<cmd>'`"), so an agent immediately knows this is remote command execution rather than a local operation. It does not distinguish itself from the sibling tools file_write or pipe, which removes the top tier.

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

Usage Guidelines3/5

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

The ssh analogy implies the usage context, and the note that cmd needs no outer quoting helps an agent shape the call. However, there is no explicit when-to-use or when-not-to-use guidance, and nothing tells the agent why it would pick this over pipe or file_write for the same host.

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

Deploy Server

Other Tools