tmux_capture_pane
Capture visible text from tmux terminal panes for automation and debugging. Specify session, pane, and lines to extract displayed content or scrollback history.
Instructions
Capture the visible content of a tmux pane. Returns the text currently displayed in the pane.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_name | Yes | Name of the tmux session | |
| pane_index | No | Pane index (default: 0 for main pane) | |
| lines | No | Number of lines to capture from scrollback (default: captures visible area, use -1 for entire scrollback) |
Implementation Reference
- src/index.js:333-360 (handler)The handler function that implements the tmux_capture_pane tool by executing the `tmux capture-pane` command with optional parameters for pane index and number of lines.async capturePane(args) { const { session_name, pane_index = "0", lines } = args; try { let cmd = `tmux capture-pane -t "${session_name}:${pane_index}" -p`; if (lines !== undefined) { if (lines === -1) { cmd += " -S -"; // Capture entire scrollback } else { cmd += ` -S -${lines}`; } } const { stdout } = await execAsync(cmd); return { content: [ { type: "text", text: stdout, }, ], }; } catch (error) { throw new Error(`Failed to capture pane: ${error.message}`); } }
- src/index.js:90-113 (schema)The input schema and metadata definition for the tmux_capture_pane tool, registered in the list of tools.{ name: "tmux_capture_pane", description: "Capture the visible content of a tmux pane. Returns the text currently displayed in the pane.", inputSchema: { type: "object", properties: { session_name: { type: "string", description: "Name of the tmux session", }, pane_index: { type: "string", description: "Pane index (default: 0 for main pane)", }, lines: { type: "number", description: "Number of lines to capture from scrollback (default: captures visible area, use -1 for entire scrollback)", }, }, required: ["session_name"], }, },
- src/index.js:197-198 (registration)The switch case that registers and dispatches to the tmux_capture_pane handler in the CallToolRequestSchema handler.case "tmux_capture_pane": return await this.capturePane(args);