Skip to main content
Glama

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
NameRequiredDescriptionDefault
session_nameYesName of the tmux session
pane_indexNoPane index (default: 0 for main pane)
linesNoNumber of lines to capture from scrollback (default: captures visible area, use -1 for entire scrollback)

Implementation Reference

  • 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}`);
      }
    }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MediocreTriumph/tmux-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server