| Crates.io | tmux-mcp-rs |
| lib.rs | tmux-mcp-rs |
| version | 0.1.0 |
| created_at | 2026-01-24 12:28:06.201168+00 |
| updated_at | 2026-01-24 12:28:06.201168+00 |
| description | Tmux MCP server in Rust |
| homepage | https://github.com/bnomei/tmux-mcp |
| repository | https://github.com/bnomei/tmux-mcp |
| max_upload_size | |
| id | 2066604 |
| size | 371,784 |
A Model Context Protocol (MCP) server for tmux, written in Rust. It lets AI assistants create sessions, split panes, run commands, and capture output.
Requires tmux installed and available on PATH.
[!WARNING] Using this MCP allows the agent to escape the sandbox and its security limitations. Here be dragons!
cargo install tmux-mcp-rs
brew install bnomei/tmux-mcp/tmux-mcp-rs
npm install -g @bnomei/tmux-mcp-rs
npx -y @bnomei/tmux-mcp-rs@latest
# Claude Code
claude mcp add --transport stdio tmux -- tmux-mcp-rs
# Codex CLI
codex mcp add tmux -- tmux-mcp-rs
# OpenCode (interactive)
opencode mcp add
# Amp (non-workspace)
amp mcp add tmux -- tmux-mcp-rs
{
"mcpServers": {
"tmux": {
"command": "tmux-mcp-rs"
}
}
}
tmux attach -t <session>
Add the Quick Start snippet to your MCP client config. Example below includes all supported args (remove the ones you don't need):
{
"mcpServers": {
"tmux": {
"command": "tmux-mcp-rs",
"args": [
"--shell-type",
"zsh",
"--socket",
"/path/to/tmux.sock",
"--ssh",
"user@host",
"--config",
"/path/to/config.toml"
]
}
}
}
These patterns mirror how CLI agents like Codex can structure tmux work. Each is backed by an integration test in tests/integration.rs (run with TMUX_MCP_INTEGRATION=1).
ID-first targeting: Use window/pane IDs for operations when names collide. Tools: list-windows/list-panes, rename-window. Test: test_workflow_id_first_targeting.
Task-per-session layout: Create a session per task, add windows for build/test/docs, and split panes for runners/logs. Tools: create-session, create-window, split-pane, rename-pane, list-windows, list-panes. Test: test_workflow_task_per_session_layout.
Stateful shell context: Set environment/state in a pane and reuse it across commands. Tools: send-keys, capture-pane. Test: test_workflow_stateful_shell_context.
Continuous output pane: Run a long command and poll capture-pane to summarize progress without losing terminal state. Tools: send-keys, capture-pane. Test: test_workflow_continuous_output_capture.
Interactive prompt automation: Drive a blocking prompt (or simple TUI) by sending responses via keys, then capture the result. Tools: send-keys, capture-pane. Test: test_workflow_interactive_prompt.
Interactive interrupts: Cancel long-running commands and end stdin streams with EOF. Tools: send-cancel, send-eof, capture-pane. Test: test_workflow_interactive_interrupts.
Synchronized panes broadcast: Fan out a command to multiple panes at once using synchronize-panes. Tools: set-synchronize-panes, send-keys, capture-pane. Test: test_workflow_synchronized_panes_broadcast.
Buffer handoff: Stash output in buffers, save to disk, and delete when done. Tools: list-buffers, show-buffer, save-buffer, delete-buffer. Test: test_workflow_buffer_roundtrip.
Pane rearrangements: Swap/break/join panes and apply layouts while preserving pane identities. Tools: split-pane, select-layout, swap-pane, break-pane, join-pane, list-panes, list-windows. Test: test_workflow_pane_rearrangements.
Metadata + zoom: Rename session/window/pane and inspect pane/window metadata; toggle zoom and resize. Tools: rename-session, rename-window, rename-pane, zoom-pane, resize-pane. Resources: tmux://pane/{paneId}/info, tmux://window/{windowId}/info. Test: test_workflow_metadata_and_zoom.
Audit-ready context bundle: Pair tracked command output with raw pane capture for traceability. Tools: execute-command, get-command-result, capture-pane. Test: test_workflow_audit_context_bundle.
Agent orchestration: Run parallel commands across windows/panes with log monitoring. Tools: create-window, split-pane, execute-command, send-keys, capture-pane. Test: test_workflow_agent_orchestration.
| Option | Description | Default |
|---|---|---|
--shell-type <SHELL> |
Shell to use (bash, zsh, fish) | bash |
--socket <PATH> |
Path to tmux server socket (recommend per-agent isolated socket id) | Default server (if unset) |
--ssh <CONNECTION> |
Run tmux over SSH (options + destination, destination last) | None |
--config <PATH> |
Path to TOML configuration file | None |
Environment variables: TMUX_MCP_SOCKET can also set the socket path (recommend per-agent isolated socket id). TMUX_MCP_SSH can set the SSH connection string.
[shell]
type = "zsh"
[ssh]
remote = "user@host"
[security]
enabled = true
allow_execute_command = true
[security.command_filter]
mode = "off" # off | allowlist | denylist
patterns = []
The server exposes the following MCP resources:
| URI | Description |
|---|---|
tmux://server/info |
Default socket and SSH context for routing tool calls |
tmux://pane/{paneId} |
Content of a specific pane (last 200 lines) |
tmux://pane/{paneId}/info |
Metadata for a specific pane |
tmux://pane/{paneId}/tail/{lines} |
Tail N lines from a pane |
tmux://pane/{paneId}/tail/{lines}/ansi |
Tail N lines with ANSI colors |
tmux://window/{windowId}/info |
Metadata for a window |
tmux://session/{sessionId}/tree |
Session + windows + panes snapshot |
tmux://clients |
List tmux clients |
tmux://command/{commandId}/result |
Status and output of a tracked command |
Resources are dynamically enumerated - the server lists available panes, windows, sessions, clients, and active commands.
Use --ssh to control a tmux server on another machine. Make sure SSH authentication is non-interactive (e.g. agent or keys).
tmux-mcp-rs --ssh "user@host"
For extra SSH options, put them before the host (e.g. --ssh "-i ~/.ssh/key user@host") or use ~/.ssh/config. The destination should be the last token in the --ssh string.
Create a dedicated tmux server on the remote host, then point the MCP server at that socket:
# On the remote host (once):
ssh user@host 'tmux -S /tmp/ai-agent.sock -f /dev/null new-session -d -s workspace'
# Locally:
tmux-mcp-rs --ssh "user@host" --socket /tmp/ai-agent.sock
Use --socket or TMUX_MCP_SOCKET to point the MCP server at a specific tmux server socket.
# Connect to a specific socket id
tmux-mcp-rs --socket /tmp/tmux-mcp-<agent-id>.sock
# Or via environment variable
TMUX_MCP_SOCKET=/tmp/tmux-mcp-<agent-id>.sock tmux-mcp-rs
If you want to pre-create an isolated tmux server for the agent:
tmux -S /tmp/ai-agent.sock -f /dev/null new-session -d -s workspace
TMUX_MCP_SOCKET=/tmp/ai-agent.sock tmux-mcp-rs
Unit tests (no tmux required):
cargo test --lib
Integration tests (requires tmux installed):
# Install tmux if needed
# macOS: brew install tmux
# Ubuntu: sudo apt-get install tmux
# Run integration tests (uses isolated tmux server)
TMUX_MCP_INTEGRATION=1 cargo test --test integration
Integration tests create an isolated tmux server using a temp socket, so they won't affect your running tmux sessions.
By default, the security policy is permissive to avoid breaking agent workflows:
security.enabled = true, but all allow_* flags are truecommand_filter.mode = "off" (no allow/deny patterns)allowed_sockets/sessions/panes are unset (no scoping)Denylist behavior: when command_filter.mode = "denylist", any regex in
security.command_filter.patterns that matches a command string will block that
command. This applies to execute-command and non-literal send-keys only.
To harden a deployment, flip specific allow_* flags, add deny/allow patterns,
or restrict sockets/sessions/panes explicitly.
MIT License - see LICENSE for details.