Skip to main content
Glama

Create tmux Window

tmux_create_window

Create a new window in a tmux session with optional naming and starting directory configuration for organized terminal workspace management.

Instructions

Create a new window in a tmux session.

Args:

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

  • name (string, optional): Name for the new window

  • start_directory (string, optional): Starting directory for the window

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionYesName of the session
nameNoName for the new window
start_directoryNoStarting directory for the window

Implementation Reference

  • Handler function that executes the tmux_create_window tool logic by constructing and running the 'tmux new-window' command with optional name and start_directory.
    async ({ session, name, start_directory }) => {
      try {
        let cmd = `new-window -t "${session}"`;
        if (name) {
          cmd += ` -n "${name}"`;
        }
        if (start_directory) {
          cmd += ` -c "${start_directory}"`;
        }
        await runTmux(cmd);
    
        return {
          content: [{ type: "text", text: `Window${name ? ` '${name}'` : ""} created in session '${session}'.` }],
          structuredContent: { success: true, session, window: 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_create_window tool: session (required), name (optional), start_directory (optional).
    inputSchema: z
      .object({
        session: z.string().min(1).describe("Name of the session"),
        name: z.string().optional().describe("Name for the new window"),
        start_directory: z.string().optional().describe("Starting directory for the window"),
      })
      .strict(),
    annotations: {
  • src/index.ts:314-360 (registration)
    Registration of the tmux_create_window tool with McpServer, including title, description, schema, annotations, and inline handler.
    server.registerTool(
      "tmux_create_window",
      {
        title: "Create tmux Window",
        description: `Create a new window in a tmux session.
    
    Args:
      - session (string, required): Name of the session
      - name (string, optional): Name for the new window
      - start_directory (string, optional): Starting directory for the window`,
        inputSchema: z
          .object({
            session: z.string().min(1).describe("Name of the session"),
            name: z.string().optional().describe("Name for the new window"),
            start_directory: z.string().optional().describe("Starting directory for the window"),
          })
          .strict(),
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: false,
          openWorldHint: false,
        },
      },
      async ({ session, name, start_directory }) => {
        try {
          let cmd = `new-window -t "${session}"`;
          if (name) {
            cmd += ` -n "${name}"`;
          }
          if (start_directory) {
            cmd += ` -c "${start_directory}"`;
          }
          await runTmux(cmd);
    
          return {
            content: [{ type: "text", text: `Window${name ? ` '${name}'` : ""} created in session '${session}'.` }],
            structuredContent: { success: true, session, window: name },
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
            isError: true,
          };
        }
      }
    );
  • Shared utility function to execute tmux commands via child_process.exec, with custom error messages for common tmux errors.
    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;
      }
    }
Behavior3/5

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

Annotations already declare readOnlyHint=false, destructiveHint=false, etc., so the agent knows this is a non-destructive write operation. The description adds minimal behavioral context beyond annotations—it doesn't explain what happens if the session doesn't exist, whether the window becomes active, or if naming conflicts occur. With annotations covering safety, a 3 reflects some value but limited behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/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 Args section. It's efficient with minimal waste, though the Args section could be integrated more seamlessly. Every sentence earns its place, but slight structural improvements are possible.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema), annotations cover safety aspects, but the description lacks details on error conditions, return values, or interaction with sibling tools. It's adequate as a basic definition but has clear gaps in contextual guidance for effective agent use.

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 each parameter documented in the schema. The description repeats the parameter names and purposes verbatim from the schema without adding extra meaning (e.g., format examples, constraints like valid directory paths). Baseline 3 is appropriate since the schema does the heavy lifting.

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 ('Create a new window') and resource ('in a tmux session'), distinguishing it from sibling tools like tmux_create_session (creates sessions) or tmux_kill_window (destroys windows). 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 Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., session must exist), compare to tmux_split_window (which creates panes within windows), or specify scenarios where creating a window is preferred over other operations. Usage context is implied but not articulated.

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