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

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 list_windows: 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
{
"name": "checks",
"session_id": "$0"
}

AgentList the panes, each with its session id.

list_panes Inspect {}
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.

split_window Execute {"paneId":"%0","direction":"horizontal"}
Result
{
"pane_id": "%1"
}

AgentRead the window's layout.

list_windows Inspect {"session":"checks"}
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).

run_shell_command Execute {"paneId":"%0","command":"pytest -q"}
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).

run_shell_command Execute {"paneId":"%1","command":"cat checks.log"}
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.

kill_session Teardown {"session":"checks"}
Result
{
"deleted": true,
"session_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
libtmux-mcp-server Not on a registry yet
First
$ 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
First
$ 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
First
$ 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
First
$ 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"
        }
    }
}
First
$ 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
First
$ 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"
First
$ 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
First
$ 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
First
$ 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"
        }
    }
}
First
$ 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"
        }
    }
}
First
$ 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
First
$ 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
First
$ 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"
        }
    }
}
First
$ 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-server

Writes ~/.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_batch Inspect Run up to sixteen declared inspect operations serially under this one call.
  • capture_pane Inspect Return visible text, or retained history when requested.
  • capture_since Inspect Return bytes after a bounded client cursor and a replacement cursor.
  • find_pane_by_position Inspect Resolve coordinates using fixed tmux layout fields.
  • get_pane_info Inspect Return one pane by stable ID.
  • get_server_info Inspect Report liveness, tmux version, and the resolved socket when running.
  • get_session_info Inspect Return one session by stable ID or name, with the same client_count and attached fields as list_sessions.
  • get_tmux_variables Inspect Expand only validated variable identifiers, never a caller format.
  • get_window_info Inspect Return one window by stable ID.
  • list_panes Inspect List every pane with stable pane, window, and session IDs.
  • list_sessions Inspect List session IDs, names, paths, window counts, and client counts.
  • list_windows Inspect List windows through an exact owning session.
  • search_panes Inspect Search captured lines using a length-limited expression.
  • show_environment Inspect Read global or session environment values.
  • show_hooks Inspect Read configured hooks, optionally filtered by exact name.
  • show_option Inspect Read one exact option without accepting an option value.
  • snapshot_pane Inspect Return pane metadata and visible terminal content from one call.
  • wait_for_text Inspect Discount this server's pending input and recent submitted echoes.

Manage

Change tmux structure or presentation.

Execute

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

  • create_session Execute Create a detached session.
  • create_window Execute Create a detached window.
  • paste_text Execute 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_pane Execute Restart only the pane's configured process.
  • run_shell_command Execute Require one live configured pane, outside human-owned mode and running a supported POSIX foreground shell.
  • send_keys Execute Require every configured synchronized pane to be live and outside human-owned mode, then send one validated tmux key name.
  • send_keys_batch Execute 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_panes Execute Set the inherited window synchronize-panes default.
  • split_window Execute Create a configured-process pane.

Teardown

Delete tmux objects or retained scrollback. Not reversible.

  • clear_pane_scrollback Teardown Irreversibly discard retained scrollback for one pane.
  • kill_pane Teardown Delete one pane and its running process.
  • kill_session Teardown Delete one session and every window it owns.
  • kill_window Teardown Delete one window and every pane it owns.

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

Esc
Search in

Type to search.

Reference previewOpen reference