@@ -256,6 +256,100 @@ def split_window(
256256 return _serialize_pane (new_pane )
257257
258258
259+ #: Most panes one ``split_window_many`` call adds. A window that cannot hold
260+ #: them fails at tmux's own limit; this stops a typo from asking for thousands.
261+ _SPLIT_MANY_MAX_COUNT = 64
262+
263+
264+ @handle_tool_errors
265+ def split_window_many (
266+ count : int ,
267+ session_name : str | None = None ,
268+ session_id : str | None = None ,
269+ window_id : str | None = None ,
270+ window_index : str | None = None ,
271+ layout : str = "tiled" ,
272+ start_directory : str | None = None ,
273+ shell : str | None = None ,
274+ socket_name : str | None = None ,
275+ * ,
276+ environment : dict [str , str ] | str | None = None ,
277+ suppress_persistent_history : bool = False ,
278+ ) -> list [PaneInfo ]:
279+ """Add ``count`` panes to a window, keeping a layout applied throughout.
280+
281+ Use to fan work out across several panes at once, for example one
282+ worker per pane. Splitting halves a pane, so a window runs out of room
283+ after a few ``split_window`` calls with "no space for new pane"; this
284+ re-applies ``layout`` after every split so the window keeps room.
285+ Returns the new panes in creation order.
286+
287+ Parameters
288+ ----------
289+ count : int
290+ Number of panes to add, 1 to 64.
291+ session_name : str, optional
292+ Session name.
293+ session_id : str, optional
294+ Session ID (e.g. '$1').
295+ window_id : str, optional
296+ Window ID (e.g. '@1').
297+ window_index : str, optional
298+ Window index within the session.
299+ layout : str
300+ Layout kept applied: ``tiled`` (default), ``even-horizontal``,
301+ ``even-vertical``, ``main-horizontal`` or ``main-vertical``.
302+ start_directory : str, optional
303+ Existing directory to start every new pane in. ``~`` expands; a
304+ relative path resolves against the MCP server process's directory.
305+ shell : str, optional
306+ Shell command to run in every new pane.
307+ socket_name : str, optional
308+ tmux socket name.
309+ environment : dict or str, optional
310+ Per-process environment for every new pane, as a mapping or JSON
311+ object string. Values may be visible to host process inspection in
312+ the tmux client argv during launch and in the child environment
313+ afterward; MCP audit redaction does not hide either surface. Pass
314+ credential references, not literal credentials.
315+ suppress_persistent_history : bool
316+ Whether to suppress persistent history for the spawned shells.
317+ Defaults to False. This per-call option does not inherit
318+ LIBTMUX_SUPPRESS_HISTORY.
319+
320+ Returns
321+ -------
322+ list[PaneInfo]
323+ The new panes, in creation order.
324+ """
325+ if not 1 <= count <= _SPLIT_MANY_MAX_COUNT :
326+ msg = f"count must be between 1 and { _SPLIT_MANY_MAX_COUNT } (received { count } )"
327+ raise ExpectedToolError (msg )
328+ spawn_environment = _prepare_spawn_environment (
329+ environment ,
330+ suppress_persistent_history = suppress_persistent_history ,
331+ )
332+ server = _get_server (socket_name = socket_name )
333+ window = _resolve_window (
334+ server ,
335+ window_id = window_id ,
336+ window_index = window_index ,
337+ session_name = session_name ,
338+ session_id = session_id ,
339+ )
340+ try :
341+ panes = window .split_many (
342+ count ,
343+ layout = layout ,
344+ start_directory = _prepare_start_directory (start_directory ),
345+ shell = shell ,
346+ environment = spawn_environment ,
347+ )
348+ except ValueError as e :
349+ raise ExpectedToolError (str (e )) from e
350+ return [_serialize_pane (pane ) for pane in panes ]
351+
352+
259353@handle_tool_errors
260354def rename_window (
261355 new_name : str ,
@@ -514,6 +608,11 @@ def register(mcp: FastMCP) -> None:
514608 annotations = ANNOTATIONS_AMBIENT_UNKNOWN ,
515609 tags = {TOOLSET_EXECUTE },
516610 )(split_window )
611+ mcp .tool (
612+ title = "Split tmux Window Many" ,
613+ annotations = ANNOTATIONS_AMBIENT_UNKNOWN ,
614+ tags = {TOOLSET_EXECUTE },
615+ )(split_window_many )
517616 mcp .tool (
518617 title = "Rename tmux Window" ,
519618 annotations = ANNOTATIONS_AMBIENT_UNKNOWN ,
0 commit comments