Skip to main content
Glama

Run command

run_command
Destructive

Run a shell command (/bin/sh -c) in the sandbox as root and wait for it to finish; returns exit_code, stdout, stderr and duration. Without sandbox_id it runs in the current sandbox (one is created if there is none); a sandbox_id you pass becomes the current sandbox. Use it for installs, quick checks and anything that finishes within a few minutes; a non-zero exit code is a normal result to react to, not a tool error. Multi-line programs are simpler to run as code with an interpreter, and long or parallel work belongs in a background job, which keeps running without this connection. To keep a server running, start it in the background (nohup … &).

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

Input Schema

NameRequiredDescriptionDefault
cwdNoWorking directory
envNoEnvironment variables
commandYesCommand, e.g. 'pip install pandas && python3 script.py'
timeout_sNoTime limit in seconds (default 120, max 3600)
sandbox_idNoSandbox ID (sb_…). If omitted, the current sandbox of this session is used. A sandbox_id you pass becomes the current sandbox for later calls without sandbox_id.

Output Schema

NameRequiredDescriptionDefault
stderrYesStandard error output.
stdoutYesStandard output (very long output is shortened in the middle).
exit_codeYesExit code of the command (non-zero is a normal result, not a tool error).
shortenedYesstdout or stderr was shortened in the middle for this reply (a marker shows how many characters are missing).
timed_outYesThe time limit was exceeded and the process was killed.
truncatedYesstdout or stderr is incomplete (either of the two reasons below) – redirect large output to a file and read the part you need.
sandbox_idYesSandbox ID.
duration_msYesHow long the command ran, in milliseconds.
output_limit_hitYesThe command produced more than 1 MB of output and the rest was cut off in the sandbox.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / sandbox_id / description
      Previous value: -"Sandbox ID (sb_…). If omitted, the current sandbox of this session is used."New value: +"Sandbox ID (sb_…). If omitted, the current sandbox of this session is used. A sandbox_id you pass becomes the current sandbox for later calls without sandbox_id."
  2. Changed4 schema fields changed
    • addedOutput schema / properties / output_limit_hit
      Added value: +{
      +  "description": "The command produced more than 1 MB of output and the rest was cut off in the sandbox.",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / shortened
      Added value: +{
      +  "description": "stdout or stderr was shortened in the middle for this reply (a marker shows how many characters are missing).",
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / truncated / description
      Previous value: -"The output exceeded 1 MB and was cut."New value: +"stdout or stderr is incomplete (either of the two reasons below) – redirect large output to a file and read the part you need."
    • changedOutput schema / required
      Previous value: -[
      -  "sandbox_id",
      -  "exit_code",
      -  "stdout",
      -  "stderr",
      -  "duration_ms",
      -  "timed_out",
      -  "truncated"
      -]New value: +[
      +  "sandbox_id",
      +  "exit_code",
      +  "stdout",
      +  "stderr",
      +  "duration_ms",
      +  "timed_out",
      +  "truncated",
      +  "output_limit_hit",
      +  "shortened"
      +]
  3. 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, so the safety profile is covered; the description adds meaningful context beyond them, notably that execution is as root, that the call blocks until completion, and that passing sandbox_id silently rebinds the session's current sandbox for later calls. It does not warn that root-level mutations can destroy sandbox state or files, which is the one behavioral gap.

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 purpose and return values, then sandbox semantics, then usage boundaries, with no filler. The first sentence partly restates return fields that the output schema already provides, and the trailing nohup tip is useful but slightly tacked on.

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 five-parameter execution tool with annotations and an output schema, everything an agent needs to invoke it correctly is present: blocking semantics, timeout expectations, sandbox selection side effects, and error interpretation.

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 coverage is 100%, so the schema already documents cwd, env, timeout_s, and the sandbox_id stickiness. The description reinforces the sandbox_id fallback/creation semantics and gives a rough time budget ('a few minutes') but adds no meaning the schema lacks. Baseline 3 applies when the schema carries the load.

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 plus execution mechanism (/bin/sh -c), privilege level (root), blocking behavior (wait for it to finish), and return fields. An agent can distinguish this from run_code and run_job based on the description alone.

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?

Explicitly scopes use to installs, quick checks, and work finishing within a few minutes, then names the conditions that select alternatives: multi-line programs go to the interpreter (run_code) and long or parallel work goes to a background job. It also frames non-zero exit codes as normal results rather than failures, which prevents misuse.

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