Skip to main content
Glama

Capture tmux Pane Content

tmux_capture_pane
Read-onlyIdempotent

Capture visible content or history from a tmux pane to read command output or check pane state. Specify session, window, pane, and line range for precise extraction.

Instructions

Capture the visible content or history of a tmux pane.

Args:

  • session (string, required): Name of the session

  • window (string or number, optional): Window index or name

  • pane (number, optional): Pane index

  • start_line (number, optional): Start line (negative = history, 0 = top of visible)

  • end_line (number, optional): End line (use - for bottom of visible pane)

  • escape_sequences (boolean, optional): Include escape sequences (default: false)

This tool is useful for reading command output or checking the state of a pane.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionYesName of the session
windowNoWindow index or name
paneNoPane index
start_lineNoStart line (negative = history)
end_lineNoEnd line
escape_sequencesNoInclude escape sequences

Implementation Reference

  • The handler function that executes the tmux_capture_pane tool. It constructs the tmux capture-pane command with optional parameters for lines and escape sequences, runs it, truncates output if too long, and returns the pane content.
    },
    async ({ session, window, pane, start_line, end_line, escape_sequences }) => {
      try {
        const target = formatTarget(session, window, pane);
        let cmd = `capture-pane -t "${target}" -p`;
        if (start_line !== undefined) {
          cmd += ` -S ${start_line}`;
        }
        if (end_line !== undefined) {
          cmd += ` -E ${end_line}`;
        }
        if (escape_sequences) {
          cmd += " -e";
        }
        const output = await runTmux(cmd);
        const { text, truncated } = truncateIfNeeded(output);
    
        return {
          content: [{ type: "text", text }],
          structuredContent: { target, content: text, truncated },
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
          isError: true,
        };
      }
    }
  • Zod input schema defining parameters for the tmux_capture_pane tool: session (required), optional window, pane, start_line, end_line, escape_sequences.
    inputSchema: z
      .object({
        session: z.string().min(1).describe("Name of the session"),
        window: z.union([z.string(), z.number()]).optional().describe("Window index or name"),
        pane: z.number().int().min(0).optional().describe("Pane index"),
        start_line: z.number().int().optional().describe("Start line (negative = history)"),
        end_line: z.number().int().optional().describe("End line"),
        escape_sequences: z.boolean().default(false).describe("Include escape sequences"),
      })
      .strict(),
  • src/index.ts:633-692 (registration)
    Registers the tmux_capture_pane tool using server.registerTool, including title, description, inputSchema, annotations, and the handler function.
    server.registerTool(
      "tmux_capture_pane",
      {
        title: "Capture tmux Pane Content",
        description: `Capture the visible content or history of a tmux pane.
    
    Args:
      - session (string, required): Name of the session
      - window (string or number, optional): Window index or name
      - pane (number, optional): Pane index
      - start_line (number, optional): Start line (negative = history, 0 = top of visible)
      - end_line (number, optional): End line (use - for bottom of visible pane)
      - escape_sequences (boolean, optional): Include escape sequences (default: false)
    
    This tool is useful for reading command output or checking the state of a pane.`,
        inputSchema: z
          .object({
            session: z.string().min(1).describe("Name of the session"),
            window: z.union([z.string(), z.number()]).optional().describe("Window index or name"),
            pane: z.number().int().min(0).optional().describe("Pane index"),
            start_line: z.number().int().optional().describe("Start line (negative = history)"),
            end_line: z.number().int().optional().describe("End line"),
            escape_sequences: z.boolean().default(false).describe("Include escape sequences"),
          })
          .strict(),
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ session, window, pane, start_line, end_line, escape_sequences }) => {
        try {
          const target = formatTarget(session, window, pane);
          let cmd = `capture-pane -t "${target}" -p`;
          if (start_line !== undefined) {
            cmd += ` -S ${start_line}`;
          }
          if (end_line !== undefined) {
            cmd += ` -E ${end_line}`;
          }
          if (escape_sequences) {
            cmd += " -e";
          }
          const output = await runTmux(cmd);
          const { text, truncated } = truncateIfNeeded(output);
    
          return {
            content: [{ type: "text", text }],
            structuredContent: { target, content: text, truncated },
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
            isError: true,
          };
        }
      }
    );
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false, so the agent knows this is a safe, non-destructive, idempotent read operation. The description adds useful behavioral context beyond annotations: it explains what 'capture' means (visible content or history) and mentions use cases like reading command output. However, it doesn't cover aspects like error handling or performance implications, keeping it from a perfect score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized: it starts with a clear purpose statement, lists parameters with brief explanations, and ends with a usage note. Every sentence adds value, and there's no wasted text. However, the parameter list is somewhat redundant given the schema, slightly reducing efficiency, so it doesn't achieve a perfect score.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (6 parameters, no output schema) and rich annotations, the description is mostly complete. It explains what the tool does, provides parameter insights, and gives usage context. However, without an output schema, it doesn't describe the return format (e.g., text content, structure), leaving a minor gap. Overall, it's sufficient but not fully comprehensive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, meaning all parameters are well-documented in the input schema. The description includes an 'Args' section that repeats parameter information (e.g., 'start_line (negative = history, 0 = top of visible)'), which adds minimal value beyond the schema. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Capture the visible content or history of a tmux pane.' It specifies the verb ('capture') and resource ('tmux pane content/history'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like tmux_list_panes (which lists panes rather than capturing their content), so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some usage context: 'This tool is useful for reading command output or checking the state of a pane.' This implies when to use it, but it doesn't explicitly state when to use this tool versus alternatives (e.g., tmux_list_panes for listing panes vs. this for capturing content) or when not to use it. The guidance is helpful but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/audibleblink/tmux-mcp-server'

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