tmux-mcp

v0.3.3
io.github.fr1sk/tmux-mcp Checked 2 days ago Published 7 months ago

MCP server for tmux — browse sessions, capture output, send commands.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_sessions

List all active tmux sessions. Returns session name, window count, creation time, and attached status. WHEN TO CALL: Call this immediately whenever the user mentions tmux, asks to attach a session, wants to see terminal output, check logs, run a command in a pane, or interact with any running process. Do not answer from memory — always call this tool first to get live state. WORKFLOW: After getting sessions, ask the user which session, call list_windows, ask which window, call list_panes, ask which pane, then call capture_pane.

list_windows

List all windows in a tmux session. Returns window index, name, pane count, and active status. If there is only one window, auto-select it without asking. If multiple, ask the user which window to use.

ParameterTypeDescription
session *stringSession name (from list_sessions)

list_panes

List panes in a tmux target. Pass a session name ('work') or session:window ('work:0'). When only a session name is passed, lists all panes across all windows in that session. Returns pane index, size, active status, and running command. If there is only one pane, auto-select it without asking. If multiple, present them as choices and ask the user which pane to use.

ParameterTypeDescription
target *stringSession name or 'session:window'

capture_pane

Capture current output of a tmux pane. Target format: 'session:window.pane' (e.g. 'work:0.0'). Use list_sessions → list_windows → list_panes to build the target. WARNING: pane output may contain environment variables, API keys, tokens, and credentials — do not call if the pane may contain sensitive data unless the user has confirmed it is safe. AFTER displaying the output, always ask the user what to do next with these options: Refresh (call capture_pane again), Send command (ask what command then call send_keys), Switch pane (restart from list_sessions), Done (stop). Loop until the user…

ParameterTypeDescription
target *stringPane target: 'session:window.pane'
linesintegerLines of scrollback to include (default: 150)

send_keys

Send keys or a command to a tmux pane, then capture its output. Target format: 'session:window.pane'. Use enter=false for raw tmux key sequences like 'C-c', 'Escape', or arrow keys — these are not shell commands and must not have Enter appended. Use enter=true (default) for shell commands. Set wait_ms higher for long-running commands; 0 captures immediately before output appears. WARNING: this executes arbitrary commands in your shell — only use with trusted input.

ParameterTypeDescription
keys *stringCommand or key sequence (tmux notation: 'C-c', 'Escape', 'Up', etc.)
target *stringPane target: 'session:window.pane'
capture_linesintegerLines to capture after sending (default: 50)
enterbooleanPress Enter after keys (default: true). Set false for raw key sequences like C-c, Escape, arrow keys.
wait_msintegerMilliseconds to wait before capturing (default: 400). Set higher for slow commands, 0 to capture immediately.

new_session

Create a new detached tmux session. Before calling, use list_sessions to check whether a session with the requested name already exists.

ParameterTypeDescription
commandstringShell command to run immediately in the first window. WARNING: executes in your shell.
cwdstringWorking directory for the session.
namestringSession name. Omit to let tmux auto-assign one.

new_window

Create a new window in an existing tmux session.

ParameterTypeDescription
session *stringSession name to create the window in.
commandstringShell command to run immediately. WARNING: executes in your shell.
cwdstringWorking directory for the new window.
namestringWindow name.

split_pane

Split a tmux pane horizontally or vertically. 'horizontal' = left/right panes side by side. 'vertical' = top/bottom panes stacked. Target format: 'session:window.pane' or 'session:window'.

ParameterTypeDescription
target *stringTarget pane or window to split: 'session:window.pane'
commandstringShell command to run in the new pane. WARNING: executes in your shell.
cwdstringWorking directory for the new pane.
directionstring'horizontal' splits left/right, 'vertical' splits top/bottom (default: horizontal)
sizeintegerSize of the new pane as a percentage (e.g. 50).

kill_session

Kill a tmux session and all its windows and panes. ALWAYS confirm with the user before calling — this is destructive and cannot be undone.

ParameterTypeDescription
session *stringSession name to kill.

kill_window

Kill a tmux window and all its panes. ALWAYS confirm with the user before calling — this is destructive and cannot be undone. Target format: 'session:window'.

ParameterTypeDescription
target *stringWindow target: 'session:window'

kill_pane

Kill a tmux pane and terminate its running process. ALWAYS confirm with the user before calling — this is destructive and cannot be undone. Target format: 'session:window.pane'.

ParameterTypeDescription
target *stringPane target: 'session:window.pane'

rename_session

Rename an existing tmux session.

ParameterTypeDescription
new_name *stringNew session name.
session *stringCurrent session name.

rename_window

Rename a window in a tmux session. Target format: 'session:window'.

ParameterTypeDescription
new_name *stringNew window name.
target *stringWindow target: 'session:window'

get_config

Returns the current tmux-mcp configuration: whether tmux is installed, the default session name, and whether the agent is configured to always route shell commands through tmux. Call this at the start of any task to check how the agent should behave. If alwaysUseTmux is true, route all shell commands through send_keys in the configured session instead of direct Bash for the remainder of the task.