create-window
Create a new named window within a specified tmux session to organize and manage terminal tasks efficiently.
Instructions
Create a new window in a tmux session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for the new window | |
| sessionId | Yes | ID of the tmux session |
Implementation Reference
- src/index.ts:207-227 (handler)The async handler function for the 'create-window' MCP tool. It extracts parameters, calls the tmux.createWindow helper, formats success/error responses, and returns structured content.async ({ sessionId, name }) => { try { const window = await tmux.createWindow(sessionId, name); return { content: [{ type: "text", text: window ? `Window created: ${JSON.stringify(window, null, 2)}` : `Failed to create window: ${name}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating window: ${error}` }], isError: true }; } }
- src/index.ts:203-206 (schema)Zod schema defining input parameters for the 'create-window' tool: sessionId (string) and name (string).{ sessionId: z.string().describe("ID of the tmux session"), name: z.string().describe("Name for the new window") },
- src/index.ts:200-228 (registration)MCP server.tool registration for 'create-window' tool, including name, description, schema, and inline handler.server.tool( "create-window", "Create a new window in a tmux session", { sessionId: z.string().describe("ID of the tmux session"), name: z.string().describe("Name for the new window") }, async ({ sessionId, name }) => { try { const window = await tmux.createWindow(sessionId, name); return { content: [{ type: "text", text: window ? `Window created: ${JSON.stringify(window, null, 2)}` : `Failed to create window: ${name}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating window: ${error}` }], isError: true }; } } );
- src/tmux.ts:170-174 (helper)Core helper function implementing tmux window creation via 'tmux new-window' command, then retrieves and returns the new window object by name.export async function createWindow(sessionId: string, name: string): Promise<TmuxWindow | null> { const output = await executeTmux(`new-window -t '${sessionId}' -n '${name}'`); const windows = await listWindows(sessionId); return windows.find(window => window.name === name) || null; }