# libtmux_mcp.tools.server_tools.create_session

- **Module:** libtmux_mcp.tools.server_tools
- **Package:** libtmux-mcp
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux-mcp/blob/4daddc0dfca96c43bf521d818bf91564e1434760/src/libtmux_mcp/tools/server_tools.py#L70
- **Page:** https://libtmux.org/en/py/stable/mcp/reference/libtmux_mcp-tools-server_tools-create_session/

```
libtmux_mcp.tools.server_tools.create_session(
    session_name: str | None = None,
    window_name: str | None = None,
    start_directory: str | None = None,
    x: int | None = None,
    y: int | None = None,
    environment: dict[str, str] | str | None = None,
    socket_name: str | None = None,
    suppress_persistent_history: bool = False,
) -> SessionInfo
```

Create a new tmux session.

Check list_sessions first to avoid name conflicts. A new session
starts with one window and one pane. Values in ``environment`` are stored
in the tmux session environment, so future panes inherit them too.

## Parameters

- `session_name` (`str | None`): Name for the new session.
- `window_name` (`str | None`): Name for the initial window.
- `start_directory` (`str | None`): Existing directory to start in. ``~`` expands; a relative path
resolves against the MCP server process's directory.
- `x` (`int | None`): Width of the initial window.
- `y` (`int | None`): Height of the initial window.
- `environment` (`dict[str, str] | str | None`): 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:`libtmux_mcp._utils._coerce_dict_arg`. Each item appears in the
tmux client argv as one ``-eKEY=VALUE`` element and may be visible to
host process inspection during launch. tmux retains the values in
tmux session state, where ``show-environment`` can reveal them. They reach
the initial and future child environments unless a later spawn
overrides them. MCP audit redaction does not hide these surfaces. Pass
credential references, not literal credentials.
- `socket_name` (`str | None`): tmux socket name. Defaults to LIBTMUX_SOCKET env var.
- `suppress_persistent_history` (`bool`): 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.

## Returns

SessionInfo
    The created session.
