mcp-terminal-bridge
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., "@mcp-terminal-bridgeStart a terminal session and run 'npm install' in my project directory."
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.
MCP Terminal Bridge (mcp-terminal-bridge)
A cross-platform Model Context Protocol (MCP) server that provides AI agents (Cursor, Windsurf, Claude Code, Antigravity, etc.) with persistent, interactive pseudo-terminals (PTYs).
Standard AI agent execution tools rely on basic child-process pipes (child_process.exec / spawn), which fail on interactive operations (like AWS SSM sessions, SSH prompts, sudo passwords, and REPLs) and pollute LLM context with ANSI escape noise. This project bridges that gap by running true pseudo-terminals (PTYs) with headless VT100 emulation, deterministic exit-code probing, concurrent execution queuing, and an embedded zero-config Web TUI mirror.
Setup & Installation
Add terminal-bridge to your MCP settings (Cursor, Claude Desktop, Windsurf, Claude Code, etc.):
{
"mcpServers": {
"terminal-bridge": {
"command": "npx",
"args": ["-y", "mcp-terminal-bridge"]
}
}
}Related MCP server: pty-mcp
The Problem Solved
AWS SSM Sessions (
aws ssm start-session): Fails or hangs becausesession-manager-pluginrequires an interactive TTY and terminal dimensions.SSH Connections (
ssh user@host): Fails with "Pseudo-terminal will not be allocated because stdin is not a terminal".Interactive Questions & Prompts: Prompts like
Are you sure you want to continue connecting (yes/no)?,[Y/n]confirmations, or password challenges freeze because standard tools wait indefinitely for process exit.Concurrent Input Collisions: When an AI agent fires multiple commands simultaneously, characters collide on screen and corrupt the shell prompt.
ANSI & Escape Noise: Raw terminal streams contain thousands of VT100 control codes that waste tokens and confuse LLM parsers.
The Solution:
Cross-Platform PTY Layer (
node-pty): Spawns true pseudo-terminals using Windows ConPTY on Windows and POSIX PTY (openpty) on Linux & macOS (identical to VS Code's integrated terminal).Headless Terminal Emulation (
@xterm/headless): Parses raw ANSI streams into clean, human-readable 2D text grids and scrollback lines without inflating token usage.Three-Tier Completion Engine:
Sentinel Probing: Deterministically captures command exit codes (
$?) without terminating the remote session.Idle Quiescence: Detects interactive prompts when output pauses (e.g.
(yes/no)?) so the agent can respond usingterminal_send_input.Prompt Regex: Fallback detection for custom shell prompts.
Concurrent Execution Queuing: Parallel command executions on the same session are chained via a sequential mutex queue (
executionQueue), preventing overlapping input, character scrambling, and screen corruption.Embedded Web TUI Mirror: Built-in HTTP and WebSocket server running at
http://localhost:4040(with Hub & Satellite multi-client support). Developers can watch the AI agent type live at 60 FPS, see live queued command badges (⏳ X queued), and toggle Interactive Takeover to type into the terminal directly from the browser.Asciinema Auto-Recording: Every session is automatically recorded into standard Asciinema v2 format (
.castfile in~/.mcp-terminal-bridge/recordings/) for post-mortem replay and auditing.
Exposed MCP Tools
Tool | Description | Key Parameters |
| Connects to an AWS EC2 instance via SSM or SSH-over-SSM |
|
| Spawns a persistent local shell or custom interactive CLI |
|
| Runs a command in an active session and waits for completion/prompt |
|
| Sends text answers, passwords, or control keys ( |
|
| Reads the current clean 2D screen text (like a screenshot in plain text) |
|
| Lists all active sessions, process IDs, and uptimes | None |
| Gracefully exits or terminates a session |
|
| Validates presence of AWS CLI, Session Manager Plugin, and OpenSSH | None |
Example AI Agent Workflows
Scenario 1: AWS SSM Session
Agent initiates SSM:
// Tool Call: terminal_ssm_connect { "target": "i-0123456789abcdef0", "region": "us-east-1" }Agent runs commands on the remote EC2 instance:
// Tool Call: terminal_execute { "sessionId": "term-xxxx", "command": "uname -a && cat /etc/os-release" }Agent stops a runaway process with Ctrl+C:
// Tool Call: terminal_send_input { "sessionId": "term-xxxx", "specialKey": "ctrl_c" }
Scenario 2: Handling Interactive Prompts
Agent runs
sudo apt install nginx.Output stops with
Do you want to continue? [Y/n].Server returns status
"idle_prompt"with the question text.Agent calls:
// Tool Call: terminal_send_input { "sessionId": "term-xxxx", "input": "Y\n" }
Architecture
mcp-terminal-bridge/
├── src/
│ ├── index.ts # FastMCP server entry point (stdio & HTTP stream)
│ ├── osal/ # Operating System Abstraction Layer
│ │ ├── detector.ts # Platform and shell auto-detection (Linux, macOS, Windows)
│ │ ├── paths.ts # Binary resolution for aws, session-manager-plugin, ssh
│ │ └── keys.ts # Terminal keystroke and control sequences
│ ├── pty/ # Pseudo-terminal & Emulation
│ │ ├── virtual_terminal.ts# @xterm/headless 2D screen buffer & ANSI sanitization
│ │ ├── completion.ts # Sentinel exit code detector & quiescence debounce
│ │ ├── session.ts # Stateful PTY session wrapper
│ │ └── manager.ts # Multi-session lifecycle registry
│ └── tools/ # FastMCP Tool Registrations
│ └── index.ts # Tool schemas and execution logic
├── test/
│ └── test_session.ts # Integration test suite
├── package.json
└── tsconfig.jsonLicense
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Develop, manage, and debug Railway projects, services, and deployments from within agents.
Remote shell and detached long-running jobs on your own machines — no SSH, open ports or VPN.
Run AI customer support from your terminal: conversations, knowledge base, and chat widget.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides a pseudo-terminal (PTY) interface that allows AI agents to interact with command-line tools requiring interactive prompts. It enables agents to autonomously spawn processes, read output, and send inputs for workflows like database migrations and project scaffolding.11 npm1MIT
- FlicenseAqualityCmaintenanceEnables AI agents to start and manage pseudo-terminal sessions, run shell commands and interact with REPLs programmatically.7-
- AlicenseNot gradedqualityCmaintenanceProvides AI agents with fully interactive terminal sessions, including TUI support, keyboard control, and screen capture across Windows, Linux, and Mac.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to interact with interactive CLI processes via a real PTY, allowing them to send keystrokes, read screen output, and handle interactive prompts.4 npm1MIT