Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

libtmux-mcp

A Model Context Protocol server for tmux, built on libtmux.

Python Version PyPI Version License

[!WARNING] Alpha. Releases carry an -alpha prerelease tag. The API is not settled, and any release may change or remove exported identifiers without a deprecation period. Pin an exact version. Not recommended for production.

Give your AI agent hands inside the terminal — create sessions, run commands, read output, orchestrate panes.

Tools

Module Tools
Server list_servers, list_sessions, create_session, kill_server, get_server_info
Batch call_read_tools_batch
Session list_windows, get_session_info, create_window, rename_session, select_window, kill_session
Window list_panes, get_window_info, split_window, rename_window, select_layout, resize_window, move_window, kill_window
Pane run_command, send_keys, send_keys_batch, paste_text, capture_pane, capture_since, snapshot_pane, search_panes, find_pane_by_position, get_pane_info, wait_for_text, wait_for_channel, signal_channel, display_message, select_pane, swap_pane, resize_pane, set_pane_title, clear_pane, pipe_pane, enter_copy_mode, exit_copy_mode, respawn_pane, kill_pane
Options show_option, set_option
Environment show_environment, set_environment
Buffers load_buffer, paste_buffer, show_buffer, delete_buffer
Hooks show_hooks, show_hook

Quickstart

Requirements: Python 3.10+, tmux >= 3.2a on $PATH.

The distribution is libtmux-mcp, the import is libtmux_mcp, and the installed executable is libtmux-mcp.

Install and run:

$ uvx libtmux-mcp

Claude Code

$ claude mcp add tmux -- uvx libtmux-mcp

Codex CLI

$ codex mcp add tmux -- uvx libtmux-mcp

Gemini CLI

$ gemini mcp add tmux uvx -- libtmux-mcp

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "tmux": {
      "command": "uvx",
      "args": ["libtmux-mcp"]
    }
  }
}

More clients and JSON config: client setup docs

What it feels like

You: Create a session called "api" and run pytest tests/api/ -x in it.

Agent: Created session api with window tests. Running pytest now. Here's the output — 14 passed, 2 failed. The failures are in test_auth.py::test_token_refresh and test_auth.py::test_expired_session. Want me to open those files?

The agent manages tmux directly. No copy-pasting terminal output. No switching windows to check on long-running processes.

When the server earns its keep

For a single tmux send-keys, the server doesn't. It earns its keep the moment the agent has to wait, inspect, or avoid damaging the terminal it is using — pytest finishing, a dev server printing its port, a deploy log settling. The difference then is not more access to tmux, but a better place to put the control loop.

The server-side moves are:

Running. run_command sends an authored shell command, waits for deterministic completion, and returns exit status plus tail-preserved output as one typed value. The command and its completion signal reach the shell as one space-prefixed event, so best-effort history suppression keeps agent-generated input out of shell history by default. The alternative — hand-rolled send-keys plus wait-for plus a pane capture — leaves every typed command, signal included, in shell history.

Driving. send_keys_batch sends several ordered raw-input operations for TUIs and persistent shell interaction. It is deliberately not a workflow DSL; command completion stays in run_command, and repeated observation stays in capture_since.

Waiting. wait_for_text blocks inside the server until a condition fires for output the agent does not author. The alternative is the model polling capture-pane in a loop, paying both context tokens and round-trip latency for every turn.

Reading. snapshot_pane returns content, cursor, copy-mode state, and scroll offset as one typed value. The alternative is several tmux invocations stitched together with regex.

Observing. capture_since returns a cursor with the current pane content, then returns only newly written or rewritten rows on follow-up calls. The alternative is re-sending the same scrollback to the model on every check.

Guarding. The server detects the agent's own pane across sockets and declines to end its own — kill_session on itself fails loudly instead of silently terminating the host environment the agent is running in. LIBTMUX_TOOLSETS (inspect, manage, execute, teardown) drops whole toolsets from the client's tool list before any prompt is built. The sets are unordered, so inspect,teardown is a legal surface. Dropping one is inventory and MCP tool-call configuration, not containment: an enabled execute tool can type the equivalent of anything it hides.

Documentation

Full docs, guides, and tool reference: libtmux-mcp.git-pull.com

Development

Clone and install:

$ git clone https://github.com/tmux-python/libtmux-mcp.git
$ cd libtmux-mcp
$ uv sync --all-extras --dev

Run the server locally:

$ uv run libtmux-mcp

Run tests:

$ uv run pytest

See CONTRIBUTING.md for the gates, and WRITING.md for how this project writes prose, docstrings, and MCP tool descriptions.

Related projects

License

MIT

Release files for libtmux-mcp 0.1.0a21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libtmux-mcp 0.1.0a21
File Size Uploaded
libtmux_mcp-0.1.0a21.tar.gz 805.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for libtmux-mcp 0.1.0a21
File Interpreter ABI Platform
libtmux_mcp-0.1.0a21-py3-none-any.whl Python 3 none any Details

Total release size: 940.4 kB

Release files / libtmux_mcp-0.1.0a21.tar.gz

Download URL libtmux_mcp-0.1.0a21.tar.gz
Size 805.7 kB
Tags Source
SHA-256 checksum
How to use checksums
91ddca7a7d32f7cef6ab63c8bc814a1a45c7f97f969cf04b3627f13b63e7cf9c
BLAKE2b-256 checksum
How to use checksums
c6d8231f705ecf427140bafe46f46e175d6da2c8c307fe27907f840d14ae3f85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / libtmux_mcp-0.1.0a21-py3-none-any.whl

Download URL libtmux_mcp-0.1.0a21-py3-none-any.whl
Size 134.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff5d3dabf6c95dbc8ccadaef2ba2c670dce44f5284bb1dcc4c6f508e9b387a3b
BLAKE2b-256 checksum
How to use checksums
ff6e4e0b295d06312cf4a9672a541ef2f35b5b565ca57f285cbe21f113e7b1ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page