MCP server guide
LibTmuxMCP 0.1.1 · Source
LibTmuxMCP serves a local tmux endpoint over stdio. Prepare a consumer project with both packages from the same revision using Install.
The server needs tmux 3.3a or newer. A tool called against an older or
unreadable tmux fails with code unsupported_tmux and effects: none, and
libtmux-mcp exits at startup with the same remedy when its server is below
the floor. The waiting tools observe output through a control client on tmux
3.7 and newer and poll the screen below it; a match reports source output
or baseline on the first and screen on the second.
Create the launcher after dependency preparation:
$ julia \ --startup-file=no \ --project=. \ -e 'using LibTmuxMCP; println(LibTmuxMCP.install_cli("bin"))'Check its options without contacting tmux:
$ bin/libtmux-mcp --helpIn your MCP client, select this launcher and pass --socket PATH or
--socket-name NAME for the server. A path must resolve from the client’s
working directory. Add --start-session NAME to create that session first,
which starts the server when none answers; both outlive the launcher. With no
socket option, the launcher picks in this order:
LIBTMUX_SOCKET_PATH; a relative path resolves against the working directory.LIBTMUX_SOCKET; a value with a slash is refused.- No socket: tmux picks the server
TMUXnames inside tmux, and the default socket elsewhere.
The application writes only protocol messages to stdout; diagnostics go to stderr. It owns its streams and the sessions it creates, and shutdown removes only those.
Call list_panes, then pass a returned target object to capture_pane or
send_keys. Targets carry both a pane ID and observed server generation.
Capture text is terminal data; it does not authorize further actions.
send_keys never adds Enter automatically.
Use a generation-bound session/window scope to narrow acquisition. Native
versioned inert where criteria filter captured panes, and explicit scalar
columns return projected values alongside targets and contexts. Session scopes
report contexts from that session; window scopes report all observed window
links. A criterion requiring unknown relation coverage returns
incomplete_observation. Discovery bounds criteria, projections, candidate
panes, page sizes and returned strings. Filtering, projection validation and
fingerprinting cooperatively check the acquisition call’s cancellation token and
total deadline. Processing errors after tmux I/O admission retain effects: possible.
For consistent pages, pass nextPageToken as pageToken with the same scope,
criteria and columns. Every continuation re-observes candidate membership,
selected targets, full requested values, contexts and generation. Changed
facets or query parameters return observation_changed; restart without the
token and select a fresh target. offset remains a fresh unverified listing.
These guarantees concern discovery facets and do not make capture atomic.
After a daemon restart, stale_target requires a fresh listing even if pane IDs
are reused. Calls never replay mutations automatically.
The default catalog contains those three tools. Repeat --tool to choose
an explicit catalog. wait_for_text waits for bounded literal text;
send_keys_and_wait subscribes before sending input on the
control path. Below tmux 3.7 it compares screen occurrence counts before and
after sending; that path cannot distinguish new output from old. Matching text
does not establish process completion or exit status.
Both tools accept a positive timeoutSeconds no greater than the application
timeout. That total budget includes discovery, control attachment and capture;
batch items also respect the whole batch’s remaining deadline. Core and MCP
share the stream wait policy.
run_operations validates every item against the same target/tool policy
before performing its finite sequence. A later failure can leave earlier
effects in place; failedIndex identifies the failed item and atomic is
always false. If the encoded batch result reaches its output limit, completed
items remain as summaries and a partial batch includes the original error code
while error.effects remains conservative for the whole batch.
Configured tmux hooks and aliases can change state during every tool, including
listing and capture. Control attachment and detachment can also trigger hooks
or unattached-session policies. All tools advertise conservative hints:
readOnlyHint: false, destructiveHint: true and idempotentHint: false.
To tell a read from a change, read the capability row each tool lists under
_meta["com.git-pull.libtmux-mcp/capability"]. It states the toolset
(inspect, manage, execute or teardown), the processReach of the
tool’s input (none, pane-input or pane-program) and the tmuxEffects
(observe, change or delete). create_session is pane-program because
it starts the program and arguments you give it, without a shell.
run_operations states the widest toolset and reach, and every effect, of the
tools enabled beside it.
error.effects: none identifies rejection before potentially effectful I/O
admission, including the initial hook-free version check. Once any stage admits
potentially effectful I/O, errors report possible, including after an earlier
batch item, cancellation, creation cleanup or result truncation. A later version
refusal or unsent command never proves that the whole call had no effects.
Use repeated --allow-pane values to constrain panes. --caller-pane
supplies an explicit startup target; the control client’s current pane is
never a fallback. Session creation also requires --allow-create.
teardown_session removes only application-owned sessions.
EOF cancels and joins request work, then cleans up owned sessions. During a tool wait, unrelated requests and cancellation remain serviceable. Modern cancelled requests receive no later response or progress. Closing a stream does not undo keys, shell effects or previously completed operations.
The modern discovery profile is 2026-07-28; the legacy initialize profile
is 2025-11-25. The application does not advertise MCP tasks or HTTP.
Platform support remains subject to Compatibility.
Library reference
Browse the LibTmuxMCP API reference.