mcp-tmux
v0.3.1A comprehensive, universal MCP server for driving tmux (local and over SSH).
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
tmux_command
Run an arbitrary tmux command and return its raw result. This is the universal escape hatch — it runs `tmux <args>` verbatim, so it can do anything the target's tmux supports. Pass the subcommand and its flags as a list, e.g. args=["new-window", "-t", "mysess", "-n", "logs"]. Do NOT include the leading "tmux". Returns {"stdout", "stderr", "exit_code"}. Non-zero exit codes are returned, not raised, so you can inspect failures. `target` selects where tmux runs: omit (or "local") for the local machine, a named profile from the c…
| Parameter | Type | Description |
|---|---|---|
args * | array | tmux subcommand + flags as a list (no leading "tmux"). |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
timeout | Max seconds to wait for the command. |
tmux_query
Evaluate a tmux format string (e.g. "#{pane_current_path}"). Uses `display-message -p` to expand any #{...} format variable. Optional `target_pane` sets the context (-t) the format is evaluated against. This returns the expanded value to you; to instead show a message on a client's status line, use `tmux_display_message`. Returns {"value": <expanded string>}.
| Parameter | Type | Description |
|---|---|---|
format * | string | tmux format string to expand, e.g. "#{pane_current_path}". |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
target_pane | The pane to act on (e.g. "%3" or "sess:1.2"); defaults to the active pane when omitted. |
tmux_version
Report the target's tmux version and whether it is supported (1.8+). For more server facts (pid, socket path) use `tmux_server_info`.
| Parameter | Type | Description |
|---|---|---|
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. |
tmux_list_targets
List configured targets: 'local' plus any named profiles from config. Pass one of these names as the `target` argument of any other tool to run it against that host.
tmux_has_session
Check whether a session exists. Returns {"exists": bool}. To enumerate sessions use `tmux_list(kind="session")`; to create one only if it is missing, use `tmux_new_session(attach_or_create=True)` directly.
| Parameter | Type | Description |
|---|---|---|
session * | string | Session name or id to check for. |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. |
tmux_new_session
Create a new session (detached by default). Optional `command` runs as the first pane's command; `start_directory` sets the working dir; `width`/`height` size the detached session. `attach_or_create=True` makes the call idempotent: if a session named `name` already exists it is reused (its id/name returned) instead of erroring, otherwise it is created. tmux's own `new-session -A` *attaches* the existing session, which a headless MCP server has no terminal to do; so the reuse here is a detached `has-session` check (the create-time…
| Parameter | Type | Description |
|---|---|---|
attach_or_create | boolean | Reuse an existing session of this name instead of erroring. |
command | Command to run as the first pane instead of the default shell. | |
detached | boolean | Create the session detached (-d); default True. |
env | Session environment variables (-e KEY=VAL; tmux 3.0+). | |
height | Height in rows for the detached session (-y). | |
name | Name for the new session (-s). | |
start_directory | Working directory for the first pane (-c). | |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
width | Width in columns for the detached session (-x). |
tmux_new_window
Create a window. `session` is the target session (or "sess:index"). Set select=False to create it in the background (-d). Use this to add a window to an existing session; for a whole new session use `tmux_new_session`, or `tmux_split_window` to add a pane to the current window instead. Returns the new window's {"id", "index", "name"}.
| Parameter | Type | Description |
|---|---|---|
command | Command to run instead of the default shell. | |
name | Name for the new window (-n). | |
select | boolean | Focus the new window (default); False backgrounds it (-d). |
session | Target session or "sess:index" (-t); current session if omitted. | |
start_directory | Working directory for the new window (-c). | |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. |
tmux_list_panes
List panes. Scope to a `window` (-t), a `session` (-s), or the whole server (default, -a). For sessions/windows/clients/buffers use `tmux_list(kind=...)`; panes live here because they have two independent scope axes (window vs session).
| Parameter | Type | Description |
|---|---|---|
session | Scope to all panes in a session (-s). | |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
window | Scope to a single window (-t); takes precedence over session. |
tmux_split_window
Split a pane. By default splits left/right; vertical=True splits top/bottom. `percentage` sizes the new pane (e.g. 30). select=False keeps focus on the original pane (-d). Use this to add a pane to the current window; use `tmux_new_window` for a fresh window instead, or `tmux_join_pane` to move an existing pane in as the split rather than spawning a new one. Returns the new pane's {"id", "index"}.
| Parameter | Type | Description |
|---|---|---|
command | Shell command to run in the new pane instead of the default shell. | |
percentage | Size of the new pane as a percentage of the space (e.g. 30). | |
select | boolean | Focus the new pane (default); False keeps focus on the original (-d). |
start_directory | Working directory for the new pane (-c). | |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
target_pane | The pane to act on (e.g. "%3" or "sess:1.2"); defaults to the active pane when omitted. | |
vertical | boolean | Split top/bottom instead of the default left/right. |
tmux_list
List sessions, windows, clients, or paste buffers. `kind` selects what to enumerate: - "session" — all sessions (`scope` ignored) - "window" — windows in `scope` (a session); all windows server-wide (-a) when `scope` is omitted - "client" — clients attached to `scope` (a session); all clients when omitted - "buffer" — paste buffers (`scope` ignored) Panes are NOT here — use `tmux_list_panes`, which has two independent scope axes (a window vs a session). Key bindings use `tmux_list_keys`…
| Parameter | Type | Description |
|---|---|---|
kind * | string | What to enumerate: "session", "window", "client", or "buffer". |
scope | Context for the listing: a session for kind="window"/"client" (omit for server-wide); ignored for "session"/"buffer". | |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. |
tmux_kill
Kill a session, window, pane, or the whole server (destructive). Irreversible and immediate: tmux does not prompt for confirmation, and any program running in the killed entity is terminated (SIGHUP) along with its unsaved state and scrollback. Killing the last pane in a window closes the window; killing the last window in a session ends the session. `kind` selects what to kill: "session" / "window" / "pane" / "server". `id` is the target entity (e.g. session name "work", a window "sess:2", a pane "%3" or "sess:2.1") and is required for…
| Parameter | Type | Description |
|---|---|---|
kind * | string | What to kill: "session", "window", "pane", or "server". |
id | The entity to kill (e.g. session "work", window "sess:2", pane "%3"); required for every kind except "server". | |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. |
tmux_rename
Rename a session or window. `kind` is "session" or "window"; `id` is the entity to rename. Maps to `rename-<kind> -t id new_name`. To label a pane (rather than rename its window), use `tmux_set_pane_title` instead. Returns {"renamed": True, "kind": kind, "name": new_name}.
| Parameter | Type | Description |
|---|---|---|
id * | string | The entity to rename (e.g. "work" or "work:2"). |
kind * | string | What to rename: "session" or "window". |
new_name * | string | The new name to assign. |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. |
tmux_select
Make a window or pane the active (focused) one. Moves the selection so that subsequent interactive input and any attached client's view go to this entity; selecting a pane also selects its window. This only changes focus — it does not alter contents or layout, and it is not required before targeting an entity by id elsewhere (e.g. `tmux_send_keys` and `tmux_capture_pane` address a pane directly, regardless of which one is active). `kind` is "window" or "pane"; `id` is the entity to activate (e.g. "mysess:2" for a window, "%3"…
| Parameter | Type | Description |
|---|---|---|
id * | string | The entity to activate (e.g. "mysess:2" or pane "%3"). |
kind * | string | What to activate: "window" or "pane". |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. |
tmux_send_keys
Send input to a pane. Two modes (provide exactly one of `text` / `keys`): * `text`: a literal string. With literal=True (default) it is sent exactly as written via `send-keys -l` (so "C-c" types those three characters). Set literal=False to let tmux interpret key names inside the string. * `keys`: a list of tmux key tokens interpreted by tmux, e.g. ["C-c"], ["Escape"], ["Up", "Up", "Enter"]. `enter=True` appends an Enter keypress after the input — the usual way to "run" a typed command. This is fire-a…
| Parameter | Type | Description |
|---|---|---|
target_pane * | string | The pane to act on, as a tmux target (e.g. "%3" or "sess:1.2"). |
enter | boolean | Append an Enter keypress after the input (i.e. run it). |
keys | tmux key tokens to send, e.g. ["C-c"], ["Up", "Enter"]. | |
literal | boolean | Send text exactly (-l); False lets tmux interpret key names. |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
text | Literal string to type (mutually exclusive with keys). |
tmux_capture_pane
Capture (read) the visible contents and/or scrollback of a pane. This is the primary way to observe output. `start`/`end` select a scrollback line range (-S/-E): negative or "-" for the start of history, e.g. start=-100 grabs the last 100+ lines. `escapes=True` keeps ANSI color/escape sequences (-e). `join=True` rejoins wrapped lines (-J). `trim=True` (default) drops the empty padding lines tmux emits below the last line of real content; set trim=False to keep the raw capture. This is a point-in-time snapshot. To wait for output to appe…
| Parameter | Type | Description |
|---|---|---|
end | Scrollback end line (-E); "-" for the end of history. | |
escapes | boolean | Keep ANSI color/escape sequences (-e). |
join | boolean | Rejoin wrapped lines (-J). |
start | Scrollback start line (-S); negative or "-" for start of history. | |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
target_pane | The pane to act on (e.g. "%3" or "sess:1.2"); defaults to the active pane when omitted. | |
trim | boolean | Drop trailing empty padding lines (default); False keeps raw. |
tmux_wait_for_text
Wait until `pattern` appears in a pane, or `timeout` seconds elapse. `pattern` is a substring by default, or a regular expression when regex=True. `history` optionally includes that many scrollback lines in each check (-S -history). Returns {"matched", "elapsed", "content"} where content is the last capture taken. Caveat: the pane also shows the command you typed, so a pattern can match your own echoed input line rather than the command's output. To wait for a command to *finish* and get just its output, prefer `tmux_run`.
| Parameter | Type | Description |
|---|---|---|
pattern * | string | Text to wait for: a substring, or a regex when regex=True. |
target_pane * | string | The pane to act on, as a tmux target (e.g. "%3" or "sess:1.2"). |
history | Include this many scrollback lines in each check (-S). | |
poll_interval | number | Seconds between capture checks. |
regex | boolean | Treat pattern as a regular expression. |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
timeout | number | Max seconds to wait before giving up. |
tmux_wait_for_idle
Wait until a pane's visible content stops changing. Returns once the capture is unchanged for `idle_seconds` (i.e. output has settled), or after `timeout`. Use this when you don't know the exact completion text; if you do, wait on it with `tmux_wait_for_text`, and to run a command and get just its output + exit code, use `tmux_run`. Returns {"idle", "elapsed", "content"}.
| Parameter | Type | Description |
|---|---|---|
target_pane * | string | The pane to act on, as a tmux target (e.g. "%3" or "sess:1.2"). |
idle_seconds | number | Seconds the content must stay unchanged to count as idle. |
poll_interval | number | Seconds between capture checks. |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
timeout | number | Max seconds to wait before giving up. |
tmux_run
Run a shell command in a pane and return just its output + exit code. Types `command` into the pane bracketed by unique markers, then polls until the command finishes, and returns the text printed between the markers. This is the reliable alternative to send-keys + sleep + capture. Intended for NON-interactive commands at a shell prompt. Returns {"completed", "exit_code", "output", "elapsed"}; on timeout, completed is False and output holds the raw capture so far.
| Parameter | Type | Description |
|---|---|---|
command * | string | Non-interactive shell command to run at the pane's prompt. |
target_pane * | string | The pane to act on, as a tmux target (e.g. "%3" or "sess:1.2"). |
history | integer | Scrollback lines to scan when locating the output markers. |
poll_interval | number | Seconds between capture checks. |
target | Host or named SSH profile from the config to run against; omit (or pass "local") to act on the local machine. | |
timeout | number | Max seconds to wait for the command to finish. |