# wait_for_exit

Source: https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/

> Inspect tmux metadata; accepts no client-supplied executable input. Wait until the program in a pane exits and return its exit status or signal. Use it for a pane you did not start, such as a person's build or a server someone launched; for run_program and start_program, their own results report the exit. A pane that closes on exit still reports its status; a pane killed from outside during the wait has none and answers gone within about two seconds, and a pane id that is already gone is not found. A pane at a shell prompt exits only when the shell does: for a command typed into it, use run_shell_command or wait_for_text. Requires tmux 3.8 or newer.

tool MCPlatest

MCP concept example

A working example of the core library. It can change without notice.

[What concept means](https://libtmux.org/en/meta/support/#concept-and-alpha)

* **wait_for_exit**( [paneId](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.input%2Fproperties%2FpaneId): [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"), [timeoutMs](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.input%2Fproperties%2FtimeoutMs)?: [integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"), )

  tool \[[source](https://github.com/libtmux/libtmux-ts/blob/f7b03a361f7c97677406b4ab937b2772ddb5f7dd/packages/mcp/src/tools/wait.ts#L618)][¶](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit)

  Inspect tmux metadata; accepts no client-supplied executable input. Wait until the program in a pane exits and return its exit status or signal. Use it for a pane you did not start, such as a person’s build or a server someone launched; for [run_program](https://libtmux.org/en/ts/latest/mcp/tools/run_program/) and [start_program](https://libtmux.org/en/ts/latest/mcp/tools/start_program/), their own results report the exit. A pane that closes on exit still reports its status; a pane killed from outside during the wait has none and answers gone within about two seconds, and a pane id that is already gone is not found. A pane at a shell prompt exits only when the shell does: for a command typed into it, use [run_shell_command](https://libtmux.org/en/ts/latest/mcp/tools/run_shell_command/) or [wait_for_text](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_text/). Requires tmux 3.8 or newer.

  * MCP request method

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

  ## Arguments[#](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.parameters)

  * **[`paneId`](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.input%2Fproperties%2FpaneId)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Stable pane id, e.g. %1.

    * pattern

      `"^%\\d+$"`

  * **[`timeoutMs`](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.input%2Fproperties%2FtimeoutMs)**? ([integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"))

    How long to wait for the exit: 30 seconds when omitted, clamped by the server ceiling; the result reports what was used, and timed_out leaves the program running.

    * maximum

      `9007199254740991`

    * exclusiveMinimum

      `0`

  ## Result[#](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.result)

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

  * **[`effectiveTimeoutMs`](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.output%2Fproperties%2FeffectiveTimeoutMs)** ([integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"))

    The timeout enforced.

    * minimum

      `-9007199254740991`

    * maximum

      `9007199254740991`

  * **[`exitStatus`](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.output%2Fproperties%2FexitStatus)** ([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)"))

    The exit status, as tmux read it from the pane’s process: null when a signal ended it, with signal set, or when it has not exited.

    Matches one or more variants.

    * **[Variant 1](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.output%2Fproperties%2FexitStatus%2FanyOf%2F0)** ([integer](https://json-schema.org/understanding-json-schema/reference/numeric "numeric (JSON Schema)"))

      * minimum

        `-9007199254740991`

      * maximum

        `9007199254740991`

  * **[`outcome`](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.output%2Fproperties%2Foutcome)** ("completed" | "timed_out" | "gone" | "cancelled")

    completed: the program ended; exitStatus holds its status, or is null with signal set. timed_out: it still runs; call again to keep waiting. gone: the pane was removed without an exit status. cancelled: the request was cancelled.

  * **[`signal`](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.output%2Fproperties%2Fsignal)** ([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)"))

    The signal that ended the program, such as “SIGTERM”; otherwise null.

  No other properties are accepted.

  ## Annotations[#](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.annotations)

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

    `true`

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

    `false`

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

    `true`

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

    `false`

  ## Protocol data[#](https://libtmux.org/en/ts/latest/mcp/tools/wait_for_exit/#mcp.tool.wait_for_exit.schemas)

  Use the complete advertised contract for validation and client integration.

  Input schema

  ```json
  {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "properties": {
      "paneId": {
        "description": "Stable pane id, e.g. %1.",
        "pattern": "^%\\d+$",
        "type": "string"
      },
      "timeoutMs": {
        "description": "How long to wait for the exit: 30 seconds when omitted, clamped by the server ceiling; the result reports what was used, and timed_out leaves the program running.",
        "exclusiveMinimum": 0,
        "maximum": 9007199254740991,
        "type": "integer"
      }
    },
    "required": [
      "paneId"
    ],
    "type": "object"
  }
  ```

  Output schema

  ```json
  {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "additionalProperties": false,
    "properties": {
      "effectiveTimeoutMs": {
        "description": "The timeout enforced.",
        "maximum": 9007199254740991,
        "minimum": -9007199254740991,
        "type": "integer"
      },
      "exitStatus": {
        "anyOf": [
          {
            "maximum": 9007199254740991,
            "minimum": -9007199254740991,
            "type": "integer"
          },
          {
            "type": "null"
          }
        ],
        "description": "The exit status, as tmux read it from the pane's process: null when a signal ended it, with signal set, or when it has not exited."
      },
      "outcome": {
        "description": "completed: the program ended; exitStatus holds its status, or is null with signal set. timed_out: it still runs; call again to keep waiting. gone: the pane was removed without an exit status. cancelled: the request was cancelled.",
        "enum": [
          "completed",
          "timed_out",
          "gone",
          "cancelled"
        ],
        "type": "string"
      },
      "signal": {
        "description": "The signal that ended the program, such as \"SIGTERM\"; otherwise null.",
        "type": [
          "string",
          "null"
        ]
      }
    },
    "required": [
      "effectiveTimeoutMs",
      "exitStatus",
      "outcome",
      "signal"
    ],
    "type": "object"
  }
  ```
