Skip to main content
Glama
nickgnd
by nickgnd

capture-pane

Extract content from tmux panes, specifying line count and optionally preserving text colors, for integration with AI-driven terminal workflows.

Instructions

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

Input Schema

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

Implementation Reference

  • Handler function for the 'capture-pane' MCP tool. Parses input parameters and delegates to tmux.capturePaneContent for execution.
    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 defining parameters for the capture-pane tool: paneId (required), lines (optional string), colors (optional boolean).
    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") },
  • src/index.ts:137-167 (registration)
    MCP server.tool registration for the 'capture-pane' tool, including description, schema, and handler reference.
    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 }; } } );
  • Core helper function that executes the tmux 'capture-pane' command via executeTmux, handling color flags and line counts.
    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 -`); }

Other Tools

Related 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