MCPconceptHome

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice

Concept example A working example of the core library. It can change without notice. What concept means

Edit this page on GitHub

tmux MCP, built in Rust

tmux terminal control for AI agents, built on libtmux for Rust and rmcp. This server maps tmux's object hierarchy — sessions, windows, panes — into MCP tools grouped by the operation they request. The server enforces the selected groups at the MCP tool boundary.

tmux through MCP

Replay Hover a call to preview the tmux state after it. Use its pin button to hold it. With the replay focused, the arrow keys, Home and End step through the calls.

tmux before the first call.

tmux window of 1 pane
%0 sh
[checks] 0:sh*

tmux after create_session.

tmux window of 1 pane
%0 sh
[checks] 0:sh*

tmux after list_panes: unchanged, the call only reads.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after split_window.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after get_tmux_variables: unchanged, the call only reads.

tmux window of 2 panes
%0 sh
$ pytest -q
..                               [100%]
2 passed in 0.01s
%1 sh
[checks] 0:sh*

tmux after run_shell_command.

tmux window of 2 panes
%0 sh
$ pytest -q
..                               [100%]
2 passed in 0.01s
%1 sh
$ cat checks.log
2026-01-01 checks started
2026-01-01 checks finished
[checks] 0:sh*

tmux after run_shell_command.

No sessions

tmux after kill_session.

You

Create a tmux session called checks, split its window into two panes, run pytest -q in one and show checks.log in the other, show me the results, then remove the session.

AgentCreate the session.

create_session Execute {"name":"checks"}
Result
{
"attached": false,
"id": "$0",
"name": "checks",
"windows": 1
}

AgentList the panes, each with its window id.

list_panes Inspect {}
Result
{
"panes": [
{
"active": true,
"caller": "unknown",
"command": "sh",
"id": "%0",
"path": "/home/user/project",
"window_id": "@0"
}
]
}

AgentSplit the pane the list returned (%0) in two.

split_window Execute {"pane":"%0","direction":"right"}
Result
{
"active": false,
"caller": "unknown",
"command": "sh",
"id": "%1",
"path": "/home/user/project",
"window_id": "@0"
}

AgentRead the window's layout, which tmux calls window_layout, through the pane the list returned (%0).

get_tmux_variables Inspect {"names":["window_layout"],"pane":"%0"}
Result
{
"values": {
"window_layout": "8205,80x24,0,0{40x24,0,0,0,39x24,41,0,1}"
}
}

AgentRun the tests in the pane the list returned (%0).

run_shell_command Execute {"pane":"%0","command":"pytest -q"}
Result
{
"bytes": 320,
"exit_status": 0,
"outcome": "completed",
"output": ".. [100%]\n2 passed in 0.01s\n",
"pane": "%0",
"truncated": false
}

AgentShow the log in the new pane the split returned (%1).

run_shell_command Execute {"pane":"%1","command":"cat checks.log"}
Result
{
"bytes": 257,
"exit_status": 0,
"outcome": "completed",
"output": "2026-01-01 checks started\n2026-01-01 checks finished\n",
"pane": "%1",
"truncated": false
}

AgentRemove the session once the result is read.

kill_session Teardown {"session":"checks"}
Result
{
"id": "$0"
}
Agent

pytest printed 2 passed and checks.log ends with checks finished. I removed the checks session.

1/7

Install

Choose your client and configuration scope, then run the command or paste the configuration.

Terminal
Terminal
Terminal
claude_desktop_config.json
Terminal
.codex/config.toml
Terminal
Terminal
.cursor/mcp.json
~/.cursor/mcp.json
Terminal
Terminal
~/.gemini/config/mcp_config.json
Terminal
tmux-mcp concept crates.io
First
$ cargo install tmux-mcp
$ claude mcp add tmux -- tmux-mcp
First
$ cargo install tmux-mcp
$ claude mcp add tmux --scope user -- tmux-mcp
First
$ cargo install tmux-mcp
$ claude mcp add tmux --scope project -- tmux-mcp
First
$ cargo install tmux-mcp
{
    "mcpServers": {
        "tmux": {
            "command": "tmux-mcp"
        }
    }
}
First
$ cargo install tmux-mcp
$ codex mcp add tmux -- tmux-mcp
First
$ cargo install tmux-mcp
[mcp_servers.tmux]
command = "tmux-mcp"
First
$ cargo install tmux-mcp
$ gemini mcp add --scope user tmux tmux-mcp
First
$ cargo install tmux-mcp
$ gemini mcp add --scope project tmux tmux-mcp
First
$ cargo install tmux-mcp
{
    "mcpServers": {
        "tmux": {
            "command": "tmux-mcp"
        }
    }
}
First
$ cargo install tmux-mcp
{
    "mcpServers": {
        "tmux": {
            "command": "tmux-mcp"
        }
    }
}
First
$ cargo install tmux-mcp
$ grok mcp add --scope user tmux -- tmux-mcp
First
$ cargo install tmux-mcp
$ grok mcp add --scope project tmux -- tmux-mcp
First
$ cargo install tmux-mcp
{
    "mcpServers": {
        "tmux": {
            "command": "tmux-mcp"
        }
    }
}
First
$ cargo install tmux-mcp
$ opencode mcp add tmux -- tmux-mcp

