Skip to main content
Glama

execute_command

Destructive

Run a command on a device. Use setup to create a terminal or session_id to reuse one. Omit both for an anonymous terminal, which closes on early completion or stays open if the wait expires. Commands can continue after the wait expires. Use session_read for more output and stop task-owned terminals when finished.

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": {
      "command": "<command>",
      "control_token": "<control_token>"
    },
    "name": "execute_command"
  }
}

Input Schema

NameRequiredDescriptionDefault
setupNoCreate a new terminal using optional cwd, env and session_id. Cannot be combined with top-level session_id. An existing setup.session_id is rejected. Omit its ID for a generated anonymous terminal with the usual wait-based lifetime.
commandYesShell command to execute on the target device.
wait_msNoMaximum result wait in milliseconds. Completion returns early. 0 retains an anonymous terminal immediately after admission.
client_idNoDevice ID from list_client. Required with multi-device tokens for execute_command, session_read, session_control, and p2p_transfer_start.
session_idNoReuse an existing session only. Unknown or closed IDs are rejected. To create a terminal, use setup instead.
control_tokenYesControl credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token.

Output Schema

NameRequiredDescriptionDefault
errorNoOptional execution or connection error. A disconnect does not prove the remote process completed successfully.
outputYesCombined terminal output from the requested cursor; may contain echoed input.
statusYesrunning: terminal busy or stop pending; idle: command ended and shell reusable; closed: client confirmed shell termination. Transport errors do not imply termination.
has_moreYesWhether more retained output is available after next_cursor.
exit_codeNoexecute/read/list: the latest completed command exit code, preserved when its shell later ends. stop: the confirmed shell termination code. 0 means success; -1 denotes execution failure. Transport errors never invent a code.
truncatedNoPresent only as true when the requested cursor predates the oldest retained output. The latest 1 MiB is retained; pagination alone does not truncate.
command_idYesIdentifier of the latest command. New clients generate eight case-sensitive alphanumeric characters; older clients may return longer IDs.
session_idNoClient-local session identifier. Multi-device read/control also require client_id.
next_cursorYesByte offset after the returned output. Pass it as cursor in the next session_read.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • changedInput schema / properties / client_id / description
      Previous value: -"Six lowercase letters or digits from list_client. Required for execute_command, session_read and session_control on multi-device tokens, including existing sessions. Session-list filtering is optional."New value: +"Device ID from list_client. Required with multi-device tokens for execute_command, session_read, session_control, and p2p_transfer_start."
    • changedInput schema / properties / wait_ms / description
      Previous value: -"Maximum result wait in milliseconds, default 10000, range 0–20000. Keep the default for ordinary commands; completion returns early. A short wait can retain an anonymous shell and consume a live-terminal slot. 0 retains it immediately. Expiry never kills the command."New value: +"Maximum result wait in milliseconds. Completion returns early. 0 retains an anonymous terminal immediately after admission."
    • changedOutput schema / properties / has_more / description
      Previous value: -"Whether retained output remains after next_cursor; continue reading even after idle or closed."New value: +"Whether more retained output is available after next_cursor."
    • changedOutput schema / properties / next_cursor / description
      Previous value: -"Byte offset immediately after the returned output. Pass it as cursor for the next session_read. Continue while has_more=true, including after status becomes idle or closed."New value: +"Byte offset after the returned output. Pass it as cursor in the next session_read."
  2. Changed3 schema fields changed
    • removedInput schema / properties / client_token
      Removed value: -{
      -  "description": "Control credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token.",
      -  "minLength": 1,
      -  "type": "string"
      -}
    • addedInput schema / properties / control_token
      Added value: +{
      +  "description": "Control credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token.",
      +  "minLength": 1,
      +  "type": "string"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "command",
      -  "client_token"
      -]New value: +[
      +  "command",
      +  "control_token"
      +]
  3. Changed2 schema fields changed
    • changedInput schema / properties / wait_ms / description
      Previous value: -"Completion wait in milliseconds, 0–20000; default 10000. Anonymous terminals close if the command finishes first; otherwise the client retains the same shell under a random session_id. 0 retains immediately. Never stops a running command."New value: +"Maximum result wait in milliseconds, default 10000, range 0–20000. Keep the default for ordinary commands; completion returns early. A short wait can retain an anonymous shell and consume a live-terminal slot. 0 retains it immediately. Expiry never kills the command."
    • changedOutput schema / properties / command_id / description
      Previous value: -"Identity of the latest submitted command."New value: +"Identifier of the latest command. New clients generate eight case-sensitive alphanumeric characters; older clients may return longer IDs."
  4. Changed8 schema fields changed
    • changedInput schema / properties / client_id / description
      Previous value: -"Six lowercase letters or digits from list_clients, used to select or filter devices. For multi-device tokens it is required when a specific device must be selected and no existing session_id identifies it. Session-list filtering is optional."New value: +"Six lowercase letters or digits from list_client. Required for execute_command, session_read and session_control on multi-device tokens, including existing sessions. Session-list filtering is optional."
    • changedInput schema / properties / client_token / description
      Previous value: -"Target client connection token, required with management access (including stdio and no-password mode). Device-scoped bearer access implicitly selects its own token."New value: +"Control credential in token:key format, required with management access (including stdio and no-password mode). Scoped control bearer access implicitly selects its own token."
    • changedOutput schema / properties / exit_code / description
      Previous value: -"Exit code of the latest completed command, or terminal termination if it ended; 0 is success, -1 denotes execution/connection failure. Absent while a command is running."New value: +"execute/read/list: the latest completed command exit code, preserved when its shell later ends. stop: the confirmed shell termination code. 0 means success; -1 denotes execution failure. Transport errors never invent a code."
    • changedOutput schema / properties / has_more / description
      Previous value: -"Whether more retained output remains after next_cursor. May be true even when done=true; continue reading to drain output."New value: +"Whether retained output remains after next_cursor; continue reading even after idle or closed."
    • changedOutput schema / properties / next_cursor / description
      Previous value: -"Byte offset immediately after the returned output. Pass it as cursor for the next session_read, including when done=true and has_more=true."New value: +"Byte offset immediately after the returned output. Pass it as cursor for the next session_read. Continue while has_more=true, including after status becomes idle or closed."
    • changedOutput schema / properties / session_id / description
      Previous value: -"Session identifier used by session_read and session_control."New value: +"Client-local session identifier. Multi-device read/control also require client_id."
    • changedOutput schema / properties / status / description
      Previous value: -"running: terminal busy or stop pending; idle: command ended and reusable; closed: session is no longer usable. A disconnection error means remote process termination is unconfirmed."New value: +"running: terminal busy or stop pending; idle: command ended and shell reusable; closed: client confirmed shell termination. Transport errors do not imply termination."
    • changedOutput schema / required
      Previous value: -[
      -  "session_id",
      -  "command_id",
      -  "status",
      -  "output",
      -  "next_cursor",
      -  "has_more"
      -]New value: +[
      +  "command_id",
      +  "status",
      +  "output",
      +  "next_cursor",
      +  "has_more"
      +]
  5. Changed23 schema fields changed
    • addedInput schema / not
      Added value: +{
      +  "required": [
      +    "session_id",
      +    "setup"
      +  ]
      +}
    • changedInput schema / properties / client_id / description
      Previous value: -"Six lowercase letters or digits from list_clients. Required for multi-device tokens, even when only one device is online; optional for single-device tokens."New value: +"Six lowercase letters or digits from list_clients, used to select or filter devices. For multi-device tokens it is required when a specific device must be selected and no existing session_id identifies it. Session-list filtering is optional."
    • removedInput schema / properties / cwd
      Removed value: -{
      -  "description": "Working directory for this process on the target device.",
      -  "type": "string"
      -}
    • removedInput schema / properties / env
      Removed value: -{
      -  "additionalProperties": {
      -    "type": "string"
      -  },
      -  "description": "Environment overrides for this command, merged with the client environment. Values must be strings.",
      -  "type": "object"
      -}
    • addedInput schema / properties / session_id
      Added value: +{
      +  "description": "Reuse an existing session only. Unknown or closed IDs are rejected. To create a terminal, use setup instead.",
      +  "maxLength": 64,
      +  "minLength": 1,
      +  "type": "string"
      +}
    • addedInput schema / properties / setup
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Create a new terminal using optional cwd, env and session_id. Cannot be combined with top-level session_id. An existing setup.session_id is rejected. Omit its ID for a generated anonymous terminal with the usual wait-based lifetime.",
      +  "properties": {
      +    "cwd": {
      +      "description": "Initial working directory for the terminal created by setup. Change a reused shell with cd.",
      +      "type": "string"
      +    },
      +    "env": {
      +      "additionalProperties": {
      +        "type": "string"
      +      },
      +      "description": "Initial environment overrides for setup, merged with client environment. Change a reused shell through shell commands.",
      +      "type": "object"
      +    },
      +    "session_id": {
      +      "description": "Optional ID for a new persistent terminal; fails if already present. Omit to generate a random ID and follow anonymous terminal lifetime.",
      +      "maxLength": 64,
      +      "minLength": 1,
      +      "type": "string"
      +    }
      +  },
      +  "type": [
      +    "null",
      +    "object"
      +  ]
      +}
    • removedInput schema / properties / timeout_ms
      Removed value: -{
      -  "default": 60000,
      -  "description": "Remote process execution timeout in milliseconds. 0 disables only the process timeout. This does not extend the MCP caller's or a proxy's request timeout; use session_start and session_read for long-running commands.",
      -  "maximum": 86400000,
      -  "minimum": 0,
      -  "type": "integer"
      -}
    • addedInput schema / properties / wait_ms
      Added value: +{
      +  "default": 10000,
      +  "description": "Completion wait in milliseconds, 0–20000; default 10000. Anonymous terminals close if the command finishes first; otherwise the client retains the same shell under a random session_id. 0 retains immediately. Never stops a running command.",
      +  "maximum": 20000,
      +  "minimum": 0,
      +  "type": [
      +    "null",
      +    "integer"
      +  ]
      +}
    • removedOutput schema / properties / canceled
      Removed value: -{
      -  "description": "True only when the target reported cancellation; a disconnect alone does not confirm cancellation.",
      -  "type": "boolean"
      -}
    • addedOutput schema / properties / command_id
      Added value: +{
      +  "description": "Identity of the latest submitted command.",
      +  "type": "string"
      +}
    • changedOutput schema / properties / exit_code / description
      Previous value: -"Reported process exit code: 0 means success; -1 means execution failed, was interrupted, or the device disconnected before a normal exit report."New value: +"Exit code of the latest completed command, or terminal termination if it ended; 0 is success, -1 denotes execution/connection failure. Absent while a command is running."
    • changedOutput schema / properties / exit_code / type
      Previous value: -"integer"New value: +[
      +  "null",
      +  "integer"
      +]
    • addedOutput schema / properties / has_more
      Added value: +{
      +  "description": "Whether more retained output remains after next_cursor. May be true even when done=true; continue reading to drain output.",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / next_cursor
      Added value: +{
      +  "description": "Byte offset immediately after the returned output. Pass it as cursor for the next session_read, including when done=true and has_more=true.",
      +  "type": "integer"
      +}
    • addedOutput schema / properties / output
      Added value: +{
      +  "description": "Combined terminal output from the requested cursor; may contain echoed input.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / session_id
      Added value: +{
      +  "description": "Session identifier used by session_read and session_control.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / status
      Added value: +{
      +  "description": "running: terminal busy or stop pending; idle: command ended and reusable; closed: session is no longer usable. A disconnection error means remote process termination is unconfirmed.",
      +  "enum": [
      +    "running",
      +    "idle",
      +    "closed"
      +  ],
      +  "type": "string"
      +}
    • removedOutput schema / properties / stderr
      Removed value: -{
      -  "description": "Captured standard error, sharing a 1 MiB combined limit with stdout.",
      -  "type": "string"
      -}
    • removedOutput schema / properties / stdout
      Removed value: -{
      -  "description": "Captured standard output, sharing a 1 MiB combined limit with stderr.",
      -  "type": "string"
      -}
    • removedOutput schema / properties / timed_out
      Removed value: -{
      -  "description": "True if the target reported that the process execution timeout elapsed.",
      -  "type": "boolean"
      -}
    • changedOutput schema / properties / truncated / description
      Previous value: -"True if output exceeded the 1 MiB retention limit. Commands discard excess captured output; sessions discard older buffered bytes."New value: +"Present only as true when the requested cursor predates the oldest retained output. The latest 1 MiB is retained; pagination alone does not truncate."
    • addedOutput schema / properties / truncated / enum
      Added value: +[
      +  true
      +]
    • changedOutput schema / required
      Previous value: -[
      -  "stdout",
      -  "stderr",
      -  "exit_code",
      -  "timed_out",
      -  "canceled",
      -  "truncated"
      -]New value: +[
      +  "session_id",
      +  "command_id",
      +  "status",
      +  "output",
      +  "next_cursor",
      +  "has_more"
      +]
  6. Changed1 schema field changed
    • changedInput schema / properties / timeout_ms / description
      Previous value: -"Process execution timeout in milliseconds. 0 disables the timeout."New value: +"Remote process execution timeout in milliseconds. 0 disables only the process timeout. This does not extend the MCP caller's or a proxy's request timeout; use session_start and session_read for long-running commands."
  7. Changed11 schema fields changed
    • changedInput schema / properties / client_token / description
      Previous value: -"Target client connection token (required when authenticated with the management key)"New value: +"Target client connection token, required with management access (including stdio and no-password mode). Device-scoped bearer access implicitly selects its own token."
    • changedInput schema / properties / command / description
      Previous value: -"Shell command"New value: +"Shell command to execute on the target device."
    • changedInput schema / properties / cwd / description
      Previous value: -"Working directory on the target device. Each command starts a fresh shell; use cwd for subsequent commands instead of relying on a previous cd."New value: +"Working directory for this process on the target device."
    • changedInput schema / properties / timeout_ms / description
      Previous value: -"Execution timeout in milliseconds, up to 86400000 (24 hours). 0 disables the timeout. Default: 60000 for execute_command, 0 for session_start."New value: +"Process execution timeout in milliseconds. 0 disables the timeout."
    • addedOutput schema / properties / canceled / description
      Added value: +"True only when the target reported cancellation; a disconnect alone does not confirm cancellation."
    • addedOutput schema / properties / error / description
      Added value: +"Optional execution or connection error. A disconnect does not prove the remote process completed successfully."
    • addedOutput schema / properties / exit_code / description
      Added value: +"Reported process exit code: 0 means success; -1 means execution failed, was interrupted, or the device disconnected before a normal exit report."
    • addedOutput schema / properties / stderr / description
      Added value: +"Captured standard error, sharing a 1 MiB combined limit with stdout."
    • addedOutput schema / properties / stdout / description
      Added value: +"Captured standard output, sharing a 1 MiB combined limit with stderr."
    • addedOutput schema / properties / timed_out / description
      Added value: +"True if the target reported that the process execution timeout elapsed."
    • addedOutput schema / properties / truncated / description
      Added value: +"True if output exceeded the 1 MiB retention limit. Commands discard excess captured output; sessions discard older buffered bytes."
  8. First observed

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and openWorldHint=true, but the description adds non-obvious lifecycle behavior: anonymous terminals close on early completion, stay open if the wait expires, and commands may keep running past the wait. That is genuine information an agent could not infer from the annotations or schema. It stops short of discussing credential/control-token requirements or side-effect risk, which would have pushed it higher.

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?

Five short sentences, front-loaded with the action, then the mode selection, then the lifetime caveat, then the follow-up tool. No filler, and the continuation caveat sits right after the wait-expiry rule it explains.

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

Completeness4/5

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

With an output schema present, return values need not be described; the remaining burden is invocation modes, terminal lifetime, and follow-up, all covered. Minor gaps: client_id for multi-device routing and control_token requirements are only in the schema, and the description never warns that execution is destructive.

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 100%, and the schema already explains the mutual exclusion of setup and session_id, the wait_ms semantics, and cwd/env behavior in detail. The description reinforces the setup-versus-session_id distinction but adds no syntax, format, or constraint details beyond the schema. Baseline 3 applies when the schema does the heavy lifting.

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?

States a specific verb and resource ('Run a command on a device') and immediately separates the three invocation modes (create via setup, reuse via session_id, anonymous by omitting both). It also names session_read as the tool for retrieving further output, so an agent can place it against the sibling catalog without opening a 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?

Gives explicit selection rules: use setup to create a terminal, session_id to reuse one, omit both for an anonymous terminal, and use session_read for more output. It also includes a termination instruction ('stop task-owned terminals when finished') that tells the agent what follow-up action is expected.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources