Skip to main content
Glama

tmux-mcp

MCP server that gives AI assistants full visibility into your tmux sessions — browse sessions, windows, and panes, read terminal output, and send commands.

Watch your AI agent work in real-time. Enable TMUX_MCP_ALWAYS_USE to force every shell command through a named tmux session instead of direct Bash — every command your AI runs appears live in your terminal, fully auditable.

Works with Claude Code, OpenCode, Cursor, Windsurf, and any MCP-compatible host.

What it can do

Read your terminal state

  • List every active tmux session with window count, creation time, and attached status

  • List windows inside a session — index, name, pane count, which one is active

  • List panes inside a window — size, running command, which one is active

See what's on screen

  • Capture the visible output of any pane — up to 5 000 lines of scrollback

  • Read logs, compiler errors, server output, test runs — anything in your terminal

Create and organise

  • Create sessions, windows, and panes with a working directory and an initial command

  • Split panes horizontally or vertically

  • Rename sessions and windows for reliable targeting

Clean up

  • Kill sessions, windows, or individual panes

Control panes

  • Send shell commands to any pane and immediately read the output

  • Send raw key sequences: C-c to interrupt, Escape to exit, arrow keys, etc.

  • Configurable wait time before capturing so long-running commands have time to finish

Error-safe

  • Bad target? No tmux server? Returns a readable error message instead of crashing

Related MCP server: Ryan's Tmux MCP Server

Tools

list_sessions

Lists all active tmux sessions. No parameters.

Returns: session name, number of windows, creation time, attached/detached status.

list_windows

Lists windows inside a session.

Parameter

Type

Description

session

string

Session name (from list_sessions)

Returns: window index, name, pane count, whether it's the active window.

list_panes

Lists panes inside a session or window.

Parameter

Type

Description

target

string

Session name (work) or session:window (work:0)

Returns: pane index, title, dimensions (e.g. 220x50), whether it's active, running command.

capture_pane

Captures the current terminal output of a pane.

Parameter

Type

Default

Description

target

string

—

Pane target: session:window.pane (e.g. work:0.0)

lines

number

150

Lines of scrollback to include (max 5000)

Returns: raw terminal text as it appears on screen.

Security note: pane output can contain environment variables, API keys, tokens, and credentials if they were printed to the terminal. Only use this server in trusted local environments.

send_keys

Sends a command or key sequence to a pane and captures the result.

Parameter

Type

Default

Description

target

string

—

Pane target: session:window.pane

keys

string

—

Command or tmux key notation (C-c, Escape, Up, etc.)

enter

boolean

true

Press Enter after the keys

capture_lines

number

50

Lines to capture after sending

wait_ms

number

400

Milliseconds to wait before capturing

Returns: confirmation + pane output after the command ran.

new_session

Creates a new detached tmux session.

Parameter

Type

Description

name

string

Session name. Omit to let tmux auto-assign one.

cwd

string

Working directory for the session.

command

string

Shell command to run immediately in the first window.

new_window

Creates a new window inside an existing session.

Parameter

Type

Description

session

string

Session to create the window in.

name

string

Window name.

cwd

string

Working directory for the new window.

command

string

Shell command to run immediately.

split_pane

Splits a pane into two.

Parameter

Type

Default

Description

target

string

—

Pane or window to split: session:window.pane

direction

horizontal | vertical

horizontal

horizontal = left/right split, vertical = top/bottom

cwd

string

—

Working directory for the new pane.

command

string

—

Shell command to run in the new pane.

size

number

—

Size of the new pane as a percentage (1–99).

kill_session

Kills a session and all its windows and panes. Destructive — cannot be undone.

Parameter

Type

Description

session

string

Session name to kill.

kill_window

Kills a window and all its panes. Destructive.

Parameter

Type

Description

target

string

Window target: session:window

kill_pane

Kills a single pane and its running process. Destructive.

Parameter

Type

Description

target

string

Pane target: session:window.pane

rename_session

Parameter

Type

Description

session

string

Current session name.

new_name

string

New name.

rename_window

Parameter

Type

Description

target

string

Window target: session:window

new_name

string

New name.

Target format

All tools use tmux's standard session:window.pane notation:

work           →  session named "work"
work:0         →  window 0 of session "work"
work:0.0       →  pane 0, window 0, session "work"
work:editor.1  →  pane 1 of window named "editor" in session "work"

Use list_sessions → list_windows → list_panes to discover the right target before calling capture_pane or send_keys.

