tmux MCP, built in C++
tmux terminal control for AI agents, built on libtmux for C++ 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 list_windows: unchanged, the call only reads.
$ pytest -q .. [100%] 2 passed in 0.01s
tmux after run_shell_command.
$ pytest -q .. [100%] 2 passed in 0.01s
$ 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
{ "name": "checks", "session_id": "$0"}AgentList the panes, each with its session id.
Result
{ "panes": [ { "active": true, "command": "sh", "dead": false, "height": 24, "id": "%0", "index": 0, "path": "/home/user/project", "pid": 3564863, "session_id": "$0", "title": "host", "width": 80, "window_id": "@0" } ]}AgentSplit the pane the list returned (%0) in two.
Result
{ "pane_id": "%1"}AgentRead the window's layout.
Result
{ "windows": [ { "active": true, "height": 24, "id": "@0", "index": 0, "layout": "8205,80x24,0,0{40x24,0,0,0,39x24,41,0,1}", "name": "sh", "pane_count": 2, "session_id": "$0", "width": 80 } ]}AgentRun the tests in the pane the list returned (%0).
Result
{ "exit_code": 0, "pane_id": "%0", "text": ".. [100%]\n2 passed in 0.01s\n"}AgentShow the log in the new pane the split returned (%1).
Result
{ "exit_code": 0, "pane_id": "%1", "text": "2026-01-01 checks started\n2026-01-01 checks finished\n"}AgentRemove the session once the result is read.
Result
{ "deleted": true, "session_id": "$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.
$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ claude mcp add tmux -- /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ claude mcp add tmux --scope user -- /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ claude mcp add tmux --scope project -- /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/libtmux-mcp-server"
}
}
}$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ codex mcp add tmux -- /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local[mcp_servers.tmux]
command = "/absolute/path/to/libtmux-mcp-server"$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ gemini mcp add --scope user tmux /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ gemini mcp add --scope project tmux /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/libtmux-mcp-server"
}
}
}$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/libtmux-mcp-server"
}
}
}$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ grok mcp add --scope user tmux -- /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ grok mcp add --scope project tmux -- /absolute/path/to/libtmux-mcp-server$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local{
"mcpServers": {
"tmux": {
"command": "/absolute/path/to/libtmux-mcp-server"
}
}
}$ cmake \
-S . \
-B build/mcp \
-DLIBTMUX_BUILD_MCP_SERVER=ON \
-DLIBTMUX_FETCH_DEPS=ON && \
cmake --build build/mcp && \
cmake --install build/mcp --prefix ~/.local$ opencode mcp add tmux -- /absolute/path/to/libtmux-mcp-serverWrites ~/.claude.json (this project).
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes ~/.claude.json (all projects).
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes .mcp.json (in repo, version-controlled).
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes ~/.codex/config.toml.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes ~/.gemini/settings.json.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes .gemini/settings.json (in repo).
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes ~/.grok/config.toml.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes ./.grok/config.toml (in repo).
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
Writes ~/.config/opencode/opencode.jsonc.
The MCP server is a build option rather than a second package, off by default because it is the only component that needs the JSON dependency. The install above puts libtmux-mcp-server in ~/.local/bin; use its full path.
libtmux-mcp-server is a native executable that exposes tmux through
MCP over standard input and output. It is an optional consumer of the C++
library, enabled separately in the CMake build.
The catalog exposes discovery, creation, capture, input, search, and bounded text waits. Native Windows advertises the same catalog, with unsupported psmux operations failing explicitly at dispatch.
Start here
- Install points an MCP client at this server.
- Tools lists the MCP operations, arguments, and results.
- Guides build the executable and select an endpoint.
- Topics explain platform coverage, identifiers, and failures.
- Examples call a tool, then explore server internals.
- Language API documents embedding and implementation types.
Toolsets and exact tool names select the startup surface. The static
tmux://capabilities resource reports it; workflow prompts and dynamic
resource templates are absent.
The Workspace Manager is another source consumer. Its configuration types are not part of the installed core API, and the MCP server does not include a workspace-file operation.
Executable and platform contract.
Tools by tier
The C++ 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 Run up to sixteen declared inspect operations serially under this one call. -
capture_paneInspect Return visible text, or retained history when requested. -
capture_sinceInspect Return bytes after a bounded client cursor and a replacement cursor. -
find_pane_by_positionInspect Resolve coordinates using fixed tmux layout fields. -
get_pane_infoInspect Return one pane by stable ID. -
get_server_infoInspect Report liveness, tmux version, and the resolved socket when running. -
get_session_infoInspect Return one session by stable ID or name, with the same client_count and attached fields as list_sessions. -
get_tmux_variablesInspect Expand only validated variable identifiers, never a caller format. -
get_window_infoInspect Return one window by stable ID. -
list_panesInspect List every pane with stable pane, window, and session IDs. -
list_sessionsInspect List session IDs, names, paths, window counts, and client counts. -
list_windowsInspect List windows through an exact owning session. -
search_panesInspect Search captured lines using a length-limited expression. -
show_environmentInspect Read global or session environment values. -
show_hooksInspect Read configured hooks, optionally filtered by exact name. -
show_optionInspect Read one exact option without accepting an option value. -
snapshot_paneInspect Return pane metadata and visible terminal content from one call. -
wait_for_textInspect Discount this server's pending input and recent submitted echoes.
Manage
Change tmux structure or presentation.
-
move_windowManage Move a window to an exact index in its owning session. -
rename_sessionManage Replace one session name. -
rename_windowManage Replace one window name. -
resize_paneManage Replace one or both pane dimensions. -
resize_windowManage Replace one window's dimensions. -
select_layoutManage Replace the pane layout of one window. -
select_paneManage Make one pane active. -
select_windowManage Make one window active. -
set_history_limitManage Replace retained-history bounds with a non-negative integer. -
set_mouse_enabledManage Replace the global mouse option with a typed boolean. -
set_pane_titleManage Replace one pane title. -
signal_channelManage Release or latch one named server-side channel. -
swap_paneManage Exchange two pane positions without changing their IDs. -
wait_for_channelManage Wait for a named server-side channel with an optional deadline.
Execute
Start or drive pane processes, or store state that can control later execution.
-
create_sessionExecute Create a detached session. -
create_windowExecute Create a detached window. -
paste_textExecute Require the target pane to be live and outside human-owned mode, then stage a private target-only buffer, optionally append Enter, paste it once, and verify cleanup. -
respawn_paneExecute Restart only the pane's configured process. -
run_shell_commandExecute Require one live configured pane, outside human-owned mode and running a supported POSIX foreground shell. -
send_keysExecute Require every configured synchronized pane to be live and outside human-owned mode, then send one validated tmux key name. -
send_keys_batchExecute Preflight each row's configured synchronized pane cohort independently, requiring every pane to be live and outside human-owned mode before its text or key and optional Enter. -
set_synchronize_panesExecute Set the inherited window synchronize-panes default. -
split_windowExecute Create a configured-process pane.
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.