Skip to main content
Glama
nickgnd

Tmux MCP Server

by nickgnd

list-panes

Retrieve and display all terminal panes within a specified tmux window to manage and monitor session layout.

Instructions

List panes in a tmux window

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
windowIdYesID of the tmux window

Implementation Reference

  • Core handler function that executes the tmux 'list-panes' command, parses the formatted output into TmuxPane objects, and returns the list of panes.
    export async function listPanes(windowId: string): Promise<TmuxPane[]> {
      const format = "#{pane_id}:#{pane_title}:#{?pane_active,1,0}";
      const output = await executeTmux(`list-panes -t '${windowId}' -F '${format}'`);
    
      if (!output) return [];
    
      return output.split('\n').map(line => {
        const [id, title, active] = line.split(':');
        return {
          id,
          windowId,
          title: title,
          active: active === '1'
        };
      });
    }
  • src/index.ts:109-134 (registration)
    MCP tool registration for 'list-panes', including input schema (windowId: string) and thin wrapper handler that calls tmux.listPanes and returns JSON response.
    server.tool(
      "list-panes",
      "List panes in a tmux window",
      {
        windowId: z.string().describe("ID of the tmux window")
      },
      async ({ windowId }) => {
        try {
          const panes = await tmux.listPanes(windowId);
          return {
            content: [{
              type: "text",
              text: JSON.stringify(panes, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error listing panes: ${error}`
            }],
            isError: true
          };
        }
      }
    );
  • TypeScript interface defining the structure of a TmuxPane object, used as output type for listPanes.
    export interface TmuxPane {
      id: string;
      windowId: string;
      active: boolean;
      title: string;
    }

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