MCPconceptHome

Choose documentation 3

latest

Current version

latest
English

Unreleased LibTmux has not been released. Its API may change during development. 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 Julia

tmux terminal control for AI agents, built on libtmux for Julia and ModelContextProtocol.jl. This server maps tmux's object hierarchy — sessions, windows, panes — into MCP tools. It offers only the tools selected when it starts.

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 window of 1 pane
%0 cat
[docs] 0:cat*

tmux before the first call.

tmux window of 1 pane
%1 sh
[checks] 0:sh*

tmux after create_session.

tmux window of 2 panes
%1 sh
%2 sh
[checks] 0:sh*

tmux after send_keys.

tmux window of 2 panes
%1 sh
%2 sh
[checks] 0:sh*

tmux after list_panes: unchanged, the call only reads.

tmux window of 2 panes
%1 sh
%2 sh
[checks] 0:sh*

tmux after send_keys_and_wait.

tmux window of 2 panes
%1 sh
%2 sh
[checks] 0:sh*

tmux after send_keys_and_wait.

tmux window of 1 pane
%0 cat
[docs] 0:cat*

tmux after teardown_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","command":["sh"]}
Result
{
"completed": true,
"panes": [
{
"paneId": "%1",
"generation": "3f9a1c"
}
],
"sessionId": "$1",
"generation": "3f9a1c",
"ownership": "application"
}

AgentThis server has no split tool, so split from inside the pane the create result returned (%1) with tmux itself.

send_keys Execute {"target":{"paneId":"%1","generation":"3f9a1c"},"keys":["tmux split-window -h sh","Enter"]}
Result
{
"completed": true,
"generationGuarantee": "best_effort",
"target": {
"paneId": "%1",
"generation": "3f9a1c"
}
}

AgentList the panes of the session the create result returned ($1); each carries its position and size.

list_panes Inspect {"scope":{"sessionId":"$1","generation":"3f9a1c"}}
Result
{
"coverage": "session_scope",
"contextsCoverage": "selected_session",
"terminalContent": "data",
"nextOffset": null,
"pagination": "verified_discovery_facets",
"generationGuarantee": "best_effort",
"panes": [
{
"contextsTruncated": false,
"width": 40,
"caller": false,
"contexts": [
{
"sessionName": "checks",
"windowName": "sh",
"windowIndex": 0,
"sessionId": "$1",
"windowId": "@1"
}
],
"height": 24,
"fieldsTruncated": false,
"title": "host",
"active": false,
"dead": false,
"command": "sh",
"target": {
"paneId": "%1",
"generation": "3f9a1c"
}
},
{
"contextsTruncated": false,
"width": 39,
"caller": false,
"contexts": [
{
"sessionName": "checks",
"windowName": "sh",
"windowIndex": 0,
"sessionId": "$1",
"windowId": "@1"
}
],
"height": 24,
"fieldsTruncated": false,
"title": "host",
"active": true,
"dead": false,
"command": "sh",
"target": {
"paneId": "%2",
"generation": "3f9a1c"
}
}
],
"total": 2,
"nextPageToken": null,
"truncated": false
}

AgentRun the tests in the pane the create result returned (%1) and wait for the summary.

send_keys_and_wait Execute {"target":{"paneId":"%1","generation":"3f9a1c"},"keys":["pytest -q","Enter"],"text":"2 passed"}
Result
{
"matched": true,
"source": "output",
"terminalContent": "data",
"evidence": "literal_text",
"continuity": "stream",
"text": "2 passed",
"generationGuarantee": "best_effort",
"keysSent": true,
"target": {
"paneId": "%1",
"generation": "3f9a1c"
}
}

AgentShow the log in the new pane the list returned (%2) and wait for its last line.

send_keys_and_wait Execute {"target":{"paneId":"%2","generation":"3f9a1c"},"keys":["cat checks.log","Enter"],"text":"checks finished"}
Result
{
"matched": true,
"source": "output",
"terminalContent": "data",
"evidence": "literal_text",
"continuity": "stream",
"text": "checks finished",
"generationGuarantee": "best_effort",
"keysSent": true,
"target": {
"paneId": "%2",
"generation": "3f9a1c"
}
}

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

