Skip to main content
Glama

tmux_rename_window

Change the name of a tmux window to organize terminal sessions by specifying the session, window, and new name.

Instructions

Rename a window in a tmux session.

Args:

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

  • window (string or number, required): Window index or current name

  • new_name (string, required): New window name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionYesName of the session
windowYesWindow index or current name
new_nameYesNew window name

Implementation Reference

  • The handler function that executes the tmux_rename_window tool logic, formatting the session:window target and running the 'tmux rename-window' command.
    async ({ session, window, new_name }) => {
      try {
        const target = formatTarget(session, window);
        await runTmux(`rename-window -t "${target}" "${new_name}"`);
    
        return {
          content: [{ type: "text", text: `Window '${window}' renamed to '${new_name}'.` }],
          structuredContent: { success: true, session, window, new_name },
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
          isError: true,
        };
      }
    }
  • Zod input schema defining parameters for the tmux_rename_window tool: session (string), window (string|number), new_name (string).
    inputSchema: z
      .object({
        session: z.string().min(1).describe("Name of the session"),
        window: z.union([z.string(), z.number()]).describe("Window index or current name"),
        new_name: z.string().min(1).describe("New window name"),
      })
      .strict(),
  • src/index.ts:819-859 (registration)
    Registration of the tmux_rename_window tool using server.registerTool, including title, description, input schema, annotations, and handler function.
    server.registerTool(
      "tmux_rename_window",
      {
        title: "Rename tmux Window",
        description: `Rename a window in a tmux session.
    
    Args:
      - session (string, required): Name of the session
      - window (string or number, required): Window index or current name
      - new_name (string, required): New window name`,
        inputSchema: z
          .object({
            session: z.string().min(1).describe("Name of the session"),
            window: z.union([z.string(), z.number()]).describe("Window index or current name"),
            new_name: z.string().min(1).describe("New window name"),
          })
          .strict(),
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ session, window, new_name }) => {
        try {
          const target = formatTarget(session, window);
          await runTmux(`rename-window -t "${target}" "${new_name}"`);
    
          return {
            content: [{ type: "text", text: `Window '${window}' renamed to '${new_name}'.` }],
            structuredContent: { success: true, session, window, new_name },
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
            isError: true,
          };
        }
      }
    );
  • Helper function formatTarget used by the handler to construct the tmux target string from session, window, and optional pane.
    function formatTarget(session?: string, window?: number | string, pane?: number): string {
      let target = "";
      if (session) {
        target = session;
        if (window !== undefined) {
          target += `:${window}`;
          if (pane !== undefined) {
            target += `.${pane}`;
          }
        }
      }
      return target;

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