11# libtmux-mcp
22
3- MCP ( Model Context Protocol) server for tmux, powered by [ libtmux] ( https://github.com/tmux-python/libtmux ) .
3+ A [ Model Context Protocol] ( https://modelcontextprotocol.io ) server for [ tmux] ( https://github.com/tmux/tmux ) , built on [ libtmux] ( https://libtmux.git-pull.com ) .
44
55[ ![ Python Version] ( https://img.shields.io/pypi/pyversions/libtmux-mcp.svg )] ( https://pypi.org/project/libtmux-mcp/ )
66[ ![ PyPI Version] ( https://img.shields.io/pypi/v/libtmux-mcp.svg )] ( https://pypi.org/project/libtmux-mcp/ )
@@ -9,254 +9,100 @@ MCP (Model Context Protocol) server for tmux, powered by [libtmux](https://githu
99> [ !WARNING]
1010> ** Pre-alpha.** APIs may change. Contributions and feedback welcome.
1111
12- 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 .
12+ Give your AI agent hands inside the terminal — create sessions, run commands, read output, orchestrate panes .
1313
14- ## Use cases
14+ ## Tools
1515
16- - ** Terminal automation** — Send commands, wait for output, capture results across panes
17- - ** Session management** — Create, organize, and monitor tmux workspaces
18- - ** Multi-pane orchestration** — Split windows, route commands to different panes in parallel
19- - ** Environment inspection** — Search pane contents, read tmux options and environment variables
20-
21- ## Quick start
22-
23- ### One-liner setup
24-
25- ` uvx ` handles install, deps, and execution automatically:
26-
27- ** Claude Code:**
16+ | Module | Tools |
17+ | --------| -------|
18+ | ** Server** | ` list_sessions ` , ` create_session ` , ` kill_server ` , ` get_server_info ` |
19+ | ** Session** | ` list_windows ` , ` create_window ` , ` rename_session ` , ` kill_session ` |
20+ | ** Window** | ` list_panes ` , ` split_window ` , ` rename_window ` , ` kill_window ` , ` select_layout ` , ` resize_window ` |
21+ | ** Pane** | ` send_keys ` , ` capture_pane ` , ` resize_pane ` , ` kill_pane ` , ` set_pane_title ` , ` get_pane_info ` , ` clear_pane ` , ` search_panes ` , ` wait_for_text ` |
22+ | ** Options** | ` show_option ` , ` set_option ` |
23+ | ** Environment** | ` show_environment ` , ` set_environment ` |
2824
29- ``` console
30- $ claude mcp add libtmux -- uvx libtmux-mcp
31- ```
25+ ## Quickstart
3226
33- <details >
34- <summary >Codex CLI / Gemini CLI</summary >
27+ ** Requirements:** Python 3.10+, tmux installed and on ` $PATH ` .
3528
36- ** Codex CLI: **
29+ Install and run:
3730
38- ``` console
39- $ codex mcp add libtmux -- uvx libtmux-mcp
31+ ``` bash
32+ uvx libtmux-mcp
4033```
4134
42- ** Gemini CLI: **
35+ ### Claude Code
4336
44- ``` console
45- $ gemini mcp add libtmux uvx -- libtmux-mcp
37+ ``` bash
38+ claude mcp add tmux -- uvx libtmux-mcp
4639```
4740
48- </details >
49-
50- ** Cursor** does not have an ` mcp add ` CLI command - use the JSON config below.
41+ ### Claude Desktop
5142
52- ### JSON config (all tools)
43+ Add to ` claude_desktop_config.json ` :
5344
5445``` json
5546{
56- "mcpServers" : {
57- "libtmux" : {
58- "command" : " uvx" ,
59- "args" : [" libtmux-mcp" ],
60- "env" : {
61- "LIBTMUX_SOCKET" : " ai_workspace"
62- }
63- }
47+ "mcpServers" : {
48+ "tmux" : {
49+ "command" : " uvx" ,
50+ "args" : [" libtmux-mcp" ]
6451 }
52+ }
6553}
6654```
6755
68- | Tool | Config file | Format |
69- | ------| -------------| --------|
70- | Claude Code | ` .mcp.json ` (project) or ` ~/.claude.json ` (global) | JSON |
71- | Claude Desktop | ` claude_desktop_config.json ` | JSON |
72- | Codex CLI | ` ~/.codex/config.toml ` | TOML (see below) |
73- | Gemini CLI | ` ~/.gemini/settings.json ` | JSON |
74- | Cursor | ` .cursor/mcp.json ` (project) or ` ~/.cursor/mcp.json ` (global) | JSON |
75-
76- <details >
77- <summary >Codex CLI config.toml format</summary >
78-
79- ``` toml
80- [mcp_servers .libtmux ]
81- command = " uvx"
82- args = [" libtmux-mcp" ]
83- ```
84-
85- </details >
86-
87- ### Install with pip / uv
88-
89- ``` console
90- $ uv pip install libtmux-mcp
91- ```
92-
93- ``` console
94- $ pip install libtmux-mcp
95- ```
96-
97- ## Development install
98-
99- Clone and install in editable mode:
100-
101- ``` console
102- $ git clone https://github.com/tmux-python/libtmux-mcp.git
103- ```
104-
105- ``` console
106- $ cd libtmux-mcp
107- ```
108-
109- ``` console
110- $ uv pip install -e " ."
111- ```
112-
113- Run the server:
114-
115- ``` console
116- $ libtmux-mcp
117- ```
56+ More clients (Codex CLI, Gemini CLI, Cursor): [ client setup docs] ( https://libtmux-mcp.git-pull.com/clients/ )
11857
119- Code changes take effect immediately - no reinstall needed.
58+ ## What it feels like
12059
121- ### Local checkout CLI setup
60+ > ** You:** Create a session called "api" and run ` pytest tests/api/ -x ` in it.
61+ >
62+ > ** Agent:** Created session ` api ` with window ` tests ` . Running pytest now.
63+ > Here's the output — 14 passed, 2 failed. The failures are in
64+ > ` test_auth.py::test_token_refresh ` and ` test_auth.py::test_expired_session ` .
65+ > Want me to open those files?
12266
123- Point your tool at the local checkout via ` uv --directory ` :
67+ The agent manages tmux directly. No copy-pasting terminal output. No switching windows to check on long-running processes.
12468
125- ** Claude Code: **
69+ ## Documentation
12670
127- ``` console
128- $ claude mcp add \
129- --scope user \
130- libtmux -- \
131- uv --directory ~/work/python/libtmux-mcp \
132- run libtmux-mcp
133- ```
71+ Full docs, guides, and tool reference: ** [ libtmux-mcp.git-pull.com] ( https://libtmux-mcp.git-pull.com ) **
13472
135- <details >
136- <summary >Codex CLI / Gemini CLI / Cursor</summary >
73+ ## Development
13774
138- ** Codex CLI: **
75+ Clone and install:
13976
140- ``` console
141- $ codex mcp add libtmux -- \
142- uv --directory ~/work/python/libtmux-mcp \
143- run libtmux-mcp
77+ ``` bash
78+ git clone https://github.com/tmux-python/libtmux-mcp.git
14479```
14580
146- ** Gemini CLI:**
147-
148- ``` console
149- $ gemini mcp add \
150- --scope user \
151- libtmux uv -- \
152- --directory ~/work/python/libtmux-mcp \
153- run libtmux-mcp
81+ ``` bash
82+ cd libtmux-mcp
15483```
15584
156- ** Cursor** — add to ` ~/.cursor/mcp.json ` :
157-
158- ``` json
159- {
160- "mcpServers" : {
161- "libtmux" : {
162- "command" : " uv" ,
163- "args" : [
164- " --directory" , " ~/work/python/libtmux-mcp" ,
165- " run" , " libtmux-mcp"
166- ]
167- }
168- }
169- }
85+ ``` bash
86+ uv sync --dev
17087```
17188
172- ** Codex CLI ** — ` config.toml ` format :
89+ Run the server locally :
17390
174- ``` toml
175- [mcp_servers .libtmux ]
176- command = " uv"
177- args = [" --directory" , " ~/work/python/libtmux-mcp" , " run" , " libtmux-mcp" ]
91+ ``` bash
92+ uv run libtmux-mcp
17893```
17994
180- </details >
181-
182- ## What's included
183-
184- ### Tools
185-
186- | Module | Tools |
187- | --------| -------|
188- | ** Server** | ` list_sessions ` , ` create_session ` , ` kill_server ` , ` get_server_info ` |
189- | ** Session** | ` list_windows ` , ` create_window ` , ` rename_session ` , ` kill_session ` |
190- | ** Window** | ` list_panes ` , ` split_window ` , ` rename_window ` , ` kill_window ` , ` select_layout ` , ` resize_window ` |
191- | ** Pane** | ` send_keys ` , ` capture_pane ` , ` resize_pane ` , ` kill_pane ` , ` set_pane_title ` , ` get_pane_info ` , ` clear_pane ` , ` search_panes ` , ` wait_for_text ` |
192- | ** Options** | ` show_option ` , ` set_option ` |
193- | ** Environment** | ` show_environment ` , ` set_environment ` |
194-
195- ### ` tmux:// ` resources
196-
197- Browse the tmux hierarchy via URI patterns:
198-
199- - ` tmux://sessions ` - All sessions
200- - ` tmux://sessions/{session_name} ` - Session detail with windows
201- - ` tmux://sessions/{session_name}/windows ` - Session's windows
202- - ` tmux://sessions/{session_name}/windows/{window_index} ` - Window detail with panes
203- - ` tmux://panes/{pane_id} ` - Pane details
204- - ` tmux://panes/{pane_id}/content ` - Pane captured content
205-
206- ### Safety tiers
207-
208- Control which tools are available via ` LIBTMUX_SAFETY ` env var:
209-
210- | Tier | Tools | Use case |
211- | ------| -------| ----------|
212- | ` readonly ` | List, capture, search, info | Monitoring, browsing |
213- | ` mutating ` (default) | + create, send_keys, rename, resize | Normal agent workflow |
214- | ` destructive ` | + kill_server, kill_session, kill_window, kill_pane | Full control |
215-
216- ### Architecture
95+ Run tests:
21796
97+ ``` bash
98+ uv run pytest
21899```
219- src/libtmux_mcp/
220- __init__.py # Entry point: main()
221- __main__.py # python -m libtmux_mcp support
222- server.py # FastMCP instance
223- _utils.py # Server caching, resolvers, serializers, error handling
224- models.py # Pydantic output models
225- middleware.py # Safety tier middleware
226- tools/
227- server_tools.py # list_sessions, create_session, kill_server, get_server_info
228- session_tools.py # list_windows, create_window, rename_session, kill_session
229- window_tools.py # list_panes, split_window, rename_window, kill_window, select_layout, resize_window
230- pane_tools.py # send_keys, capture_pane, resize_pane, kill_pane, set_pane_title, get_pane_info, clear_pane, search_panes, wait_for_text
231- option_tools.py # show_option, set_option
232- env_tools.py # show_environment, set_environment
233- resources/
234- hierarchy.py # tmux:// URI resources
235- ```
236-
237- ## Environment variables
238-
239- | Variable | Purpose |
240- | ----------| ---------|
241- | ` LIBTMUX_SOCKET ` | tmux socket name (` -L ` ). Isolates the MCP server to a specific socket. |
242- | ` LIBTMUX_SOCKET_PATH ` | tmux socket path (` -S ` ). Alternative to socket name. |
243- | ` LIBTMUX_TMUX_BIN ` | Path to tmux binary. Useful for testing with different tmux versions. |
244- | ` LIBTMUX_SAFETY ` | Safety tier: ` readonly ` , ` mutating ` (default), or ` destructive ` . |
245-
246- ## Requirements
247-
248- - Python 3.10+
249- - tmux >= 3.2a
250- - [ libtmux] ( https://github.com/tmux-python/libtmux ) >= 0.55.0
251- - [ fastmcp] ( https://github.com/jlowin/fastmcp ) >= 3.1.0
252100
253- ## Links
101+ ## Related projects
254102
255- - ** Documentation** : < https://libtmux-mcp.git-pull.com >
256- - ** libtmux** (core library): < https://libtmux.git-pull.com >
257- - ** tmuxp** (workspace manager): < https://tmuxp.git-pull.com >
258- - ** Source** : < https://github.com/tmux-python/libtmux-mcp >
259- - ** Issues** : < https://github.com/tmux-python/libtmux-mcp/issues >
103+ - [ libtmux] ( https://libtmux.git-pull.com ) — Python API for tmux
104+ - [ tmuxp] ( https://tmuxp.git-pull.com ) — tmux session manager
105+ - [ The Tao of tmux] ( https://leanpub.com/the-tao-of-tmux ) — the book
260106
261107## License
262108
0 commit comments