Run command¶
run_command¶
Run a shell command in a pane, wait for completion, and capture output.
- Returns:
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 |
|---|---|---|---|---|
|
yes |
— |
Shell command to run in the target pane. |
|
|
no |
— |
Pane ID (e.g. ‘%1’). |
|
|
no |
— |
Session name for pane resolution. |
|
|
no |
— |
Session ID (e.g. ‘$1’) for pane resolution. |
|
|
no |
— |
Window ID for pane resolution. |
|
|
no |
|
Maximum seconds to wait for command completion. Capped by the same server wait ceiling as |
|
|
no |
— |
Maximum pane output lines to return. Defaults to all captured visible output; pass a small value for a tail-only summary. |
|
|
no |
|
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. |
|
|
no |
— |
tmux socket name. |