termio-mcp
This server provides an MCP interface for creating and managing persistent interactive terminal and serial sessions, enabling AI assistants to run commands, automate SSH logins, interact with REPLs/debuggers, intercept bootloaders, and retrieve timestamped output.
Spawn interactive processes (bash, ssh, python, gdb, docker, etc.) in a PTY with configurable terminal size, working directory, and environment.
Connect to hardware or virtual serial ports (UART, router console) with configurable baud rate.
Execute commands and wait for prompts atomically using
exec_expect, returning structured success/output/timeout/exit-code results.Match regex/substring patterns with
expect, optionally sending commands or polling with repeated characters (e.g., space bar to interrupt U-Boot autoboot).Send raw text or escape sequences (e.g., Ctrl+C, Escape, Enter) to sessions.
Non-blockingly read newly accumulated stream buffer output with backspace folding.
Retrieve recent line history with precise timestamps and
↳continuation markers for pauses ≥50ms.List, switch, and close active PTY and serial sessions.
Enumerate available serial ports on the host.
Check runtime diagnostics, buffer usage, and background daemon health via
status.Support multi-session concurrency with thread-safe management and session guarding.
Provide ANSI/backspace sanitization and causal command-echo preservation for clean AI analysis.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@termio-mcp SSH into root@192.168.1.1 and run cat /etc/config/network"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
expty-mcp
expty-mcp is a high-performance Model Context Protocol (MCP) server that equips AI assistants (Claude Code, Cursor, Antigravity, VS Code) with persistent, zero-loss Interactive PTY Process and Serial Communication capabilities.
Engineered specifically for persistent SSH sessions, remote server administration, local shells, REPLs, container debugging, and hardware serial ports (UART/U-Boot). It features an Atomic Expect Engine, continuous background ingestion daemon, transport-level microsecond timestamping with intelligent 50ms continuation detection, and full cross-chunk ANSI sanitization.
Architecture Design
Related MCP server: Interactive Shell MCP
Key Features
Zero-Loss Background Daemon: Dedicated reader daemon continuously ingests bytes into memory in real time—eliminating dropped output during LLM reasoning pauses.
Unified PTY & Serial Transports: Seamlessly spawn local processes (
bash,python,gdb), SSH sessions (ssh user@router), or connect to physical UART devices (/dev/ttyUSB0,COM3).Accurate Transport-Level Timestamping: Timestamps are stamped at the moment bytes leave the OS kernel/driver system call, avoiding queue or scheduling jitter.
Smart 50ms Packet Continuation:
Packet fragments arriving within
< 50msare smoothly merged into a single line.Fragments arriving after
>= 50ms(e.g. driver pause, slow command) are split into separate lines tagged with↳and their own timestamp—enabling effortless correlation against test framework logs (Pytest, RobotFramework).
Atomic Expect Engine (
expect): Match regex or substring prompt patterns atomically (['password:', '# ', '>>>']) with buffer slicing and retention.Prompt-Aware Execution (
exec_expect): Send commands and wait for prompt return in a single call, returning structured JSON results with execution status, optionalcheck_exit_code_cmdprobe, andinterrupt_on_timeoutrecovery.Causal Anchor Preservation: Preserves command echo in output streams, providing LLMs with an unbroken causal chain for self-correction without regex stripping bugs.
Cross-Chunk ANSI & Backspace Sanitization: Intelligently handles split escape sequences (e.g.
\x1b[in chunk 1 and31min chunk 2) and terminal cursor backspace (\b/0x08) line-editor overwriting artifacts.Thread-Safe Multi-Session Management: Concurrently manage multiple terminal sessions with strict session guarding and double-checked locking auto-spawn.
Fast Process Exit Detection: Instantly detects when a child process or SSH connection terminates, returning exit codes immediately without waiting for timeouts.
Periodic Injection (
poll_cmd): Inject keepalive characters or autoboot interrupt keys (e.g. spaces for U-Boot) at high frequency during expect wait windows.100% Cross-Platform: Native POSIX PTY on Linux & macOS (
ptyprocess), leak-free Windows ConPTY worker queue (pywinpty), and cross-platform Serial support (pyserial).
Available MCP Tools
Tool | Description |
| Spawn a new interactive process ( |
| Connect to a physical or virtual serial port ( |
| Execute a command and wait for prompt to return, returning structured execution status and clean output. Supports |
| Atomically send a command and wait for regex patterns (ideal for SSH login / prompt sync / bootloader interception). Supports |
| Send raw keys or escape sequences (e.g. |
| Non-blocking read of newly accumulated stream buffer with backspace folding. |
| Fetch recent line history. By default, formats with |
| List all active PTY and Serial sessions with runtime health status. |
| Switch the default active session (most tools accept |
| Terminate and cleanly shut down an active session. |
| Enumerate connected physical and virtual serial ports on the host. |
| Query runtime diagnostics, buffer usage, and transport health. |
Practical Examples
1. Persistent SSH Session (No repeated logins)
// Step 1: Spawn SSH connection
// Tool: spawn
{
"command": "ssh root@192.168.1.1",
"name": "openwrt-router"
}
// Step 2: Handle password prompt with Expect
// Tool: expect
{
"patterns": ["password:", "# "],
"command": "admin",
"timeout": 10.0
}
// Step 3: Run interactive commands effortlessly
// Tool: exec_expect
{
"command": "cat /etc/config/network"
}2. Time-Correlated Log Analysis (Aligning with Test Frameworks)
// Tool: get_history
{
"limit": 5,
"with_timestamps": true
}Output:
[2026-09-13 15:30:45.100] [Kernel] Initializing network interface eth0...
[2026-09-13 15:30:45.120] [Kernel] PHY driver link speed: 1000Mbps
[2026-09-13 15:30:45.300] [Kernel] Loading crypto module...
[2026-09-13 15:30:46.850] ↳ done (took 1550ms)
[2026-09-13 15:30:46.870] IPQ807x# Notice how the 1.55-second driver pause is clearly split with ↳ , immediately pinpointing where execution stalled relative to your test runner logs.
3. Interactive Python REPL / Debugger
// Tool: spawn
{
"command": "python3",
"name": "python-repl"
}
// Tool: exec_expect
{
"command": "import math; math.factorial(10)"
}4. Hardware UART Bootloader Interception
// Step 1: Open serial port
// Tool: serial
{
"port": "/dev/ttyUSB0",
"baudrate": 115200
}
// Step 2: Interrupt autoboot with high-frequency space injection
// Tool: expect
{
"patterns": ["IPQ807x#", "U-Boot#"],
"poll_cmd": " ",
"poll_interval": 0.05,
"timeout": 15.0
}Installation & Configuration
Option 1: Fast Zero-Install with uvx (Recommended)
No manual installation required. MCP clients can run expty-mcp directly via Astral uv:
# Run directly from PyPI
uvx expty-mcpOption 2: Install via pip or uv
# Using uv
uv pip install expty-mcp
# Or using standard pip
pip install expty-mcpOption 3: From Source (Editable Mode)
git clone https://github.com/weyou/expty-mcp.git
cd expty-mcp
uv pip install -e .Client Configuration
1. Claude Desktop / Claude Code
Using uvx (Zero-Install, Recommended):
{
"mcpServers": {
"expty": {
"command": "uvx",
"args": ["expty-mcp"]
}
}
}Using installed Python environment:
{
"mcpServers": {
"expty": {
"command": "python3",
"args": ["-m", "expty_mcp"]
}
}
}2. Antigravity / Google AI Assistant
Add to ~/.gemini/config/mcp_config.json:
{
"mcpServers": {
"expty": {
"command": "uvx",
"args": ["expty-mcp"]
}
}
}3. Cursor IDE
Add to .cursor/mcp.json or Cursor Global Settings:
{
"mcpServers": {
"expty": {
"command": "uvx",
"args": ["expty-mcp"]
}
}
}Testing & Code Quality
pytest -v
ruff check .License
This project is licensed under the MIT License.
Available Tools
12 toolsclose_sessionB
Close and terminate an interactive session.
Args: session_id: Target session ID to close (defaults to active session).
Inputs: session_id. Returns: result
exec_expectA
Execute a shell, REPL, or bootloader command and automatically wait for prompt to return. Output preserves original terminal stream (including command echo) as a causal anchor for AI analysis. ANSI escape codes are stripped for readability.
Returns a structured result with 'success', 'output', 'timeout', 'process_exited', 'exit_code', and 'elapsed_seconds' fields.
IMPORTANT: For long-running commands (e.g. apt-get install, make, large file transfers), use send instead to dispatch the command, then poll with read_buffer periodically to check progress. Do NOT use exec_expect for commands that may take more than a few seconds, as it will report a timeout.
Args: command: The command line to execute. prompts: Optional list of prompt patterns (defaults to standard shell and REPL prompts). timeout: Maximum seconds to wait for the prompt to return. session_id: Target session ID (defaults to currently active session).
Inputs: command (required), prompts, timeout, session_id. Returns: object
expectA
Atomically send an optional command and match incoming stream against prompt patterns. Ideal for multi-step authentication (SSH login/password), prompts, and U-Boot interception.
Args: patterns: List of regex/substring patterns to expect (e.g. ['password:', '# ']). command: Optional command/response to send before waiting. timeout: Maximum seconds to wait. Defaults to 10.0s. poll_cmd: Characters to repeatedly send during wait (e.g. ' ' for autoboot intercept). poll_interval: Interval between repeating poll_cmd. Defaults to 0.05s. session_id: Target session ID (defaults to currently active session).
Inputs: patterns (required), command, timeout, poll_cmd, +2 more. Returns: object
get_historyA
Retrieve recent chronological line history captured by the background daemon.
By default, each line is prefixed with an accurate wall-clock timestamp [YYYY-MM-DD HH:MM:SS.mmm] captured at the transport reception level. If a line was split across packets with a pause of >= 50ms (e.g. driver pause, delayed response), the continuation line is prefixed with '↳ ' and tagged with its own timestamp for precise correlation against test framework logs.
Args: limit: Number of recent lines to retrieve (default: 50). with_timestamps: If True (default), attaches wall-clock timestamps and continuation symbols on the fly. If False, returns raw clean text lines without timestamps. session_id: Target session ID (defaults to currently active session).
Inputs: limit, session_id, with_timestamps. Returns: result
list_portsA
Enumerate attached physical and virtual serial ports on the host.
Inputs: no named parameters. Returns: result
list_sessionsA
List all active PTY and Serial sessions with runtime health status.
Inputs: no named parameters. Returns: result
read_bufferA
Read newly accumulated text from the stream buffer without blocking.
Args: clear: If True, flushes the read buffer after fetching. session_id: Target session ID (defaults to currently active session).
Inputs: clear, session_id. Returns: result
sendB
Send raw characters or escape sequences (e.g. '\x03' for Ctrl+C, '\x1b' for Escape, spaces).
Args: text: Raw text or escape sequence string. send_enter: If True, appends a newline. session_id: Target session ID (defaults to currently active session).
Inputs: text (required), send_enter, session_id. Returns: result
serialB
Connect to a hardware or virtual serial device (UART / router console / microcontroller).
Args: port: Serial device path (e.g. '/dev/ttyUSB0', 'COM3'). baudrate: Baud rate (e.g. 115200, 9600, 57600). name: Optional friendly name for this session.
Inputs: name, port, baudrate. Returns: object
spawnC
Spawn a new persistent interactive process (bash, ssh, python, gdb, docker, etc.) in a PTY.
Args: command: Command to execute (defaults to platform shell: bash or powershell.exe). name: Optional friendly name for this session (e.g. 'router-ssh'). cwd: Optional working directory. env: Optional environment variables dictionary. rows: Terminal rows (default: 40). cols: Terminal columns (default: 120).
Inputs: cwd, env, cols, name, +2 more. Returns: object
statusB
Check connection health, buffer statistics, and background daemon status.
Args: session_id: Target session ID (defaults to active session).
Inputs: session_id. Returns: object
switch_sessionC
Switch the default active session.
Args: session_id: Target session ID to make active.
Inputs: session_id (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Several tools have overlapping purposes: exec_expect and expect both execute/match terminal output, while get_history and read_buffer both retrieve output. Descriptions provide guidance, but an agent could still misselect between them.
Most tools follow a snake_case verb_noun pattern (get_history, list_sessions, switch_session, close_session, read_buffer, list_ports). A few single-word names (serial, spawn, send, status) deviate slightly but remain readable and predictable.
12 tools is well within the ideal range for a terminal/serial session management server. Each tool covers a distinct operational area such as session creation, I/O, discovery, and health monitoring.
The surface covers core lifecycle operations: connect/spawn, list, switch, close, send, read, expect/exec, history, ports, and status. Minor gaps exist (e.g., explicit terminal resize or file transfer), but agents can work around them with existing tools.
Maintenance
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Hosted runtime for persistent agent teams, durable workflows, memory, schedules, and goals.
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Persistent Linux computers for AI agents: desktop, signed-in browser, vault, apps and shell.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides stateful, interactive terminal access for LLMs to spawn and maintain persistent processes like SSH sessions, debuggers, and REPLs with continuous input/output interaction across commands.8-
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to create and manage persistent, interactive shell sessions with full terminal emulation and PTY support. It allows for sequential command execution and supports interactive programs like vim or htop through specialized streaming and snapshot output modes.5MIT
- FlicenseAqualityDmaintenanceEnables AI agents to start and manage pseudo-terminal sessions, run shell commands and interact with REPLs programmatically.7-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents or human operators to spawn, monitor, drive, and hook into child terminal sessions—such as CLI tools, interactive shells, and polyglot runtimes—via POSIX pseudo-terminals, providing multiplexed control, event interception, and memory-bounded observability for orchestration.GPL 3.0