Skip to main content
Glama
nickgnd
by nickgnd

list-sessions

Displays all active tmux sessions for interaction or management, enabling users to monitor and control terminal sessions efficiently via the Tmux MCP Server.

Instructions

List all active tmux sessions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list-sessions' tool. It calls tmux.listSessions() to get the list of sessions and returns them formatted as JSON text content, with error handling.
    try { const sessions = await tmux.listSessions(); return { content: [{ type: "text", text: JSON.stringify(sessions, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error listing tmux sessions: ${error}` }], isError: true }; } }
  • src/index.ts:27-50 (registration)
    Registration of the 'list-sessions' tool using server.tool(), including name, description, empty input schema, and inline handler.
    server.tool( "list-sessions", "List all active tmux sessions", {}, async () => { try { const sessions = await tmux.listSessions(); return { content: [{ type: "text", text: JSON.stringify(sessions, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error listing tmux sessions: ${error}` }], isError: true }; } } );
  • Helper function listSessions() that executes the tmux 'list-sessions' command, parses the output into TmuxSession objects, and returns the array of sessions.
    export async function listSessions(): Promise<TmuxSession[]> { const format = "#{session_id}:#{session_name}:#{?session_attached,1,0}:#{session_windows}"; const output = await executeTmux(`list-sessions -F '${format}'`); if (!output) return []; return output.split('\n').map(line => { const [id, name, attached, windows] = line.split(':'); return { id, name, attached: attached === '1', windows: parseInt(windows, 10) }; }); }
  • TypeScript interface defining the structure of a TmuxSession, used as the output type for listSessions() and thus the tool response.
    export interface TmuxSession { id: string; name: string; attached: boolean; windows: number; }

Other Tools

Related 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/nickgnd/tmux-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server