tmux_list_sessions
View active tmux sessions with details like name, windows, creation time, and attachment status to manage terminal workflows.
Instructions
List all active tmux sessions with their details (name, windows, created time, attached status).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:261-303 (handler)Executes the tmux list-sessions command using execAsync, parses the output into structured session data (name, windows, created time, attached status), and returns it as JSON text content.async listSessions() { try { const { stdout } = await execAsync( "tmux list-sessions -F '#{session_name}|#{session_windows}|#{session_created}|#{session_attached}' 2>/dev/null || echo ''" ); if (!stdout.trim()) { return { content: [ { type: "text", text: "No active tmux sessions", }, ], }; } const sessions = stdout .trim() .split("\n") .map((line) => { const [name, windows, created, attached] = line.split("|"); const createdDate = new Date(parseInt(created) * 1000); return { name, windows: parseInt(windows), created: createdDate.toISOString(), attached: attached === "1", }; }); return { content: [ { type: "text", text: JSON.stringify(sessions, null, 2), }, ], }; } catch (error) { throw new Error(`Failed to list sessions: ${error.message}`); } }
- src/index.js:57-65 (schema)Defines the tool name, description, and empty input schema for tmux_list_sessions in the list of tools.{ name: "tmux_list_sessions", description: "List all active tmux sessions with their details (name, windows, created time, attached status).", inputSchema: { type: "object", properties: {}, }, },
- src/index.js:193-194 (registration)Registers the handler dispatch for tmux_list_sessions in the CallToolRequest switch statement.case "tmux_list_sessions": return await this.listSessions();