The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Pty MCP listing page.
An MCP (Model Context Protocol) server that gives AI agents interactive terminal sessions — local shells, SSH, serial ports, and persistent remote sessions that survive disconnects.
Built for sysadmins and network engineers who want AI to help with real server and device management, not just code generation.

AI agents run commands in non-interactive shells. They can't:
pty-mcp solves all of these by providing real PTY sessions over MCP.
Without pty-mcp, AI agents resort to sleep 30 && check_status loops — burning CPU cycles and API calls waiting for things to happen. With wait_for, the agent blocks server-side until the event occurs. Less polling, less energy, better for polar bears. 🐻❄️
Server administration
Network device management
Log monitoring and alerting
Long-running tasks that survive disconnects
| Feature | Description |
|---|---|
| Local terminal | Interactive bash/python/node sessions on local machine |
| SSH sessions | Connect to remote hosts with key/password auth, SSH config support |
| Serial port | Connect to devices via serial (IoT, embedded, network gear) |
| Persistent sessions | Sessions survive SSH disconnects via ai-tmux daemon |
| Attach/Detach | Detach from a running session, reconnect later |
| Control keys | Send ctrl+c, ctrl+d, arrow keys, tab, escape |
| Settle detection | Waits for output to settle before returning (smart timeout) |
| Pattern matching | wait_for blocks until a regex pattern appears in output (v0.2.0) |
| Bounded memory | Ring buffer prevents OOM on long-running sessions (v0.2.0) |
| Resize terminal | Resize the PTY window for local, SSH, serial, and persistent remote sessions (v0.10.0) |
| Audit log | Optional voluntary operation log — record send_input commands to a collector for review and traceability (v0.8.0) |
| Audit redaction | Credentials, auth headers, and PEM keys are automatically scrubbed before being written to the audit log (v0.10.0) |
Installs the binary automatically and registers the MCP server:
Restart Claude Code — the binary downloads automatically on session start, then restart once more to activate it. No manual claude mcp add needed.
Updating:
Restart Claude Code — the new binary downloads automatically on session start, then restart once more to apply the update.
One-line install + register (macOS / Linux / WSL2):
Restart Claude Code and the tools are available.
Download from GitHub Releases:
Go to Releases, download the binary for your platform, and make it executable:
| Platform | Binary |
|---|---|
| macOS (Apple Silicon) | pty-mcp-darwin-arm64 |
| macOS (Intel) | pty-mcp-darwin-amd64 |
| Linux (x86_64) / WSL2 | pty-mcp-linux-amd64 |
| Linux (ARM64) | pty-mcp-linux-arm64 |
Build from source (requires Go 1.25+):
pty-mcp works in WSL2 out of the box. Use the Linux binary:
For persistent sessions that survive SSH disconnects, install ai-tmux on your remote server:
Once registered, the AI agent can use these MCP tools:
Local interactive shell:
SSH to remote server:
Wait for pattern (v0.2.0):
Send secret / password (v0.3.0):
Persistent session (survives SSH disconnect):
| Tool | Description |
|---|---|
create_local_session | Start a local interactive terminal (bash, python3, node, etc.) |
create_ssh_session | SSH to a remote host (supports SSH config aliases) |
create_serial_session | Connect to a serial port device |
send_input | Send a command and wait for output to settle |
read_output | Read output, optionally wait for a pattern (wait_for, timeout, context_lines, tail_lines) |
send_control | Send control keys (ctrl+c, ctrl+d, arrows, tab, etc.) |
send_secret | Prompt the human operator for a secret via GUI dialog; sends it to the PTY session without exposing it to AI context or logs ¹ |
list_sessions | List all active sessions |
close_session | Close a session (terminates remote PTY) |
detach_session | Disconnect but keep remote PTY running |
resize_session | Resize the terminal window (rows/cols) for any session type |
list_remote_sessions | List persistent sessions on a remote host |
¹
send_secretplatform support: macOS uses a native password dialog (osascript). WSL2 usespowershell.exe Get-Credential(Windows GUI dialog). Linux with a display server useszenityorkdialog. Headless Linux falls back to/dev/tty. On macOS/Linux, if the operator doesn't respond within 60 seconds, the dialog is dismissed and the call returns a timeout error instead of falling through to another dialog or waiting again; cancelling the call (e.g. pressing ESC in Claude Code) dismisses the dialog immediately the same way. WSL2 is the exception: its dialog has no timeout and is never force-closed, including on cancellation — killing a WSL-interop-launched process that owns an open Windows GUI window was found to freeze the hosting terminal (unresponsive to input, scrolling, and selection) until the operator closes that terminal, with no way to recover it short of that. The dialog just waits until the operator answers or clicks Cancel themselves, which exits normally.
pty-mcp includes an optional audit log feature that records every send_input command to a central collector. This lets teams review and trace what AI agents did during a session.
Important: This is a voluntary, self-reporting operation log. It relies on operators choosing to enable it and run the collector. Because pty-mcp runs on the operator's own machine, there is no technical mechanism to enforce logging — a non-compliant operator could simply run pty-mcp without audit enabled. This feature provides traceability for teams that want it, but it is not a substitute for system-level audit tools (e.g., auditd, syslog forwarding, SSH session recording) in environments where audit compliance is required.
send_input (including raw=true inputs like menu selections)cmd_id linking the command to its outputsend_secret is never logged — secrets entered via the GUI dialog do not appear in the audit log.
Commands and output snippets are automatically redacted before being written. The following patterns are replaced with [REDACTED] or [PRIVATE KEY REDACTED]:
password=, passwd:, token=, api_key=, access_key=, auth_token=, secret=Authorization: Bearer …, Authorization: Basic …, Authorization: Token …-----BEGIN RSA PRIVATE KEY----- / -----BEGIN OPENSSH PRIVATE KEY-----Each operator runs once to create their config and generate a token:
This creates ~/.config/pty-mcp/config (chmod 600) with a randomly generated token and prints the token to share with the collector admin.
The collector admin starts the server (using the token from init output):
Enable audit after setting the collector URL in the config:
To temporarily stop logging without losing your config:
Operators without a config file are unaffected — audit is off by default.
| Mode | Behaviour |
|---|---|
best-effort (default) | Commands execute regardless of whether the log was written; entries are queued and retried in the background |
strict | send_input is rejected if the audit entry cannot be delivered; use when logging is a team policy requirement |
Logs are stored as JSONL (one JSON object per line), readable with standard tools:
ai-tmux is a lightweight daemon that runs on remote servers, keeping PTY sessions alive across SSH disconnects. Think of it as tmux designed for AI agents.
ai-tmux server — daemon mode, listens on Unix socket, manages PTY sessionsai-tmux client — bridge mode, forwards JSON protocol over stdin/stdout (used by pty-mcp over SSH)ai-tmux list — list active sessionsThe daemon auto-starts when pty-mcp connects with persistent: true. Sessions are reaped after 30 minutes of inactivity.
pty-mcp checks ai-tmux --version on the remote host before opening a session and returns a clear error if the binary is missing or below the minimum required version — no cryptic connection errors.
pty-mcp reads ~/.ssh/config to resolve host aliases:
ai-tmux binary on remote serverSee CHANGELOG.md for version history.
MIT