Create session¶
create_session¶
Create a new tmux session.
- Returns:
Use when you need a new isolated workspace. Sessions are the top-level container — create one before creating windows or panes.
Avoid when a session with the target name already exists — check with
list_sessions first, or the command will fail.
Side effects: Creates a new tmux session with one window and one pane.
Do not pass credentials directly in environment. Values persist in the
new session, can be inspected with show_environment, and reach
its initial pane and future panes. Pass credential references instead; see
Safety tiers for details.
suppress_persistent_history defaults to false for MCP and direct Python calls. It does not inherit LIBTMUX_SUPPRESS_HISTORY. Leave it false to add no history controls for this call. That choice cannot remove inherited, session, or startup-file controls.
Set it to true and create_session copies and merges best-effort no-disk history controls into the tmux session environment. They reach the initial pane and future panes in that session. The shell can retain in-memory history, and a startup file can override these controls after the process starts.
When you enable it, tmux environment arguments are added, but the spawned process command text is not prefixed or rewritten. If you also pass environment, any history-control values must agree with the policy. A conflict fails the call, names the variable without including the conflicting value, and is never retried without suppression. See History suppression for shell behavior and Safety tiers for output, scrollback, process, transcript, hook, and logging boundaries.
Example:
{
"tool": "create_session",
"arguments": {
"session_name": "dev"
}
}
Response (SessionInfo):
{
"session_id": "$1",
"session_name": "dev",
"window_count": 1,
"session_attached": "0",
"session_created": "1774521872",
"active_pane_id": "%0"
}
Tip
The returned active_pane_id is the pane ID (%N) of the
session’s initial pane. It’s guaranteed non-None immediately
after create_session (the
libtmux layer always creates the
session with one initial pane), so you can target subsequent
send_keys / split_window /
capture_pane calls directly without a
follow-up list_panes round-trip — saving an MCP call
in the most common “new session, then act on it” workflow.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
no |
— |
Name for the new session. |
|
|
no |
— |
Name for the initial window. |
|
|
no |
— |
Working directory for the session. |
|
|
no |
— |
Width of the initial window. |
|
|
no |
— |
Height of the initial window. |
|
|
no |
— |
Environment variables to store in the session environment. Accepts either a dict of env vars or a JSON-serialized string of the same — the latter is the cursor-composer-1 workaround described in :func: |
|
|
no |
— |
tmux socket name. Defaults to LIBTMUX_SOCKET env var. |
|
|
no |
|
Whether to suppress persistent history for the spawned shell. Defaults to False for MCP and direct Python calls. This per-call option does not inherit LIBTMUX_SUPPRESS_HISTORY. Startup files may override these controls. |