SuperAPI AI Directory

PiloTY

Control interactive terminals (PTY) with stateful sessions, SSH connections and background process management.

Open website

About this tool

PiloTY (PTY for your AI Copilot) is an MCP server designed to provide AI agents with a persistent, interactive terminal. If you have ever used Claude Code or Codex to run shell commands, you may have encountered the problem of stateless tool calls: each call starts from a "fresh" state, causing environment variables to be lost, interactive programs to be unable to be driven reliably, and long-running processes to be cut off or become orphaned while the agent is thinking. PiloTY makes an agent's terminal behavior more human-like: start a task in a real terminal, come back later, and continue.

Main capabilities

PiloTY supports a variety of scenarios:

  • Long-running commands: builds, installs, migrations, test suites. Start once, check the output later.
  • Log monitoring: tail -f, journalctl -f, kubectl logs -f, CI logs, service restarts.
  • "Vibe debugging": keep a REPL/debugger open (python, ipython, pdb) while the agent reads code and tries out ideas.
  • Privileged operations: handle interactive password prompts (sudo, SSH passwords, key passphrases).
  • SSH-based DevOps: keep a remote login session alive between tool calls; run remote commands in the same shell.
  • Terminal UIs: less, man, top, vim can work, but cursor-intensive programs usually require screen snapshots rather than plain text output.

How to use

PiloTY is launched by an MCP client via stdio. It can be added as an MCP server for the Codex CLI, or the server command can be run directly (without adding it to an MCP client). A session is a real interactive terminal that stays alive between tool calls. State is persistent: current working directory, environment variables, foreground process, remote SSH connection, REPL/debugger state.

PiloTY tracks the raw output stream and the rendered screen/scrollback view. Public MCP results separate the call result from the terminal interpretation: outcome: success, deadline_exceeded, eof, error, invalid_session, or terminated; terminal_state: a best-effort rendered state classification after the call (running, ready, password, confirm, repl, editor, pager, unknown). Sessions are addressed by a session_id string. Reusing the same id preserves state.

Integration notes (for MCP integrators)

MCP does not expose a standard "client current working directory" 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. A typical agent workflow:

  1. Create a session (explicit cwd) and reuse the same session_id.
  2. Use send_line to submit newline-terminated commands, send_text to send raw bytes, and send_control / send_signal to send interrupts.
  3. Use wait_for_output for time-based PTY output waiting, wait_for_regex for content-based waiting, and wait_for_shell_prompt after ssh or similar login flows.
  4. Use snapshot_screen / snapshot_scrollback when layout matters. Snapshot tools are passive and do not ingest new PTY bytes.
  5. If prompt detection is wrong, configure a custom shell prompt regular expression.
  6. Use send_password to enter secrets; terminate the session when done.

For exact tool names, parameters, and return fields, use your MCP client's tool schema or read piloty/mcp_server.py.

deadline_s is a wall-clock time budget. On send/wait tools, it is not "process completion time." Drain-based tools (send_line, send_text, send_control, send_password, send_signal, wait_for_output) stop after the server quiescence policy (PILOTY_QUIESCENCE_MS, default 1000) or when deadline_s expires. wait_for_output may return partial output with outcome=deadline_exceeded if output has started but the PTY never went quiet before the deadline. wait_for_regex first checks the already-rendered scrollback, then waits for new PTY bytes. wait_for_shell_prompt, while waiting,consumes PTY output and returns the consumed bytes in output.

Limitations and caveats

Terminal state detection is best-effort and can be wrong (especially custom prompts and cursor-heavy TUIs). Plain-text output can be misleading for full-screen programs; use screen snapshots when layout matters. send_password() suppresses transcript logging and terminal echo for that send. It cannot prevent other prompts/programs from echoing the secret later. Quiescence-based output collection can be confused by programs that print noise periodically. Tune with PILOTY_QUIESCENCE_MS (default 1000).

Each server instance writes session logs under ~/.piloty/:

  • ~/.piloty/servers/<server-instance-id>/sessions/<session-id>/transcript.log: raw PTY bytes (merged stdout/stderr)
  • ~/.piloty/servers/<server-instance-id>/sessions/<session-id>/commands.log: sent input (best-effort)
  • ~/.piloty/servers/<server-instance-id>/sessions/<session-id>/interaction.log: input plus captured output (best-effort)
  • ~/.piloty/servers/<server-instance-id>/sessions/<session-id>/session.json: metadata snapshot
  • ~/.piloty/active/<server-instance-id>/<session-id>: symlink to the current session directory (when symlinks are supported) Server logs are located at /tmp/piloty.log by default. tools/session_viewer.py can inspect sessions.

Security warning

PiloTY exposes unrestricted terminal access. Treat it like handing your keyboard to an agent.

License

Apache License 2.0, see LICENSE for details.