PiloTY (PTY for your AI Copilot) is an MCP server that gives an agent a persistent, interactive terminal. If you have used Claude Code / Codex to run shell commands, you have probably hit the same wall: tool calls tend to be stateless. Each call starts "fresh", so environment variables disappear, interactive programs cannot be driven reliably, and long-running processes get cut off or orphaned whi
Add this skill
npx mdskills install yiwenlu66/pilotySolves persistent terminal state for agents with clear capabilities and excellent setup guidance
1<p align="center">2 <img src="assets/logo.png" alt="PiloTY logo" width="220" />3</p>45# PiloTY67PiloTY (PTY for your AI Copilot) is an MCP server that gives an agent a persistent, interactive terminal.89If you have used Claude Code / Codex to run shell commands, you have probably hit the same wall: tool calls tend to be stateless. Each call starts "fresh", so environment variables disappear, interactive programs cannot be driven reliably, and long-running processes get cut off or orphaned while the agent is thinking.1011PiloTY exists to make the agent's terminal behave more like a human's: start something in a real terminal, come back later, and keep going.1213Warning: PiloTY exposes unrestricted terminal access. Treat it like giving the agent your keyboard.1415## What it enables1617- Long-running commands: builds, installs, migrations, test suites. Start once, check output later.18- Log monitoring: `tail -f`, `journalctl -f`, `kubectl logs -f`, CI logs, service restarts.19- "Vibe debugging": keep a REPL/debugger open while the agent reads code and tries ideas (`python`, `ipython`, `pdb`).20- Privileged operations: handle interactive password prompts (`sudo`, SSH passwords, key passphrases).21- SSH-based devops: keep a remote login session alive across tool calls; run remote commands in the same shell.22- Terminal UIs: `less`, `man`, `top`, `vim` can work, but cursor-heavy programs often require screen snapshots instead of plain text output.2324## Quickstart2526PiloTY is meant to be launched by an MCP client over stdio.2728Add it to Codex CLI as an MCP server:2930```bash31codex mcp add piloty -- uvx --from git+https://github.com/yiwenlu66/PiloTY.git piloty32```3334If you prefer SSH-based Git fetch:3536```bash37codex mcp add piloty -- uvx --from git+ssh://git@github.com/yiwenlu66/PiloTY.git piloty38```3940If you already have a local clone:4142```bash43codex mcp add piloty -- uv --directory /path/to/PiloTY run piloty44```4546Run the server command directly (without adding it to an MCP client):4748```bash49uvx --from git+https://github.com/yiwenlu66/PiloTY.git piloty50```5152## Mental model5354One session is one real interactive terminal that stays alive across tool calls.5556- State persists: cwd, environment variables, foreground process, remote SSH connection, REPL/debugger state.57- PiloTY tracks both the raw output stream and a rendered screen/scrollback view.5859PiloTY keeps two representations:6061- `output`: incremental text stream (optionally ANSI-stripped)62- Rendered screen/scrollback: what a human would see in a terminal6364Sessions are addressed by a `session_id` string. Reusing the same id is what keeps state.6566## Integration notes (for MCP integrators)6768MCP does not expose a standard "client cwd" field, so the first step is always to create a session with an explicit working directory, then reuse the same `session_id` for subsequent calls.6970Typical agent workflow:7172- Create a session (explicit cwd) and reuse the same `session_id`.73- Run commands, poll for output, and send raw input/control keys for interactive programs.74- For cursor-heavy TUIs, rely on rendered screen snapshots/scrollback rather than plain text output.75- Use `expect_prompt` after `ssh` or other login flows where the prompt appears later.76- If prompt detection is wrong (looks idle at a prompt but status stays "running"), configure a custom shell-prompt regex.77- Use `send_password` for secret entry; terminate the session when done.7879For exact tool names, arguments, and return fields, use your MCP client's tool schema or read `piloty/mcp_server.py`.8081## Limitations8283- Status/prompt detection is best-effort and can be wrong (especially for custom prompts and cursor-heavy TUIs).84- Plain text output can be misleading for full-screen programs; use screen snapshots when layout matters.85- `send_password()` suppresses transcript logging and terminal echo for that send. It does not prevent other prompts/programs from echoing secrets later.86- Quiescence-based output collection can be confused by programs that print periodic noise. Tune with `PILOTY_QUIESCENCE_MS` (default `1000`).8788## Logs8990Each server instance writes session logs under `~/.piloty/`:9192- `~/.piloty/servers/<server-instance-id>/sessions/<session-id>/transcript.log`: raw PTY bytes (combined stdout/stderr)93- `~/.piloty/servers/<server-instance-id>/sessions/<session-id>/commands.log`: inputs sent (best-effort)94- `~/.piloty/servers/<server-instance-id>/sessions/<session-id>/interaction.log`: inputs plus captured output (best-effort)95- `~/.piloty/servers/<server-instance-id>/sessions/<session-id>/session.json`: metadata snapshot96- `~/.piloty/active/<server-instance-id>/<session-id>`: symlink to the current session directory (when symlinks are supported)9798Server logs default to `/tmp/piloty.log`.99100`tools/session_viewer.py` can inspect sessions:101102```bash103python tools/session_viewer.py list104python tools/session_viewer.py info <server-instance-id>/<session-id>105python tools/session_viewer.py tail -f <server-instance-id>/<session-id>106```107108## Development109110Repository layout:111112```113piloty/114 core.py # PTY + terminal renderer + session logs115 mcp_server.py # MCP tools + state inference116tests/117tools/118 pty_playground.py119 session_viewer.py120```121122Run tests:123124```bash125python -m pytest -q126```127128License: Apache License 2.0, see `LICENSE`.129
Full transparency — inspect the skill content before installing.