Skip to main content
Glama

List tmux Windows

tmux_list_windows
Read-onlyIdempotent

List all windows in a tmux session to view their index, name, active status, and pane count for session management.

Instructions

List all windows in a tmux session.

Args:

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

Returns information about each window including index, name, active status, and pane count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionYesName of the session

Implementation Reference

  • Main handler function that lists windows in the specified tmux session by executing 'tmux list-windows' with a custom format, parsing the output into TmuxWindow objects (index, name, active status, pane count), handling empty results and errors, and returning both text and structured JSON content.
    async ({ session }) => {
      try {
        const output = await runTmux(
          `list-windows -t "${session}" -F "#{window_index}|#{window_name}|#{window_active}|#{window_panes}"`
        );
    
        if (!output) {
          return {
            content: [{ type: "text", text: `No windows found in session '${session}'.` }],
          };
        }
    
        const windows: TmuxWindow[] = output.split("\n").map((line) => {
          const [index, name, active, panes] = line.split("|");
          return {
            index: parseInt(index, 10),
            name,
            active: active === "1",
            panes: parseInt(panes, 10),
          };
        });
    
        const result = { session, count: windows.length, windows };
    
        return {
          content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
          structuredContent: result,
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
          isError: true,
        };
      }
    }
  • Zod input schema defining the required 'session' parameter as a non-empty string.
    inputSchema: z
      .object({
        session: z.string().min(1).describe("Name of the session"),
      })
      .strict(),
  • TypeScript interface defining the structure of a tmux window object used in the tool's output.
      index: number;
      name: string;
      active: boolean;
      panes: number;
    }
  • src/index.ts:255-312 (registration)
    Full registration of the tmux_list_windows tool with McpServer, including name, tool specification (title, description, input schema, annotations), and inline handler function.
    server.registerTool(
      "tmux_list_windows",
      {
        title: "List tmux Windows",
        description: `List all windows in a tmux session.
    
    Args:
      - session (string, required): Name of the session
    
    Returns information about each window including index, name, active status, and pane count.`,
        inputSchema: z
          .object({
            session: z.string().min(1).describe("Name of the session"),
          })
          .strict(),
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ session }) => {
        try {
          const output = await runTmux(
            `list-windows -t "${session}" -F "#{window_index}|#{window_name}|#{window_active}|#{window_panes}"`
          );
    
          if (!output) {
            return {
              content: [{ type: "text", text: `No windows found in session '${session}'.` }],
            };
          }
    
          const windows: TmuxWindow[] = output.split("\n").map((line) => {
            const [index, name, active, panes] = line.split("|");
            return {
              index: parseInt(index, 10),
              name,
              active: active === "1",
              panes: parseInt(panes, 10),
            };
          });
    
          const result = { session, count: windows.length, windows };
    
          return {
            content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
            structuredContent: result,
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
            isError: true,
          };
        }
      }
    );
  • Utility function to execute tmux commands asynchronously, handling common errors like no server, session/window/pane not found with helpful messages referencing this tool.
    async function runTmux(args: string): Promise<string> {
      try {
        const { stdout } = await execAsync(`tmux ${args}`);
        return stdout.trim();
      } catch (error: unknown) {
        if (error instanceof Error && "stderr" in error) {
          const stderr = (error as { stderr: string }).stderr;
          if (stderr.includes("no server running")) {
            throw new Error("tmux server is not running. Start a session first with tmux_create_session.");
          }
          if (stderr.includes("session not found")) {
            throw new Error("Session not found. Use tmux_list_sessions to see available sessions.");
          }
          if (stderr.includes("window not found")) {
            throw new Error("Window not found. Use tmux_list_windows to see available windows.");
          }
          if (stderr.includes("can't find pane")) {
            throw new Error("Pane not found. Use tmux_list_panes to see available panes.");
          }
          throw new Error(`tmux error: ${stderr}`);
        }
        throw error;
      }
    }
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, covering safety and idempotency. The description adds valuable context about what information is returned (index, name, active status, pane count), which goes beyond annotations and helps the agent understand the output structure. No contradictions with annotations exist.

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 front-loaded with the core purpose in the first sentence, followed by a structured breakdown of args and returns. Every sentence adds value: the first states the action, the second clarifies the parameter, and the third details the return information. No wasted words or redundancy.

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?

For a read-only listing tool with rich annotations and a simple parameter schema, the description is mostly complete. It covers purpose, parameter context, and return details. The lack of an output schema is compensated by the return information description. Minor gaps include no explicit sibling differentiation or error handling details.

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%, with the parameter 'session' fully documented in the schema. The description repeats the parameter name and requirement but doesn't add meaningful semantics beyond what the schema provides, such as format examples or session naming conventions. Baseline 3 is appropriate given high schema coverage.

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

Purpose5/5

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

The description clearly states the specific action ('List all windows') and resource ('in a tmux session'), distinguishing it from sibling tools like tmux_list_sessions (which lists sessions) and tmux_list_panes (which lists panes). The verb+resource combination is precise and unambiguous.

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 implies usage when needing to list windows within a specific session, but doesn't explicitly state when to use this tool versus alternatives like tmux_list_sessions or tmux_list_panes. No guidance is provided on prerequisites or exclusions, leaving usage context inferred rather than explicit.

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