tmux MCP, built in Swift
tmux terminal control for AI agents, built on libtmux for Swift with its own implementation of the Model Context Protocol. 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
tmux before the first call.
tmux after create_session.
tmux after list_panes: unchanged, the call only reads.
tmux after split_window.
tmux after get_tmux_variables: unchanged, the call only reads.
$ pytest -q .. [100%] 2 passed in 0.00s
tmux after run_shell_command.
$ pytest -q .. [100%] 2 passed in 0.00s
$ cat checks.log 2026-01-01 checks started 2026-01-01 checks finished
tmux after run_shell_command.
tmux after kill_session.
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.
Result
{ "isAttached": false, "id": "$0", "windowCount": 1, "ref": "tmux1_AWXw31wwjyXoEaqBo3la-V4mtPL0vRI4iGVS1yE78h4Y", "createdAt": 1795061804, "name": "checks"}AgentList the panes in the new session.
Result
{ "panes": [ { "currentPath": "/home/user/project", "windowID": "@0", "isActive": true, "isAtTop": true, "isAtBottom": true, "width": 80, "isAtRight": true, "isAtLeft": true, "ref": "tmux1_BGXw31wwjyXoEaqBo3la-V4QetAYfM5JN9hpsAyrKwx3", "height": 24, "currentCommand": "sh", "isDead": false, "…": "4 more" } ]}AgentSplit the pane the list returned (%0) in two.
Result
{ "id": "%1", "height": 24, "isDead": false, "ref": "tmux1_BGXw31wwjyXoEaqBo3la-V6jHcgKRph3CM6YZTGyd4fB", "isAtLeft": false, "isActive": false, "windowID": "@0", "isSynchronized": false, "width": 39, "isAtRight": true, "isAtBottom": true, "modeCount": 0, "…": "4 more"}AgentRead the window's layout through the pane the list returned (%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).
Result
{ "pane": "%0", "droppedLines": 0, "seconds": 0.449415896, "exitStatus": 0, "effectiveTimeout": 30, "paneRef": "tmux1_BGXw31wwjyXoEaqBo3la-V4QetAYfM5JN9hpsAyrKwx3", "linesMissed": false, "output": [ ".. [100%]", "2 passed in 0.00s" ], "timedOut": false}AgentShow the log in the new pane the split returned (%1).
Result
{ "pane": "%1", "effectiveTimeout": 30, "seconds": 0.085019186, "timedOut": false, "droppedLines": 0, "exitStatus": 0, "paneRef": "tmux1_BGXw31wwjyXoEaqBo3la-V6jHcgKRph3CM6YZTGyd4fB", "linesMissed": false, "output": [ "2026-01-01 checks started", "2026-01-01 checks finished" ]}AgentRemove the session once the result is read.
Result
{ "deleted": true, "sessionId": "$0"}pytest printed 2 passed and checks.log ends with checks finished. I removed the checks session.
Install
Choose your client and configuration scope, then run the command or paste the configuration.
$ swift build --product libtmux-mcp$ claude mcp add tmux -- /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp$ claude mcp add tmux --scope user -- /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp$ claude mcp add tmux \
--scope project \
-- /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/.build/debug/libtmux-mcp"
}
}
}$ swift build --product libtmux-mcp$ codex mcp add tmux -- /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp[mcp_servers.tmux]
command = "/absolute/path/to/.build/debug/libtmux-mcp"$ swift build --product libtmux-mcp$ gemini mcp add --scope user tmux /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp$ gemini mcp add --scope project tmux /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/.build/debug/libtmux-mcp"
}
}
}$ swift build --product libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/.build/debug/libtmux-mcp"
}
}
}$ swift build --product libtmux-mcp$ grok mcp add --scope user tmux -- /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp$ grok mcp add --scope project tmux -- /absolute/path/to/.build/debug/libtmux-mcp$ swift build --product libtmux-mcp{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/.build/debug/libtmux-mcp"
}
}
}$ swift build --product libtmux-mcp$ opencode mcp add tmux -- /absolute/path/to/.build/debug/libtmux-mcpWrites ~/.claude.json (this project).
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes ~/.claude.json (all projects).
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes .mcp.json (in repo, version-controlled).
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes ~/.codex/config.toml.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes ~/.gemini/settings.json.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes .gemini/settings.json (in repo).
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes ~/.grok/config.toml.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes ./.grok/config.toml (in repo).
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
Writes ~/.config/opencode/opencode.jsonc.
Nothing publishes this server as a binary yet. The server takes no flags — which tmux it talks to is environment, so the client config is where you say so.
libtmux-mcp is the Swift stdio executable.
LibTmuxMCP
is the SwiftPM library product for embedding the same
tools. They expose tmux discovery, captures, waits, input, configuration,
and process control.
The package requires Swift 6.2 or newer and supports Linux and macOS. The documented Darwin dependency build uses Xcode’s Swift 6.3 toolchain. tmux is required at runtime.
Start here
- Install points an MCP client at this server.
- Tools lists the MCP operations, arguments, and results.
- Guides build the executable and configure its environment.
- Topics explain toolsets, command waits, and capability discovery.
- Examples call a tool, then explore server internals.
- Language API documents embedding and implementation types.
The executable defaults to inspection, management, and execution; a
verified dedicated daemon can also receive teardown tools. The embedding
initializer defaults to inspection alone. Read tmux://capabilities
for the startup selection.
Workspace Manager is a separate library product. The current MCP catalog does not include a workspace-file operation.
Library contract and platform requirements.
Tools by tier
The Swift 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_batchInspect Invoke a serial batch of at most 16 inspect tools. -
capture_paneInspect Return a bounded slice of rendered pane text. -
capture_sinceInspect Return output after an opaque pane cursor. -
find_pane_by_positionInspect Find a pane occupying a named window corner. -
get_pane_infoInspect Return metadata for one pane. -
get_server_infoInspect Return liveness and identity metadata for the selected tmux server. -
get_session_infoInspect Return metadata for one session. -
get_tmux_variablesInspect Resolve validated variable names without accepting raw format syntax. -
get_window_infoInspect Return metadata and placements for one window. -
list_panesInspect List panes, optionally within a session or window. -
list_sessionsInspect List sessions on the selected server. -
list_windowsInspect List windows, optionally within one session. -
search_panesInspect Search bounded pane content for literal text or a regular expression. -
show_environmentInspect Read the tmux environment. -
show_hooksInspect Read configured hooks, optionally for one session. -
show_optionInspect Read one exact tmux option. -
snapshot_paneInspect Return pane metadata and bounded terminal content together. -
wait_for_textInspect Wait within one deadline for pane text.
Manage
Change tmux structure or presentation.
-
move_windowManage Move one window appearance to another session. -
rename_sessionManage Set a literal-safe session name. -
rename_windowManage Set a literal-safe window name. -
resize_paneManage Resize one pane by dimensions or a directional amount. -
resize_windowManage Resize the terminal dimensions reported for one window. -
select_layoutManage Apply a named layout, a unique abbreviation for the running tmux version, or a checksummed saved layout. -
select_paneManage Select one pane as active. -
select_windowManage Select one exact window appearance. -
set_history_limitManage Set the default retained scrollback line limit. -
set_mouse_enabledManage Set the global tmux mouse option through a boolean. -
set_pane_titleManage Set one literal-safe pane title. -
signal_channelManage Signal one tmux wait-for channel. -
swap_paneManage Swap two panes without changing their identities. -
wait_for_channelManage Wait within one deadline for a tmux channel signal.
Execute
Start or drive pane processes, or store state that can control later execution.
-
create_sessionExecute Create a detached session with a configured pane process. -
create_windowExecute Create a window with a configured pane process. -
paste_textExecute Paste literal text and an optional newline target-only after two state checks. -
respawn_paneExecute Restart only the pane's configured process. -
run_shell_commandExecute Run a shell command in a pane with your user's permissions. -
send_keysExecute Send keys after checking the effective synchronized-pane cohort. -
send_keys_batchExecute Send an ordered bounded batch with a fresh check for every row. -
set_synchronize_panesExecute Set the window input default. -
split_windowExecute Create a configured-process pane without accepting command or environment data.
Teardown
Delete tmux objects or retained scrollback. Not reversible.
-
clear_pane_scrollbackTeardown Irreversibly discard retained scrollback for one pane. -
kill_paneTeardown Delete one pane and its running process. -
kill_sessionTeardown Delete one session and every window it owns. -
kill_windowTeardown Delete one window and every pane it owns.
Browse every tool, with its arguments, result and protocol data.