MCPconceptTools

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

tool MCPlatest

capture_pane

tool [source]

Read a pane’s contents. Reads the visible screen by default; set history to reach output that has scrolled off, or give a start and end line. Set last_command to get only what the last command printed, which is usually what you want and is far shorter — it needs tmux 3.7 and a shell that marks its prompts, and says so when it cannot. Read pane output; accepts no client-supplied executable input. Returned content may be sensitive or untrusted.

MCP request method
tools/call Send capture_pane as the tool name, with the arguments below.

Arguments#

  • end? (integer | null) #

    End at this line. Omit for the bottom of the screen.

    format
    "int32"
  • history? = false (boolean) #

    Read the whole history rather than the visible screen.

  • last_command? = false (boolean) #

    Return only the last command’s output, when the shell marks its prompts.

    Answers far less than the history, because it starts where the last command’s output began. When the pane’s shell does not mark its prompts — fish does, bash and zsh do not — this reports marks: "absent" and returns the visible screen instead.

  • pane (string) #

    The %-prefixed pane id.

  • start? (integer | null) #

    Start at this line. Zero is the top of the screen, negative is scrollback. Omit for the top of the screen, or of the scrollback with history.

    format
    "int32"

No other arguments are accepted.

Result#

Returns object

  • lines (integer) #

    How many lines that is.

    minimum
    0
  • marks (Marks) #

    Whether the text is one command’s output, and why it is not.

  • pane (string) #

    The pane that was read.

  • text (string) #

    The text, with lines separated by newlines.

Types#

Marks: "present" | "absent" | "unsupported" | "not_asked"

type

Whether tmux knew where the last command’s output began.

Reported rather than inferred: an answer that fell back to the whole screen looks exactly like a command that printed a great deal.

Matches exactly one variant.

  • Variant 1 ("present") #

    The prompt marks were there, so the text is one command’s output.

  • Variant 2 ("absent") #

    tmux has the marks but this pane has none, because its shell does not emit OSC 133. fish does; bash and zsh need shell integration. The visible screen came back instead — not the history, which would answer a request for one command with everything the pane ever wrote.

  • Variant 3 ("unsupported") #

    This tmux predates capture-pane -F, which arrived in 3.7. The visible screen came back instead.

  • Variant 4 ("not_asked") #

    The caller did not ask for the last command, so nothing was looked up.

Annotations#

destructiveHint
false
idempotentHint
true
openWorldHint
true
readOnlyHint
true
title
"Read Pane Contents"

Protocol data#

Use the complete advertised contract for validation and client integration.

Input schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"end": {
"description": "End at this line. Omit for the bottom of the screen.",
"format": "int32",
"type": [
"integer",
"null"
]
},
"history": {
"default": false,
"description": "Read the whole history rather than the visible screen.",
"type": "boolean"
},
"last_command": {
"default": false,
"description": "Return only the last command's output, when the shell marks its\nprompts.\n\nAnswers far less than the history, because it starts where the last\ncommand's output began. When the pane's shell does not mark its\nprompts -- fish does, bash and zsh do not -- this reports\n`marks: \"absent\"` and returns the visible screen instead.",
"type": "boolean"
},
"pane": {
"description": "The `%`-prefixed pane id.",
"type": "string"
},
"start": {
"description": "Start at this line. Zero is the top of the screen, negative is\nscrollback. Omit for the top of the screen, or of the scrollback with\n`history`.",
"format": "int32",
"type": [
"integer",
"null"
]
}
},
"required": [
"pane"
],
"type": "object"
}
Output schema
{
"$defs": {
"Marks": {
"description": "Whether tmux knew where the last command's output began.\n\nReported rather than inferred: an answer that fell back to the whole\nscreen looks exactly like a command that printed a great deal.",
"oneOf": [
{
"const": "present",
"description": "The prompt marks were there, so the text is one command's output.",
"type": "string"
},
{
"const": "absent",
"description": "tmux has the marks but this pane has none, because its shell does not\nemit OSC 133. fish does; bash and zsh need shell integration. The\nvisible screen came back instead -- not the history, which would\nanswer a request for one command with everything the pane ever wrote.",
"type": "string"
},
{
"const": "unsupported",
"description": "This tmux predates `capture-pane -F`, which arrived in 3.7. The\nvisible screen came back instead.",
"type": "string"
},
{
"const": "not_asked",
"description": "The caller did not ask for the last command, so nothing was looked up.",
"type": "string"
}
]
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"lines": {
"description": "How many lines that is.",
"minimum": 0,
"type": "integer"
},
"marks": {
"$ref": "#/$defs/Marks",
"description": "Whether the text is one command's output, and why it is not."
},
"pane": {
"description": "The pane that was read.",
"type": "string"
},
"text": {
"description": "The text, with lines separated by newlines.",
"type": "string"
}
},
"required": [
"pane",
"text",
"lines",
"marks"
],
"type": "object"
}
Esc

Type to search.

Reference previewOpen reference