Writes ~/.claude.json (this project).

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes ~/.claude.json (all projects).

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes .mcp.json (in repo, version-controlled).

The installed tmux-mcp binary speaks MCP on stdin and stdout.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes ~/.codex/config.toml.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes ~/.gemini/settings.json.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes .gemini/settings.json (in repo).

The installed tmux-mcp binary speaks MCP on stdin and stdout.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes ~/.grok/config.toml.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes ./.grok/config.toml (in repo).

The installed tmux-mcp binary speaks MCP on stdin and stdout.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

Writes ~/.config/opencode/opencode.jsonc.

The installed tmux-mcp binary speaks MCP on stdin and stdout.

tmux-mcp serves tmux over MCP stdio. It provides topology discovery, terminal capture, command execution, bounded waits, and a static capability resource.

Building requires Rust 1.88 or newer. Running requires tmux 3.3a or newer. A daemon older than 3.3a is refused before any effect; see tmux support. Toolsets select inspection, management, execution, and teardown. Read tmux://capabilities for the effective startup selection.

Start here

  • Install points an MCP client at this server.
  • Tools lists the MCP operations, arguments, and results.
  • Guides connect a client and choose its tmux socket.
  • Topics explain toolsets, command waits, and capability discovery.
  • Examples run a Rust MCP client with a private tmux server.
  • Language API documents embedding and implementation types.

The Rust Workspace Manager is a separate crate. The current MCP catalog does not include a workspace-file operation.

Crate documentation and prerequisites.

Tools by tier

The Rust server groups its tools by what they request. A tier badge tells you how far a call reaches before you approve it. Set LIBTMUX_TOOLSETS to a comma-separated list of tiers, such as inspect,manage, to offer only those tools.

Inspect

Request tmux state and terminal output.

  • call_read_tools_batch Inspect Call a serial batch of at most sixteen enabled inspect tools.
  • capture_pane Inspect Read a pane's contents.
  • capture_since Inspect Read what a pane wrote since the previous call.
  • find_pane_by_position Inspect Find the pane touching a named window corner.
  • get_pane_info Inspect Return metadata for one pane.
  • get_server_info Inspect Report every session with its windows and panes, in one call.
  • get_session_info Inspect Return metadata for one session.
  • get_tmux_variables Inspect Read a bounded set of tmux variables against one pane.
  • get_window_info Inspect Return metadata for one window.
  • list_panes Inspect List every pane on the server.
  • list_sessions Inspect List every tmux session on the server.
  • list_windows Inspect List every window on the server.
  • search_panes Inspect Search what panes are displaying with Rust's linear-time regex engine.
  • show_environment Inspect List the variables tmux hands to processes it starts, for the server or for one session, and whether each is set or marked for removal.
  • show_hooks Inspect List the hooks tmux runs when something happens on the server, such as a pane exiting.
  • show_option Inspect Read a tmux option, such as history-limit or a user option like @theme.
  • snapshot_pane Inspect Read pane content with cursor position, mode state, and scroll position in one reply.
  • wait_for_text Inspect Wait until a pane writes matching text.

Manage

Change tmux structure or presentation.

  • move_window Manage Move one window to a session and index.
  • rename_session Manage Rename one session.
  • rename_window Manage Rename one window.
  • resize_pane Manage Move one edge of a pane by a number of rows or columns.
  • resize_window Manage Resize one window to exact cell dimensions.
  • select_layout Manage Rearrange a window's panes using a saved tmux layout or a named layout and its unique abbreviation.
  • select_pane Manage Select a pane, making it its window's active pane.
  • select_window Manage Select a window, making it its session's active window.
  • set_mouse_enabled Manage Set mouse handling for a session or the global session default.
  • set_pane_title Manage Set one pane's title.
  • signal_channel Manage Signal a tmux wait-for channel, releasing every current waiter.
  • swap_pane Manage Swap the positions of two panes.
  • wait_for_channel Manage Block until something signals a tmux wait-for channel.

Execute

Start or drive pane processes, or store state that can control later execution.

  • create_session Execute Create a new detached tmux session.
  • create_window Execute Create a window running its configured process.
  • paste_text Execute Put text into a pane through a tmux paste buffer instead of typing it key by key.
  • respawn_pane Execute Restart a pane's configured process with no command payload.
  • run_shell_command Execute Run a shell command in a pane, wait for it to finish, and report its exit status with retained output.
  • send_keys Execute Type text into a pane, press named keys in it, or both.
  • send_keys_batch Execute Send an ordered batch of input operations to panes.
  • set_synchronize_panes Execute Set the window default for synchronized pane input.
  • split_window Execute Split a window and start the configured process with no command payload.

Teardown

Delete tmux objects or retained scrollback. Not reversible.

Browse every tool, with its arguments, result and protocol data.

Esc
Search in

Type to search.

Reference previewOpen reference