Run command

run_command

run_command
mutating tool
mutating tool
run_command

Run a shell command in a pane, wait for completion, and capture output.

Returns:

RunCommandResult

Use when you need to run a shell command in a pane and get a RunCommandResult with exit status, timeout state, and captured pane output.

Avoid when you need raw interactive key driving — use send_keys or send_keys_batch for TUIs, key names, and partial commands.

Side effects: Sends a command to the pane’s interactive shell. The command may read or write files, start processes, or access the network depending on what the shell command does. Each command runs in a subshell, so directory or environment changes do not persist across calls.

For MCP calls, lightweight suppression is enabled by default. The configuration setting LIBTMUX_SUPPRESS_HISTORY controls only omitted MCP suppress_history arguments, and an explicit suppress_history value wins. Direct Python calls default to False. suppress_history=false permits intentional multiline input.

Suppression is best effort: run_command prefixes one space to the grouped event that carries your single-line command, but the existing shell must be configured to ignore space-prefixed commands. When suppression is effective, a command containing a carriage return or line feed is rejected before tmux receives input because one prefix cannot protect multiple shell events. This control does not change the shell’s environment or startup configuration, clear its memory or pane scrollback, or hide the command from other observers. See History suppression for shell behavior and Safety tiers before handling credentials.

Example:

{
  "tool": "run_command",
  "arguments": {
    "command": "pytest -q",
    "pane_id": "%2",
    "timeout": 60
  }
}

Response (RunCommandResult):

{
  "pane_id": "%2",
  "exit_status": 0,
  "timed_out": false,
  "elapsed_seconds": 4.2,
  "output": ["..."],
  "output_truncated": false,
  "output_truncated_lines": 0
}

Note

The generated parameter table below reflects the direct Python signature, so it shows suppress_history=False. MCP tools/list advertises the effective suppression default instead: true unless LIBTMUX_SUPPRESS_HISTORY is 0. An MCP call that omits the argument uses that advertised default.

Parameters

Parameter

Type

Required

Default

Description

command

str

yes

Shell command to run in the target pane.

pane_id

str

no

Pane ID (e.g. ‘%1’).

session_name

str

no

Session name for pane resolution.

session_id

str

no

Session ID (e.g. ‘$1’) for pane resolution.

window_id

str

no

Window ID for pane resolution.

timeout

float

no

30.0

Maximum seconds to wait for command completion. Capped by the same server wait ceiling as wait_for_text; an over-large value is not an error — the wait returns at the ceiling and the timeout actually enforced is reported on RunCommandResult.effective_timeout.

max_lines

int

no

Maximum pane output lines to return. Defaults to all captured visible output; pass a small value for a tail-only summary.

suppress_history

bool

no

False

For MCP calls, omission uses the server’s LIBTMUX_SUPPRESS_HISTORY default; an explicit value overrides it. Direct Python calls default to False. Best effort: the shell must honor space-prefixed history suppression. Suppression requires a single-line command; multiline commands remain available when suppression is false.

socket_name

str

no

tmux socket name.