list-panes
List panes in a tmux window using the specified window ID, enabling users to manage and interact with terminal session layouts efficiently.
Instructions
List panes in a tmux window
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| windowId | Yes | ID of the tmux window |
Implementation Reference
- src/index.ts:109-134 (registration)MCP server.tool registration for the 'list-panes' tool, including description, Zod input schema, and inline execution handler.server.tool( "list-panes", "List panes in a tmux window", { windowId: z.string().describe("ID of the tmux window") }, async ({ windowId }) => { try { const panes = await tmux.listPanes(windowId); return { content: [{ type: "text", text: JSON.stringify(panes, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error listing panes: ${error}` }], isError: true }; } } );
- src/index.ts:112-114 (schema)Zod input schema defining the required 'windowId' parameter for the tool.{ windowId: z.string().describe("ID of the tmux window") },
- src/index.ts:115-133 (handler)Inline handler function that calls tmux.listPanes, serializes result to JSON text response, or returns error.async ({ windowId }) => { try { const panes = await tmux.listPanes(windowId); return { content: [{ type: "text", text: JSON.stringify(panes, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error listing panes: ${error}` }], isError: true }; } }
- src/tmux.ts:134-149 (helper)Helper function implementing the core logic: runs 'tmux list-panes', parses formatted output into array of TmuxPane objects.export async function listPanes(windowId: string): Promise<TmuxPane[]> { const format = "#{pane_id}:#{pane_title}:#{?pane_active,1,0}"; const output = await executeTmux(`list-panes -t '${windowId}' -F '${format}'`); if (!output) return []; return output.split('\n').map(line => { const [id, title, active] = line.split(':'); return { id, windowId, title: title, active: active === '1' }; }); }
- src/tmux.ts:22-27 (schema)TypeScript interface defining the structure of each pane object returned by listPanes.export interface TmuxPane { id: string; windowId: string; active: boolean; title: string; }