tmux_create_session
Create a new tmux terminal session with optional name and starting directory for SSH access, command execution, and terminal automation.
Instructions
Create a new tmux session. If no name is provided, tmux will generate one. Returns session name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_name | No | Name for the tmux session (optional) | |
| start_directory | No | Starting directory for the session (optional) |
Implementation Reference
- src/index.js:224-259 (handler)The handler function that implements the tmux_create_session tool. It constructs a tmux new-session command with optional session name and start directory, executes it asynchronously, retrieves the actual session name if not provided, and returns a success message.async createSession(args) { const { session_name, start_directory } = args; let cmd = "tmux new-session -d"; if (session_name) { cmd += ` -s "${session_name}"`; } if (start_directory) { cmd += ` -c "${start_directory}"`; } try { await execAsync(cmd); // If no session name was provided, get the name of the last created session let actualSessionName = session_name; if (!session_name) { const { stdout } = await execAsync( "tmux list-sessions -F '#{session_name}' | tail -1" ); actualSessionName = stdout.trim(); } return { content: [ { type: "text", text: `Created tmux session: ${actualSessionName}`, }, ], }; } catch (error) { throw new Error(`Failed to create session: ${error.message}`); } }
- src/index.js:43-55 (schema)Input schema definition for the tmux_create_session tool, specifying optional string parameters for session_name and start_directory.inputSchema: { type: "object", properties: { session_name: { type: "string", description: "Name for the tmux session (optional)", }, start_directory: { type: "string", description: "Starting directory for the session (optional)", }, }, },
- src/index.js:39-56 (registration)Registration of the tmux_create_session tool in the ListTools response, including name, description, and input schema.{ name: "tmux_create_session", description: "Create a new tmux session. If no name is provided, tmux will generate one. Returns session name.", inputSchema: { type: "object", properties: { session_name: { type: "string", description: "Name for the tmux session (optional)", }, start_directory: { type: "string", description: "Starting directory for the session (optional)", }, }, }, },
- src/index.js:191-192 (registration)Registration in the CallToolRequestHandler switch statement that routes calls to the createSession handler method.case "tmux_create_session": return await this.createSession(args);