Install

npm install -g @fr1sk/tmux-mcp

Configure

OpenCode (~/.config/opencode/opencode.json)

{
  "mcp": {
    "tmux": {
      "type": "local",
      "command": ["tmux-mcp"]
    }
  }
}

Claude Code (~/.claude/settings.json)

{
  "mcpServers": {
    "tmux": {
      "command": "tmux-mcp"
    }
  }
}

Cursor / Windsurf (mcp.json)

{
  "mcpServers": {
    "tmux": {
      "command": "tmux-mcp"
    }
  }
}

Usage examples

What tmux sessions do I have running?
Show me the output of my dev server — it's in the work session
My tests are failing, check what's in work:1.0
Run git status in my work session and show me the output
Send Ctrl-C to work:0.0, the process is stuck
Tail the last 300 lines from the logs pane in my api session
Create a new session called 'dev' in ~/Projects/myapp and run npm run dev
Split work:0.0 vertically and run npm test in the new pane
Rename session 'new' to 'api'
Kill the old session named 'temp'

Environment variables

Set these in your MCP client config under environment to control agent behavior.

Variable

Default

Description

TMUX_MCP_DEFAULT_SESSION

—

Session name the agent routes commands to when alwaysUseTmux is on

TMUX_MCP_ALWAYS_USE

false

Set to "true" to route all shell commands through tmux instead of direct Bash

When both are set, the get_config tool returns an instructions field the agent uses to automatically route every shell command through send_keys in the configured session.

Example (OpenCode):

{
  "mcp": {
    "tmux": {
      "type": "local",
      "command": ["tmux-mcp"],
      "environment": {
        "TMUX_MCP_ALWAYS_USE": "true",
        "TMUX_MCP_DEFAULT_SESSION": "dev"
      }
    }
  }
}

Security

This server provides unrestricted local shell access through tmux:

  • capture_pane — returns raw terminal output, which may include environment variables, API keys, tokens, database passwords, and SSH private keys if they were printed to the terminal.

  • send_keys — executes arbitrary shell commands in the target pane. Any command the AI sends runs in your shell with your permissions.

  • command parameter on new_session, new_window, and split_pane — passed directly to tmux, which runs it via $SHELL -c. No validation or sandboxing.

Only use this server in trusted local development environments. Never expose it to network-accessible MCP hosts or untrusted AI assistants.

Requirements

  • Node.js 18+

  • tmux on $PATH

Available Tools

14 tools
capture_paneA

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 picks Done.

Inputs: target (required), lines.

get_configA

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.

Inputs: no named parameters.

kill_paneA

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'.

Inputs: target (required).

kill_sessionA

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

Inputs: session (required).

kill_windowA

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'.

Inputs: target (required).

list_panesA

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.

Inputs: target (required).

list_sessionsA

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.

Inputs: no named parameters.

list_windowsA

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.

Inputs: session (required).

new_sessionA

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

Inputs: cwd, name, command.

new_windowB

Create a new window in an existing tmux session.

Inputs: session (required), cwd, name, command.

rename_sessionB

Rename an existing tmux session.

Inputs: session (required), new_name (required).

rename_windowA

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

Inputs: target (required), new_name (required).

send_keysA

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.

Inputs: keys (required), target (required), enter, wait_ms, +1 more.

split_paneA

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'.

Inputs: target (required), cwd, size, command, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 14 tools

    Disambiguation5/5

    Each tool targets a distinct tmux resource (session, window, pane) or action (list, capture, send, create, kill, rename). No overlapping purposes; even similar operations are clearly separated by resource type.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun snake_case pattern (e.g., list_sessions, kill_pane, rename_window). Verbs are appropriate and uniform, with no mixed naming styles.

    Tool Count5/5

    14 tools is well-scoped for a tmux server. It covers the core lifecycle of sessions, windows, and panes without excess or shortage.

    Completeness4/5

    The set covers essential operations: listing, creating, killing, renaming, capturing output, and sending keys. Minor gaps exist (e.g., no pane resizing or moving), but the core workflow is complete.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      A comprehensive MCP server for driving tmux sessions, windows, panes, sending keystrokes, and reading pane output locally or over SSH, enabling real-time collaborative pairing with AI.
      71
      20 PyPI
      6
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      MCP server for tmux enabling AI assistants to manage tmux sessions, windows, panes, layouts, and execute commands securely through natural language. Supports multiple profiles including read-only and full tool sets.
      22
      2
      MIT