testing-mcp-with-cli-agentslisted
Install: claude install-skill tmux-python/libtmux-mcp
# Testing an MCP server through real CLI agents
Unit tests prove the server's internals; they don't prove a real agent can
discover a tool, get past its approval gate, call it, and survive cancelling it
mid-flight. This skill exercises that whole path by pointing installed CLI
agents at a checkout and driving them — with the tmux tool surface (libtmux-mcp)
as the running example, though the shape generalizes to any MCP server.
## The core idea: three tmux servers, never one
The single biggest mistake is running everything on one tmux socket. Keep three
distinct servers, each on its own socket, and the whole thing becomes safe and
observable:
| Role | Socket | Who touches it | Why separate |
|---|---|---|---|
| Your real session | default | you, interactively | must never be mutated by a test |
| Harness | `tmux -L cli-harness` | the driver: `send-keys` prompts in, `capture-pane` render out | isolates the CLI TUI you're driving |
| MCP-target | `tmux -L mcp-target`, exported as `LIBTMUX_SOCKET=mcp-target` to the server | the MCP server, when the agent calls tmux tools | independent ground-truth; a destructive tool here can't kill the agent you're driving |
The server resolves its socket from `LIBTMUX_SOCKET` and runs `tmux -L <name>`
(`src/libtmux_mcp/_utils.py` builds argv with `-L server.socket_name`, defaulted
from that env var). Exporting `LIBTMUX_SOCKET=mcp-target` into the server's
config env fully sandboxes every tmux tool call onto a scratch server.
Pre-create it