Skip to main content
Glama

Create tmux Session

tmux_create_session

Create a new tmux session with a custom name, window label, and starting directory to organize terminal workflows in detached mode.

Instructions

Create a new tmux session.

Args:

  • name (string, required): Name for the new session

  • window_name (string, optional): Name for the initial window

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

The session is created in detached mode. Use this to start new working environments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName for the new session
window_nameNoName for the initial window
start_directoryNoStarting directory for the session

Implementation Reference

  • Handler function that executes tmux new-session command with optional window name and start directory.
    async ({ name, window_name, start_directory }) => {
      try {
        let cmd = `new-session -d -s "${name}"`;
        if (window_name) {
          cmd += ` -n "${window_name}"`;
        }
        if (start_directory) {
          cmd += ` -c "${start_directory}"`;
        }
        await runTmux(cmd);
    
        return {
          content: [{ type: "text", text: `Session '${name}' created successfully.` }],
          structuredContent: { success: true, session: name },
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
          isError: true,
        };
      }
    }
  • Zod schema for input validation: name (required string), window_name and start_directory (optional strings).
    inputSchema: z
      .object({
        name: z.string().min(1).describe("Name for the new session"),
        window_name: z.string().optional().describe("Name for the initial window"),
        start_directory: z.string().optional().describe("Starting directory for the session"),
      })
      .strict(),
  • src/index.ts:163-211 (registration)
    Registration of the tmux_create_session tool using server.registerTool, including title, description, schema, annotations, and handler.
    server.registerTool(
      "tmux_create_session",
      {
        title: "Create tmux Session",
        description: `Create a new tmux session.
    
    Args:
      - name (string, required): Name for the new session
      - window_name (string, optional): Name for the initial window
      - start_directory (string, optional): Starting directory for the session
    
    The session is created in detached mode. Use this to start new working environments.`,
        inputSchema: z
          .object({
            name: z.string().min(1).describe("Name for the new session"),
            window_name: z.string().optional().describe("Name for the initial window"),
            start_directory: z.string().optional().describe("Starting directory for the session"),
          })
          .strict(),
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: false,
          openWorldHint: false,
        },
      },
      async ({ name, window_name, start_directory }) => {
        try {
          let cmd = `new-session -d -s "${name}"`;
          if (window_name) {
            cmd += ` -n "${window_name}"`;
          }
          if (start_directory) {
            cmd += ` -c "${start_directory}"`;
          }
          await runTmux(cmd);
    
          return {
            content: [{ type: "text", text: `Session '${name}' created successfully.` }],
            structuredContent: { success: true, session: name },
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
            isError: true,
          };
        }
      }
    );
  • Utility function runTmux that executes tmux commands and handles common errors, used by the handler.
    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 indicate this is a non-destructive, non-readonly, non-idempotent creation operation. The description adds valuable behavioral context beyond annotations: it specifies the session is created in detached mode (important operational detail) and mentions the purpose ('to start new working environments'). 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 efficiently structured with a clear purpose statement first, followed by parameter documentation, and ending with usage guidance. Every sentence serves a distinct purpose with no redundancy or wasted words. The two-sentence format is optimal for this tool.

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 creation tool with no output schema and comprehensive annotations, the description provides adequate context about the operation's behavior and usage. The main gap is lack of information about return values or error conditions, but given the annotations cover safety aspects and the purpose is straightforward, this is a minor omission.

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?

With 100% schema description coverage, the schema already documents all three parameters thoroughly. The description repeats the parameter explanations verbatim from the schema without adding additional semantic context (e.g., format constraints, examples, or relationships between parameters). This meets the baseline for 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 ('Create a new tmux session') and distinguishes it from siblings like tmux_create_window (creates windows within sessions) and tmux_list_sessions (lists existing sessions). It specifies the resource being created (tmux session) with no ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Use this to start new working environments') and mentions the session is created in detached mode, which helps differentiate from other session-related operations. However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.

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