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

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