list-windows
Retrieve and display all windows within a specified tmux session using the session ID. Ideal for managing and monitoring multiple terminal workflows within a session.
Instructions
List windows in a tmux session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID of the tmux session |
Implementation Reference
- src/index.ts:87-105 (handler)MCP tool handler: fetches windows using tmux.listWindows(sessionId) and returns formatted text response or errorasync ({ sessionId }) => { try { const windows = await tmux.listWindows(sessionId); return { content: [{ type: "text", text: JSON.stringify(windows, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error listing windows: ${error}` }], isError: true }; } }
- src/index.ts:84-86 (schema)Zod input schema defining required 'sessionId' parameter{ sessionId: z.string().describe("ID of the tmux session") },
- src/index.ts:81-106 (registration)Registers the 'list-windows' MCP tool with description, schema, and handler functionserver.tool( "list-windows", "List windows in a tmux session", { sessionId: z.string().describe("ID of the tmux session") }, async ({ sessionId }) => { try { const windows = await tmux.listWindows(sessionId); return { content: [{ type: "text", text: JSON.stringify(windows, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error listing windows: ${error}` }], isError: true }; } } );
- src/tmux.ts:114-129 (helper)Core helper function that executes the tmux 'list-windows' command, parses the formatted output into TmuxWindow objectsexport async function listWindows(sessionId: string): Promise<TmuxWindow[]> { const format = "#{window_id}:#{window_name}:#{?window_active,1,0}"; const output = await executeTmux(`list-windows -t '${sessionId}' -F '${format}'`); if (!output) return []; return output.split('\n').map(line => { const [id, name, active] = line.split(':'); return { id, name, active: active === '1', sessionId }; }); }