Skip to main content
Glama

Terminator

Playwright for terminals — an MCP server that lets AI agents interact with CLI applications.

Terminator wraps tmux to give AI agents the ability to spawn CLI processes, type into them, read what's on screen, and assert on the output. It's like Playwright, but for terminal applications instead of web browsers.

Why

Testing CLI applications today means either:

  • A human manually runs commands and eyeballs the output

  • Fragile expect-style scripts that match on raw byte streams

Terminator gives you a virtual terminal with a proper PTY, ANSI rendering, and a screen buffer — exactly what a human sees. An AI agent (or any test script) can spawn a process, interact with it, take "screenshots" of the rendered terminal, and assert on the visible output.

Related MCP server: shell-use

Prerequisites

  • Node.js >= 20

  • tmux >= 3.0 (brew install tmux on macOS, apt install tmux on Linux)

Installation

npm install -g terminator-mcp

Or clone and build from source:

git clone https://github.com/silver83/terminator.git
cd terminator
npm install
npm run build

Usage with Claude Code

Add to your Claude Code MCP config (~/.claude/settings.json):

{
  "mcpServers": {
    "terminator": {
      "command": "node",
      "args": ["/path/to/terminator/build/index.js"]
    }
  }
}

Then Claude can use the terminal tools directly:

"Spawn a bash session, run ls -la, and tell me what files are in the directory"

Tools

Tool

Description

terminal_spawn

Start a CLI process in a virtual terminal

terminal_type

Type text into the terminal

terminal_send_key

Send special keys (Enter, Escape, Ctrl-C, Tab, arrows, etc.)

terminal_screenshot

Capture what the user currently sees (rendered text)

terminal_wait_for

Poll until a regex pattern appears on screen

terminal_assert

Assert screen contains expected text or pattern

terminal_close

Close the terminal session

Example: Testing a CLI application

# 1. Spawn the application
terminal_spawn(command: "python3")

# 2. Wait for the REPL to load
terminal_wait_for(pattern: ">>>")

# 3. Type a command
terminal_type(text: "print('hello world')")
terminal_send_key(key: "enter")

# 4. Wait for output and verify
terminal_wait_for(pattern: "hello world")
terminal_assert(text: "hello world")

# 5. Clean up
terminal_send_key(key: "ctrl-d")
terminal_close()

Example: Testing an interactive prompt

# Spawn an app that shows an interactive prompt
terminal_spawn(command: "my-cli-tool")

# Wait for the prompt to render
terminal_wait_for(pattern: "Are you sure\\?")

# Take a screenshot to see the full UI
terminal_screenshot()

# Type a response
terminal_type(text: "y")
terminal_send_key(key: "enter")

# Verify the result
terminal_wait_for(pattern: "Done!")
terminal_assert(text: "Done!")

How it works

Terminator is a thin MCP server that delegates to tmux:

  • Spawn = tmux new-session -d -s <id> -x <cols> -y <rows> <command>

  • Type = tmux send-keys -t <id> -l <text> (literal characters)

  • Send key = tmux send-keys -t <id> <key> (interpreted key names)

  • Screenshot = tmux capture-pane -t <id> -p (rendered text, ANSI stripped)

  • Wait for = polling loop over capture-pane until regex matches

  • Assert = capture-pane + string/regex match

  • Close = tmux kill-session -t <id>

tmux handles all the hard parts: PTY allocation, ANSI escape sequence parsing, screen buffer management, and terminal rendering. Terminator just exposes it as MCP tools.

Running tests

npm run build
npm test

License

MIT

Available Tools

9 tools
terminal_assertA

Assert that the terminal screen contains expected text or matches a regex pattern. Returns pass/fail with the current screen content and a human-readable message.

Inputs: text (required), session_id (required), regex.

terminal_closeA

Close a terminal session and kill the underlying process. Idempotent — safe to call on already-closed sessions.

Inputs: session_id (required).

terminal_exportA

Export the session recording as an asciicast v2 (.cast) file, playable in asciinema-player or asciinema.org. Recording happens automatically — every type, send_key, and screenshot is captured with timing.

Inputs: session_id (required), save_path.

terminal_screenshotA

Capture what the user currently sees in the terminal — the rendered text grid with ANSI escape sequences stripped. This is the equivalent of looking at the screen.

Inputs: session_id (required).

terminal_send_keyB

Send a special key to the terminal. Supported keys: enter, escape, tab, space, backspace, delete, up, down, left, right, home, end, pageup, pagedown, ctrl-c, ctrl-d, ctrl-z, ctrl-l, ctrl-a, ctrl-e, ctrl-k, ctrl-u, ctrl-w, ctrl-r, ctrl-p, ctrl-n.

Inputs: key (required), session_id (required).

terminal_spawnA

Start a CLI process in a virtual terminal (tmux session). Returns a session_id for subsequent interactions. The process runs in a real PTY with proper ANSI rendering.

Inputs: command (required), env, args, cols, +1 more.

terminal_traceA

Retrieve the recorded trace of all terminal operations since the server started. Each event has a t_ms timestamp, event type, session ID, and operation-specific fields. Useful for debugging timing issues, sharing with AI agents for analysis, or saving as a test artifact.

Inputs: save_path, session_id.

terminal_typeA

Type text into the terminal. Characters are sent literally (no key name interpretation). Use terminal_send_key for special keys like Enter or Ctrl-C.

Inputs: text (required), session_id (required), delay_ms.

terminal_wait_forA

Poll the terminal screen until a regex pattern appears or timeout is reached. Useful for waiting for prompts, output, or UI elements to render.

Inputs: pattern (required), session_id (required), timeout_ms, interval_ms.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool maps to a distinct terminal operation: spawn, type, send_key, read screen, poll, assert, close, export, trace. The main soft overlap is between terminal_screenshot, terminal_wait_for, and terminal_assert, which all inspect screen content, though their return semantics (snapshot vs. blocking poll vs. pass/fail assertion) are described clearly enough to distinguish.

    Naming Consistency5/5

    Every tool uses the same terminal_ prefix followed by a snake_case verb or noun (terminal_spawn, terminal_send_key, terminal_wait_for). The pattern is fully predictable and readable.

    Tool Count5/5

    Nine tools is well-scoped for a PTY automation server: input, observation, synchronization, assertion, lifecycle, and recording each get dedicated coverage without redundancy.

    Completeness4/5

    The lifecycle is essentially covered: spawn, drive, observe, wait, assert, close, plus recording export and trace for artifacts. Minor gaps remain—no list_sessions/exit-code or process-status retrieval and no terminal resize, which agents may need for multi-session or long-running workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables agents to interact with CLI applications like vim, htop, and gdb by sending key inputs and capturing terminal output through tmux sessions.
      6
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to interact with real terminal sessions across local and remote hosts, driving multi-turn interactive programs like TUIs, REPLs, and SSH prompts through MCP.
      72
      MIT