Skip to content

Commit 34dcfd4

Browse files
authored
feat(tools): Add 11 new MCP tools for agent workflows (#11)
Expands the MCP surface with tools that unblock common agent workflows the initial tool set couldn't serve cleanly: rich pane introspection, waiting on unspecified output, pane and window navigation, layout rearrangement, scrollback and copy-mode control, bracketed multi-line paste, generic tmux format-string queries, and pane output logging. All tools ship with Pydantic output models, user-facing documentation, and tests that run against every tmux version in the CI matrix (3.2a through master). **New pane tools:** - `snapshot_pane` — one-call capture returning content plus cursor position, mode, scroll state, and pane metadata - `wait_for_content_change` — block until any on-screen change; complements `wait_for_text` when expected output is unknown - `select_pane` — focus by pane_id or by direction (up/down/left/right/last/next/previous) - `swap_pane` — exchange two panes' positions within a window - `pipe_pane` — start or stop streaming pane output to a file - `display_message` — query arbitrary tmux format strings - `enter_copy_mode` / `exit_copy_mode` — control scrollback access, with optional immediate scroll-up on entry - `paste_text` — deliver multi-line text via isolated tmux buffers **New session tool:** - `select_window` — focus by id, index, or direction (next / previous / last) **New window tool:** - `move_window` — reorder within a session or move across sessions **New models:** `PaneSnapshot` and `ContentChangeResult`, both with full field-level typing for the richer return shapes. **Correctness guarantees validated by test:** - Directional navigation in `select_pane` and `select_window` routes through absolute pane_ids and session-scoped tmux subcommands, so targeting a non-active window or non-current session cannot misroute focus to whatever the attached client happens to have focused. - `move_window` refreshes the window after the move, so cross-session returns never carry stale session metadata (libtmux's in-memory update skips refresh on the destination-index-plus-session branch). - `snapshot_pane` uses the printable Unicode `␞` delimiter — the same choice as libtmux's `FORMAT_SEPARATOR` — so parsing is immune to tmux's version-dependent control-character escaping in `display-message` output. - `pipe_pane` shell-quotes output paths and rejects empty strings at the tool boundary instead of letting tmux emit a broken pipe silently. - `paste_text` uses per-call UUID-named tmux buffers, surfaces load-buffer stderr as `ToolError`, and cleans up both the named buffer and the temp file on every exit path. - MCP annotation tiers corrected for non-idempotent operations: `swap_pane`, `enter_copy_mode`, and `pipe_pane` advertise `idempotentHint=false`. **Docs:** per-module pages in `docs/tools/*.md` with usage guidance, JSON examples, and parameter tables for every tool; the tools index carries an expanded "Which tool do I want?" decision guide; the README Tools table lists the full new roster; the docs landing page highlights the headline capabilities.
2 parents c96af82 + a665371 commit 34dcfd4

14 files changed

Lines changed: 2086 additions & 15 deletions

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
_Notes on upcoming releases will be added here_
77
<!-- END PLACEHOLDER - ADD NEW CHANGELOG ENTRIES BELOW THIS LINE -->
88

9+
### What's new
10+
11+
- New pane tools: `snapshot_pane`, `wait_for_content_change`, `select_pane`, `swap_pane`, `pipe_pane`, `display_message`, `enter_copy_mode`, `exit_copy_mode`, and `paste_text` (#11)
12+
- New session tool: `select_window` — navigate by ID, index, or direction (#11)
13+
- New window tool: `move_window` — reorder within a session or move across sessions (#11)
14+
- New models: `PaneSnapshot` and `ContentChangeResult` (#11)
15+
916
### Documentation
1017

1118
- Visual improvements to API docs from [gp-sphinx](https://gp-sphinx.git-pull.com)-based Sphinx packages (#10)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Give your AI agent hands inside the terminal — create sessions, run commands,
1616
| Module | Tools |
1717
|--------|-------|
1818
| **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` |
19+
| **Session** | `list_windows`, `create_window`, `rename_session`, `select_window`, `kill_session` |
20+
| **Window** | `list_panes`, `split_window`, `rename_window`, `select_layout`, `resize_window`, `move_window`, `kill_window` |
21+
| **Pane** | `send_keys`, `paste_text`, `capture_pane`, `snapshot_pane`, `search_panes`, `get_pane_info`, `wait_for_text`, `wait_for_content_change`, `display_message`, `select_pane`, `swap_pane`, `resize_pane`, `set_pane_title`, `clear_pane`, `pipe_pane`, `enter_copy_mode`, `exit_copy_mode`, `kill_pane` |
2222
| **Options** | `show_option`, `set_option` |
2323
| **Environment** | `show_environment`, `set_environment` |
2424

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ Config blocks for Claude Desktop, Claude Code, Cursor, and others.
5353

5454
Read tmux state without changing anything.
5555

56-
{toolref}`list-sessions` · {toolref}`capture-pane` · {toolref}`get-pane-info` · {toolref}`search-panes` · {toolref}`wait-for-text`
56+
{toolref}`list-sessions` · {toolref}`capture-pane` · {toolref}`snapshot-pane` · {toolref}`get-pane-info` · {toolref}`search-panes` · {toolref}`wait-for-text` · {toolref}`wait-for-content-change` · {toolref}`display-message`
5757

5858
### Act (mutating)
5959

6060
Create or modify tmux objects.
6161

62-
{toolref}`create-session` · {toolref}`send-keys` · {toolref}`create-window` · {toolref}`split-window` · {toolref}`resize-pane` · {toolref}`set-option`
62+
{toolref}`create-session` · {toolref}`send-keys` · {toolref}`paste-text` · {toolref}`create-window` · {toolref}`split-window` · {toolref}`select-pane` · {toolref}`select-window` · {toolref}`move-window` · {toolref}`resize-pane` · {toolref}`pipe-pane` · {toolref}`set-option`
6363

6464
### Destroy (destructive)
6565

docs/tools/index.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,36 @@ All tools accept an optional `socket_name` parameter for multi-server support. I
88

99
**Reading terminal content?**
1010
- Know which pane? → {tool}`capture-pane`
11+
- Need text + cursor + mode in one call? → {tool}`snapshot-pane`
1112
- Don't know which pane? → {tool}`search-panes`
12-
- Need to wait for output? → {tool}`wait-for-text`
13+
- Need to wait for specific output? → {tool}`wait-for-text`
14+
- Need to wait for *any* change? → {tool}`wait-for-content-change`
1315
- Only need metadata (PID, path, size)? → {tool}`get-pane-info`
16+
- Need an arbitrary tmux variable? → {tool}`display-message`
1417

1518
**Running a command?**
1619
- {tool}`send-keys` — then {tool}`wait-for-text` + {tool}`capture-pane`
20+
- Pasting multi-line text? → {tool}`paste-text`
1721

1822
**Creating workspace structure?**
1923
- New session → {tool}`create-session`
2024
- New window → {tool}`create-window`
2125
- New pane → {tool}`split-window`
2226

27+
**Navigating?**
28+
- Switch pane → {tool}`select-pane` (by ID or direction)
29+
- Switch window → {tool}`select-window` (by ID, index, or direction)
30+
31+
**Rearranging layout?**
32+
- Swap two panes → {tool}`swap-pane`
33+
- Move window → {tool}`move-window`
34+
- Change layout → {tool}`select-layout`
35+
36+
**Scrollback / copy mode?**
37+
- Enter copy mode → {tool}`enter-copy-mode`
38+
- Exit copy mode → {tool}`exit-copy-mode`
39+
- Log output to file → {tool}`pipe-pane`
40+
2341
**Changing settings?**
2442
- tmux options → {tool}`show-option` / {tool}`set-option`
2543
- Environment vars → {tool}`show-environment` / {tool}`set-environment`
@@ -91,6 +109,24 @@ Query a tmux option value.
91109
Show tmux environment variables.
92110
:::
93111

112+
:::{grid-item-card} snapshot_pane
113+
:link: snapshot-pane
114+
:link-type: ref
115+
Rich capture: content + cursor + mode + scroll.
116+
:::
117+
118+
:::{grid-item-card} wait_for_content_change
119+
:link: wait-for-content-change
120+
:link-type: ref
121+
Wait for any screen change.
122+
:::
123+
124+
:::{grid-item-card} display_message
125+
:link: display-message
126+
:link-type: ref
127+
Query arbitrary tmux format strings.
128+
:::
129+
94130
::::
95131

96132
## Act
@@ -178,6 +214,54 @@ Set a tmux option.
178214
Set a tmux environment variable.
179215
:::
180216

217+
:::{grid-item-card} select_pane
218+
:link: select-pane
219+
:link-type: ref
220+
Focus a pane by ID or direction.
221+
:::
222+
223+
:::{grid-item-card} select_window
224+
:link: select-window
225+
:link-type: ref
226+
Focus a window by ID, index, or direction.
227+
:::
228+
229+
:::{grid-item-card} swap_pane
230+
:link: swap-pane
231+
:link-type: ref
232+
Exchange positions of two panes.
233+
:::
234+
235+
:::{grid-item-card} move_window
236+
:link: move-window
237+
:link-type: ref
238+
Move window to another index or session.
239+
:::
240+
241+
:::{grid-item-card} pipe_pane
242+
:link: pipe-pane
243+
:link-type: ref
244+
Stream pane output to a file.
245+
:::
246+
247+
:::{grid-item-card} enter_copy_mode
248+
:link: enter-copy-mode
249+
:link-type: ref
250+
Enter copy mode for scrollback.
251+
:::
252+
253+
:::{grid-item-card} exit_copy_mode
254+
:link: exit-copy-mode
255+
:link-type: ref
256+
Exit copy mode.
257+
:::
258+
259+
:::{grid-item-card} paste_text
260+
:link: paste-text
261+
:link-type: ref
262+
Paste multi-line text via tmux buffer.
263+
:::
264+
181265
::::
182266

183267
## Destroy

0 commit comments

Comments
 (0)