# run_command

Source: https://libtmux.org/en/py/stable/mcp/tools/run_command/

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

tool MCPstable

MCP is in development

Server behavior and tool contracts may change. Tool availability depends on the server configuration.

* **run_command**( [command](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fcommand): [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"), [max_lines](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fmax_lines)?: [integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [pane_id](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fpane_id)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [session_id](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsession_id)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [session_name](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsession_name)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [socket_name](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsocket_name)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [suppress_history](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsuppress_history)?: [boolean](https://json-schema.org/understanding-json-schema/reference/boolean "boolean (JSON Schema)"), [timeout](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Ftimeout)?: [number](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"), [window_id](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fwindow_id)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), )

  tool \[[source](https://github.com/tmux-python/libtmux-mcp/blob/4daddc0dfca96c43bf521d818bf91564e1434760/src/libtmux_mcp/tools/pane_tools/__init__.py#L96)][¶](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command)

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

  Use for the common terminal workflow: run this command, wait until it completes, then report whether it succeeded. The command is sent to the pane’s interactive shell, followed by a private [`tmux wait-for`](https://libtmux.org/en/tmux/latest/manual/wait-for/) signal and a private pane option carrying the shell exit status. This is the AUTHORED-output path — the command you pass is what the wait synchronizes on. Reserve [`wait_for_text`](https://libtmux.org/en/py/stable/mcp/tools/wait_for_text/) for output you did not author: another process, a human, or a background job.

  The command runs in a subshell, so `cd`, `export` and other shell state changes do not persist to later calls.

  * MCP request method

    `tools/call` Send `run_command` as the tool name, with the arguments below.

  ## Arguments[#](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.parameters)

  * **[`command`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fcommand)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Shell command to run in the target pane.

  * **[`max_lines`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fmax_lines)**? = `null` ([integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

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

  * **[`pane_id`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fpane_id)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

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

  * **[`session_id`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsession_id)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

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

  * **[`session_name`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsession_name)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

    Session name for pane resolution.

  * **[`socket_name`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsocket_name)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

    tmux socket name.

  * **[`suppress_history`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fsuppress_history)**? = `true` ([boolean](https://json-schema.org/understanding-json-schema/reference/boolean "boolean (JSON Schema)"))

    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.

  * **[`timeout`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Ftimeout)**? = `30` ([number](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"))

    Maximum seconds to wait for command completion. Capped by the same server wait ceiling as [`wait_for_text`](https://libtmux.org/en/py/stable/mcp/tools/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`.

  * **[`window_id`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.input%2Fproperties%2Fwindow_id)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

    Window ID for pane resolution.

  No other arguments are accepted.

  ## Result[#](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.result)

  Returns [object](https://json-schema.org/understanding-json-schema/reference/object "object (JSON Schema)")

  * **[`effective_timeout`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Feffective_timeout)** ([number](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"))

    Seconds actually enforced for command completion. Server policy caps the requested `timeout`; compare against what you passed to see a clamp.

  * **[`elapsed_seconds`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Felapsed_seconds)** ([number](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"))

    Time spent waiting in seconds

  * **[`exit_status`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Fexit_status)**? = `null` ([integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

    Shell exit status, or None when the command timed out

  * **[`output`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Foutput)**? ([Array](https://json-schema.org/understanding-json-schema/reference/array "array (JSON Schema)")<[string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)")>)

    Tail-preserved pane output after the wait completes

  * **[`output_truncated`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Foutput_truncated)**? = `false` ([boolean](https://json-schema.org/understanding-json-schema/reference/boolean "boolean (JSON Schema)"))

    True when output was tail-preserved to stay within max_lines

  * **[`output_truncated_lines`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Foutput_truncated_lines)**? = `0` ([integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"))

    Number of pane lines dropped from the head when truncating

  * **[`pane_id`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Fpane_id)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Pane ID that received the command

  * **[`timed_out`](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.output%2Fproperties%2Ftimed_out)** ([boolean](https://json-schema.org/understanding-json-schema/reference/boolean "boolean (JSON Schema)"))

    True when the wait timed out

  ## Annotations[#](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.annotations)

  * [`destructiveHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#destructiveHint)

    `true`

  * [`idempotentHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#idempotentHint)

    `false`

  * [`openWorldHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#openWorldHint)

    `true`

  * [`readOnlyHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#readOnlyHint)

    `false`

  ## Protocol data[#](https://libtmux.org/en/py/stable/mcp/tools/run_command/#mcp.tool.run_command.schemas)

  Use the complete advertised contract for validation and client integration.

  Input schema

  ```json
  {
    "additionalProperties": false,
    "properties": {
      "command": {
        "description": "Shell command to run in the target pane.",
        "type": "string"
      },
      "max_lines": {
        "anyOf": [
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Maximum pane output lines to return. Defaults to all captured\nvisible output; pass a small value for a tail-only summary."
      },
      "pane_id": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Pane ID (e.g. '%1')."
      },
      "session_id": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Session ID (e.g. '$1') for pane resolution."
      },
      "session_name": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Session name for pane resolution."
      },
      "socket_name": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "tmux socket name."
      },
      "suppress_history": {
        "default": true,
        "description": "For MCP calls, omission uses the server's LIBTMUX_SUPPRESS_HISTORY\ndefault; an explicit value overrides it. Direct Python calls default\nto False. Best effort: the shell must honor space-prefixed history\nsuppression. Suppression requires a single-line command; multiline\ncommands remain available when suppression is false.",
        "type": "boolean"
      },
      "timeout": {
        "default": 30,
        "description": "Maximum seconds to wait for command completion. Capped by the\nsame server wait ceiling as ``wait_for_text``; an over-large\nvalue is not an error — the wait returns at the ceiling and\nthe timeout actually enforced is reported on\n``RunCommandResult.effective_timeout``.",
        "type": "number"
      },
      "window_id": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Window ID for pane resolution."
      }
    },
    "required": [
      "command"
    ],
    "type": "object"
  }
  ```

  Output schema

  ```json
  {
    "description": "Result of running a shell command in a pane.",
    "properties": {
      "effective_timeout": {
        "description": "Seconds actually enforced for command completion. Server policy caps the requested ``timeout``; compare against what you passed to see a clamp.",
        "type": "number"
      },
      "elapsed_seconds": {
        "description": "Time spent waiting in seconds",
        "type": "number"
      },
      "exit_status": {
        "anyOf": [
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Shell exit status, or None when the command timed out"
      },
      "output": {
        "description": "Tail-preserved pane output after the wait completes",
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "output_truncated": {
        "default": false,
        "description": "True when output was tail-preserved to stay within max_lines",
        "type": "boolean"
      },
      "output_truncated_lines": {
        "default": 0,
        "description": "Number of pane lines dropped from the head when truncating",
        "type": "integer"
      },
      "pane_id": {
        "description": "Pane ID that received the command",
        "type": "string"
      },
      "timed_out": {
        "description": "True when the wait timed out",
        "type": "boolean"
      }
    },
    "required": [
      "pane_id",
      "timed_out",
      "elapsed_seconds",
      "effective_timeout"
    ],
    "type": "object"
  }
  ```
