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 Java

tmux terminal control for AI agents, built on libtmux for Java and MCP Java SDK. 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.00s
%1 sh
[checks] 0:sh*

tmux after run_shell_command.

tmux window of 2 panes
%0 sh
$ pytest -q
..
                                  [100%
]
2 passed in 0.00s
%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 {"session_name":"checks"}
Result
{
"id": "$0",
"name": "checks",
"attached": false,
"windows": 1
}

AgentList the panes, each with the session it belongs to.

list_panes Inspect {}
Result
{
"count": 1,
"panes": [
{
"id": "%0",
"session": "checks",
"window": "sh",
"window_id": "@0",
"command": "sh",
"path": "/home/user/project",
"size": "80x24",
"active": true
}
]
}

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

split_window Execute {"pane_id":"%0","direction":"right"}
Result
{
"id": "%1",
"index": 1,
"window_id": "@0",
"session_id": "$0",
"active": true,
"command": "sh",
"path": "/home/user/project",
"title": "host",
"size": "40x24"
}

AgentRead the window's layout through the pane the list returned (%0).

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

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

run_shell_command Execute {"pane_id":"%0","command":"pytest -q"}
Result
{
"pane_id": "%0",
"outcome": "SIGNALLED",
"exit_status": 0,
"output": [
"..",
" [100%",
"]",
"2 passed in 0.00s"
],
"truncated": false,
"lines_dropped": 0,
"framed": true,
"seconds": 0.33,
"effective_timeout": 30
}

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

run_shell_command Execute {"pane_id":"%1","command":"cat checks.log"}
Result
{
"pane_id": "%1",
"outcome": "SIGNALLED",
"exit_status": 0,
"output": [
"2026-01-01 checks started",
"2026-01-01 checks finished"
],
"truncated": false,
"lines_dropped": 0,
"framed": true,
"seconds": 0.01,
"effective_timeout": 30
}

AgentRemove the session by the id the create result returned ($0).

kill_session Teardown {"session_id":"$0"}
Result
{
"kind": "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 concept Maven Central
First
$ ./gradlew :libtmux-mcp:installDist
$ claude mcp add tmux -- /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
$ claude mcp add tmux --scope user -- /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
$ claude mcp add tmux --scope project -- /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/libtmux-mcp"
        }
    }
}
First
$ ./gradlew :libtmux-mcp:installDist
$ codex mcp add tmux -- /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
[mcp_servers.tmux]
command = "/absolute/path/to/libtmux-mcp"
First
$ ./gradlew :libtmux-mcp:installDist
$ gemini mcp add --scope user tmux /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
$ gemini mcp add --scope project tmux /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/libtmux-mcp"
        }
    }
}
First
$ ./gradlew :libtmux-mcp:installDist
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/libtmux-mcp"
        }
    }
}
First
$ ./gradlew :libtmux-mcp:installDist
$ grok mcp add --scope user tmux -- /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
$ grok mcp add --scope project tmux -- /absolute/path/to/libtmux-mcp
First
$ ./gradlew :libtmux-mcp:installDist
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/libtmux-mcp"
        }
    }
}
First
$ ./gradlew :libtmux-mcp:installDist
$ opencode mcp add tmux -- /absolute/path/to/libtmux-mcp

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

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

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

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

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

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

Writes ~/.codex/config.toml.

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

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 build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

Writes ~/.gemini/settings.json.

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

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

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

Writes ~/.grok/config.toml.

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

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

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

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

Nothing publishes this server as a binary yet. The build writes a launcher at libtmux-mcp/build/install/libtmux-mcp/bin/libtmux-mcp; use its absolute path.

io.github.libtmux:libtmux-mcp provides a Java MCP server and a libtmux-mcp application launcher. It discovers tmux objects, captures terminal output, runs framed shell commands, and applies typed topology operations.

Use JDK 21 or newer and tmux. The launcher selects its endpoint and toolsets at startup. It serves MCP over stdin and stdout.

Start here

  • Install points an MCP client at this server.
  • Tools lists the MCP operations, arguments, and results.
  • Guides build the server and connect a client.
  • Topics explain toolsets, input preflight, and wait semantics.
  • Examples call a tool, then explore server internals.
  • Language API documents embedding and implementation types.

The only MCP resource is the static tmux://capabilities report. The server does not register workflow prompts or dynamic resource subscriptions.

The Workspace Manager is a separate Java module. Application code can parse and build declarative workspaces; MCP clients compose the exposed topology tools.

Module documentation.

Tools by tier

The Java 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 Calls up to sixteen eligible inspect tools serially.
  • capture_pane Inspect Returns what a pane shows now, its newest lines first to go when bounded, and a cursor for capture_since.
  • capture_since Inspect Returns only the output a pane produced after a cursor from capture_pane or an earlier capture_since.
  • find_pane_by_position Inspect Finds a pane at one of a window's four corners.
  • get_pane_info Inspect Returns metadata for one pane.
  • get_server_info Inspect Reports whether the pinned server exists and its version.
  • get_session_info Inspect Returns metadata for one session.
  • get_tmux_variables Inspect Reads a capped list of validated tmux variable names, not free-form formats.
  • get_window_info Inspect Returns metadata for one window.
  • list_panes Inspect Lists pane metadata and stable pane IDs.
  • list_sessions Inspect Lists sessions on the pinned tmux server.
  • list_windows Inspect Lists windows, optionally only those in one session, named by ID or by name.
  • search_panes Inspect Searches the visible output of every pane.
  • show_environment Inspect Reads the environment tmux passes to processes.
  • show_hooks Inspect Reads configured tmux hooks.
  • show_option Inspect Reads one named tmux option.
  • snapshot_pane Inspect Returns what a pane shows and its metadata, as list_panes describes a pane, in one call.
  • wait_for_text Inspect Waits for new pane output without accepting executable input.

Manage

Change tmux structure or presentation.

Execute

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

  • create_session Execute Creates a detached session whose first pane runs the configured process.
  • create_window Execute Creates a window whose first pane runs the configured process.
  • paste_text Execute Pastes one literal text block into one target pane through an ephemeral buffer.
  • respawn_pane Execute Kills the pane's current process and starts its configured process again.
  • run_shell_command Execute Runs one authored command in a trusted pane shell and waits for singular framed output and completion.
  • send_keys Execute Sends input to the target's configured effective synchronized cohort without waiting for output.
  • send_keys_batch Execute Sends up to sixty-four ordered pane-input operations, resolving and guarding the configured effective cohort separately for each ordered operation.
  • set_synchronize_panes Execute When enabled, sets the inherited window default.
  • split_window Execute Creates a pane whose configured process starts after the split.

Teardown

Delete tmux objects or retained scrollback. Not reversible.

  • clear_pane_scrollback Teardown Deletes retained scrollback from one pane.
  • kill_pane Teardown Deletes one pane and ends its process.
  • kill_session Teardown Deletes one session and every window and pane in it.
  • kill_window Teardown Deletes one window and every pane in it.

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

Esc
Search in

Type to search.

Reference previewOpen reference