A high-performance, persistent MCP server that manages SSH sessions via a local `tmux` instance.
Unlike traditional SSH automation that relies on complex regex to detect command completion, this project treats the AI agent as a human user who "looks" at the screen. The server is responsible for:
- Sending keystrokes to a PTY.
- Capturing visual snapshots of the PTY.
- Managing the lifecycle of the local `tmux` windows.
The AI Agent is responsible for:
- Determining if a command is finished.
- Handling unexpected prompts (passwords, [Y/n] questions).
- Interpreting error messages.
- tmux Session Name: `mcp-ssh`
- Window Management: Each window is named with a unique ID (`ssh-`).
- Persistence: If the MCP server dies, `tmux` keeps the SSH connections open. Re-opening the MCP server allows the agent to re-attach to existing windows.
- `open_session(host, username, port)`: Creates a window, runs `ssh`, returns initial text.
- `send_command(session_id, command, lines, timeout)`: Sends keys + Enter, polls for up to `timeout` seconds (default 2.0), returns screen text.
- `get_snapshot(session_id)`: Returns current screen text without sending keys.
- `list_sessions()`: Returns active window IDs.
- `close_session(session_id)`: Kills the tmux window.