teardown_session Teardown {"sessionId":"$1","generation":"3f9a1c"}
Result
{
"completed": true,
"sessionId": "$1",
"generation": "3f9a1c"
}
Agent

pytest printed 2 passed and checks.log ends with checks finished. I removed the checks session.

1/6

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
LibTmuxMCP Not on a registry yet
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ claude mcp add tmux \
    -- /absolute/path/to/project/bin/libtmux-mcp \
        --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ claude mcp add tmux \
    --scope user \
    -- /absolute/path/to/project/bin/libtmux-mcp \
        --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ claude mcp add tmux \
    --scope project \
    -- /absolute/path/to/project/bin/libtmux-mcp \
        --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ codex mcp add tmux \
    -- /absolute/path/to/project/bin/libtmux-mcp \
        --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
[mcp_servers.tmux]
command = "/absolute/path/to/project/bin/libtmux-mcp"
args = ["--socket", "/absolute/path/to/tmux.sock"]
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ gemini mcp add \
    --scope user \
    tmux /absolute/path/to/project/bin/libtmux-mcp \
    -- --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ gemini mcp add \
    --scope project \
    tmux /absolute/path/to/project/bin/libtmux-mcp \
    -- --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ grok mcp add \
    --scope user \
    tmux \
    -- /absolute/path/to/project/bin/libtmux-mcp \
        --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ grok mcp add \
    --scope project \
    tmux \
    -- /absolute/path/to/project/bin/libtmux-mcp \
        --socket /absolute/path/to/tmux.sock
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
{
    "mcpServers": {
        "tmux": {
            "command": "/absolute/path/to/project/bin/libtmux-mcp",
            "args": ["--socket", "/absolute/path/to/tmux.sock"]
        }
    }
}
First
$ julia --startup-file=no -e '
using Pkg
Pkg.activate(".")
repo = "https://github.com/libtmux/libtmux-julia.git"
ref = "0e761d353bc0606f69ad87994958d09a92c7f7d1"
Pkg.add([
    Pkg.PackageSpec(url=repo, rev=ref),
    Pkg.PackageSpec(url=repo, rev=ref, subdir="packages/LibTmuxMCP")])
using LibTmuxMCP
println(LibTmuxMCP.install_cli("bin"))'
$ opencode mcp add tmux \
    -- /absolute/path/to/project/bin/libtmux-mcp \
        --socket /absolute/path/to/tmux.sock

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

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Writes ~/.codex/config.toml.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Writes ~/.gemini/settings.json.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Writes ~/.grok/config.toml.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

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

Run the setup in a consumer project directory. Replace the launcher and socket paths with absolute paths on your machine. The server borrows an existing tmux daemon. Configure tool permissions as described in the MCP server guide.

LibTmuxMCP serves a local tmux endpoint over standard input and output. Select an existing server explicitly and configure the tools the client may use. The application leaves the borrowed daemon and existing sessions running when it closes.

The server guide covers package installation, launcher creation, endpoint selection and tool permissions. The API reference documents the Julia embedding surface.

Tools by tier

The Julia server groups its tools by what they request. A tier badge tells you how far a call reaches before you approve it.

Inspect

Request tmux state and terminal output.

  • capture_pane Inspect Capture bounded UTF-8 pane text and truncation metadata.
  • list_panes Inspect Discover unique physical panes using generation-bound session/window scopes, native inert criteria and scalar columns.
  • wait_for_text Inspect Wait for a literal UTF-8 string.

Manage

Change tmux structure or presentation.

  • resize_pane Manage Request pane width or height in cells.

Execute

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

  • create_session Execute Start an argv command in a new application-owned session.
  • paste_text Execute Paste UTF-8 text through a temporary owned buffer without adding Enter.
  • send_keys Execute Send explicit key tokens or literal text to one captured target.
  • send_keys_and_wait Execute Send explicit keys and wait for literal text.

Teardown

Delete tmux objects or retained scrollback. Not reversible.

  • kill_pane Teardown Destroy one explicitly authorized pane and its running process.
  • run_operations Teardown Run up to eight enabled tool calls sequentially after validating every item.
  • teardown_session Teardown Destroy an exact generation-bound session created by this application.

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

Esc
Search in

Type to search.

Reference previewOpen reference