Skip to main content
Glama
nickgnd

Tmux MCP Server

by nickgnd

capture-pane

Extract text content from tmux terminal panes with configurable line counts and optional color formatting for AI-assisted terminal session analysis.

Instructions

Capture content from a tmux pane with configurable lines count and optional color preservation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paneIdYesID of the tmux pane
linesNoNumber of lines to capture
colorsNoInclude color/escape sequences for text and background attributes in output

Implementation Reference

  • Primary handler and registration for the 'capture-pane' MCP tool. Defines the tool name, description, input schema, and execution logic which parses inputs and delegates to tmux.capturePaneContent helper.
    server.tool(
      "capture-pane",
      "Capture content from a tmux pane with configurable lines count and optional color preservation",
      {
        paneId: z.string().describe("ID of the tmux pane"),
        lines: z.string().optional().describe("Number of lines to capture"),
        colors: z.boolean().optional().describe("Include color/escape sequences for text and background attributes in output")
      },
      async ({ paneId, lines, colors }) => {
        try {
          // Parse lines parameter if provided
          const linesCount = lines ? parseInt(lines, 10) : undefined;
          const includeColors = colors || false;
          const content = await tmux.capturePaneContent(paneId, linesCount, includeColors);
          return {
            content: [{
              type: "text",
              text: content || "No content captured"
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error capturing pane content: ${error}`
            }],
            isError: true
          };
        }
      }
    );
  • Zod input schema for capture-pane tool: paneId (string, required), lines (optional string for number of lines), colors (optional boolean for including color sequences).
    {
      paneId: z.string().describe("ID of the tmux pane"),
      lines: z.string().optional().describe("Number of lines to capture"),
      colors: z.boolean().optional().describe("Include color/escape sequences for text and background attributes in output")
    },
  • Core helper function implementing the tmux capture-pane command execution. Supports custom line count (default 200) and optional color inclusion via -e flag.
    export async function capturePaneContent(paneId: string, lines: number = 200, includeColors: boolean = false): Promise<string> {
      const colorFlag = includeColors ? '-e' : '';
      return executeTmux(`capture-pane -p ${colorFlag} -t '${paneId}' -S -${lines} -E -`);
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'configurable lines count and optional color preservation' which hints at output behavior, but lacks critical details such as error handling, format of captured content, whether it's read-only or modifies the pane, or any performance implications. This leaves significant gaps for an agent to understand the tool's behavior.

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

Conciseness5/5

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

The description is a single, well-structured sentence that efficiently conveys the core functionality and key parameters. It's front-loaded with the main purpose and wastes no words, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the tool has no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the captured content looks like (e.g., plain text, formatted output), error conditions, or how it interacts with tmux sessions. For a tool with 3 parameters and no structured behavioral hints, more context is needed for reliable agent use.

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%, so the input schema already documents all parameters thoroughly. The description adds marginal value by framing 'lines' as 'configurable lines count' and 'colors' as 'optional color preservation', but doesn't provide additional semantic context beyond what the schema descriptions offer.

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 action ('capture content') and resource ('from a tmux pane'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list-panes' or 'execute-command' which might also retrieve pane information, though the specific capture functionality is distinct.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions configurable lines and colors but doesn't explain scenarios where this is preferable over other pane-related tools like 'list-panes' or 'execute-command', nor does it mention prerequisites or exclusions.

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

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