MCP (Model Context Protocol) server for tmux, powered by libtmux.
Warning
Pre-alpha. APIs may change. Contributions and feedback welcome.
Give AI agents (Claude Code, Claude Desktop, Codex CLI, Gemini CLI, Cursor) programmatic control over tmux sessions - list, create, send keys, capture output, resize, and more.
uvx handles install, deps, and execution automatically:
Claude Code:
$ claude mcp add libtmux -- uvx libtmux-mcpCodex CLI:
$ codex mcp add libtmux -- uvx libtmux-mcpGemini CLI:
$ gemini mcp add libtmux uvx -- libtmux-mcpCursor does not have an mcp add CLI command - use the JSON config below.
{
"mcpServers": {
"libtmux": {
"command": "uvx",
"args": ["libtmux-mcp"],
"env": {
"LIBTMUX_SOCKET": "ai_workspace"
}
}
}
}| Tool | Config file | Format |
|---|---|---|
| Claude Code | .mcp.json (project) or ~/.claude.json (global) |
JSON |
| Claude Desktop | claude_desktop_config.json |
JSON |
| Codex CLI | ~/.codex/config.toml |
TOML (see below) |
| Gemini CLI | ~/.gemini/settings.json |
JSON |
| Cursor | .cursor/mcp.json (project) or ~/.cursor/mcp.json (global) |
JSON |
Codex CLI config.toml format
[mcp_servers.libtmux]
command = "uvx"
args = ["libtmux-mcp"]$ uv pip install libtmux-mcp$ pip install libtmux-mcpClone and install in editable mode:
$ git clone https://github.com/tmux-python/libtmux-mcp.git$ cd libtmux-mcp$ uv pip install -e "."Run the server:
$ libtmux-mcpCode changes take effect immediately - no reinstall needed.
Point your tool at the local checkout via uv --directory:
Claude Code:
$ claude mcp add --scope user libtmux -- uv --directory ~/work/python/libtmux-mcp run libtmux-mcpCodex CLI:
$ codex mcp add libtmux -- uv --directory ~/work/python/libtmux-mcp run libtmux-mcpGemini CLI:
$ gemini mcp add --scope user libtmux uv -- --directory ~/work/python/libtmux-mcp run libtmux-mcpCursor - add to ~/.cursor/mcp.json:
{
"mcpServers": {
"libtmux": {
"command": "uv",
"args": [
"--directory", "~/work/python/libtmux-mcp",
"run", "libtmux-mcp"
]
}
}
}Codex CLI config.toml format (local checkout)
[mcp_servers.libtmux]
command = "uv"
args = ["--directory", "~/work/python/libtmux-mcp", "run", "libtmux-mcp"]| Module | Tools |
|---|---|
| Server | list_sessions, create_session, kill_server, get_server_info |
| Session | list_windows, create_window, rename_session, kill_session |
| Window | list_panes, split_window, rename_window, kill_window, select_layout, resize_window |
| Pane | send_keys, capture_pane, resize_pane, kill_pane, set_pane_title, get_pane_info, clear_pane, search_panes, wait_for_text |
| Options | show_option, set_option |
| Environment | show_environment, set_environment |
Browse the tmux hierarchy via URI patterns:
tmux://sessions- All sessionstmux://sessions/{name}- Session detail with windowstmux://sessions/{name}/windows- Session's windowstmux://sessions/{name}/windows/{index}- Window detail with panestmux://panes/{id}- Pane detailstmux://panes/{id}/content- Pane captured content
Control which tools are available via LIBTMUX_SAFETY env var:
| Tier | Tools | Use case |
|---|---|---|
readonly |
List, capture, search, info | Monitoring, browsing |
mutating (default) |
+ create, send_keys, rename, resize | Normal agent workflow |
destructive |
+ kill_server, kill_session, kill_window, kill_pane | Full control |
src/libtmux_mcp/
__init__.py # Entry point: main()
__main__.py # python -m libtmux_mcp support
server.py # FastMCP instance
_utils.py # Server caching, resolvers, serializers, error handling
models.py # Pydantic output models
middleware.py # Safety tier middleware
tools/
server_tools.py # list_sessions, create_session, kill_server, get_server_info
session_tools.py # list_windows, create_window, rename_session, kill_session
window_tools.py # list_panes, split_window, rename_window, kill_window, select_layout, resize_window
pane_tools.py # send_keys, capture_pane, resize_pane, kill_pane, set_pane_title, get_pane_info, clear_pane, search_panes, wait_for_text
option_tools.py # show_option, set_option
env_tools.py # show_environment, set_environment
resources/
hierarchy.py # tmux:// URI resources
| Variable | Purpose |
|---|---|
LIBTMUX_SOCKET |
tmux socket name (-L). Isolates the MCP server to a specific socket. |
LIBTMUX_SOCKET_PATH |
tmux socket path (-S). Alternative to socket name. |
LIBTMUX_TMUX_BIN |
Path to tmux binary. Useful for testing with different tmux versions. |
LIBTMUX_SAFETY |
Safety tier: readonly, mutating (default), or destructive. |
- Documentation: https://libtmux-mcp.git-pull.com
- libtmux (core library): https://libtmux.git-pull.com
- tmuxp (workspace manager): https://tmuxp.git-pull.com
- Source: https://github.com/tmux-python/libtmux-mcp
- Issues: https://github.com/tmux-python/libtmux-mcp/issues
MIT