MCP server for interactive terminal sessions β SSH, REPLs, database CLIs, TUI apps
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Every AI coding tool hits the same wall: no real terminal access.
Claude Code's Bash tool, GitHub Copilot, and Codex all run commands in isolated subprocesses. Each command starts fresh. No state carries over. That means:
terminal-mcp gives AI agents a real terminal. Persistent PTY sessions that survive across tool calls. Send commands, read output, press keys, navigate TUIs - exactly like a human at a terminal.
One command. Works with Claude Code, Claude Desktop, VS Code, Cursor, and Windsurf.
Add to ~/.claude.json or project .mcp.json:
Add to claude_desktop_config.json:
Click the one-click install badge above, or add to .vscode/mcp.json:
Add to ~/.codeium/windsurf/mcp_config.json:
| Feature | What It Does |
|---|---|
| Persistent Sessions | Real PTY sessions that survive across tool calls |
| Send + Read in One Call | session_interact halves LLM round trips |
| Pattern-Based Reads | wait_for blocks until regex matches - no guessing timeouts |
| Auto TUI Detection | Detects htop, vim, etc. and auto-switches to screen snapshot mode |
| Output Diff Mode | Returns only changed screen lines - minimizes tokens |
| Special Keys | Arrow keys, Tab, F1-F12, Home/End, Page Up/Down |
| Control Characters | Ctrl-C, Ctrl-D, Ctrl-Z, Ctrl-L, telnet escape |
| Dangerous Command Gate | Blocks rm -rf, DROP TABLE, curl|sh - requires confirmation |
| OSC 133 Shell Integration | Auto-detects command boundaries and exit codes |
| Smart Truncation | Four strategies to prevent context overflow |
| Secret Input | Send passwords without logging |
| Dynamic Resize | Resize terminal on the fly with SIGWINCH |
| Idle Cleanup | Auto-closes idle sessions |
| Cross-Platform | Linux, macOS, and Windows support |
terminal-mcp exposes 9 MCP tools. Full details in docs/tools.md.
| Tool | Purpose |
|---|---|
session_create | Spawn a persistent terminal session |
session_send | Send text, keys, or control characters |
session_read | Read output (stream, snapshot, auto, diff modes) |
session_interact | Send + read in one call |
session_wait_for | Wait for regex pattern in output |
session_exec | One-shot command execution |
session_close | Close a session gracefully |
session_resize | Resize terminal dimensions |
session_list | List active sessions |
Each session is backed by a real PTY via pexpect.spawn (or PopenSpawn on Windows). For full architecture details, see docs/architecture.md.
All settings configurable via TERMINAL_MCP_* environment variables. Full reference in docs/configuration.md.
| Setting | Env Var | Default |
|---|---|---|
| Max sessions | TERMINAL_MCP_MAX_SESSIONS | 10 |
| Idle timeout | TERMINAL_MCP_IDLE_TIMEOUT | 1800 (30 min) |
| Safety gate | TERMINAL_MCP_SAFETY_GATE | on |
| Buffer cap | TERMINAL_MCP_MAX_BUFFER_BYTES | 1000000 (1MB) |
| Truncation | TERMINAL_MCP_TRUNCATION_MODE | tail |
Example with custom settings:
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/terminal-mcp)<a href="https://allmcps.com/mcp/terminal-mcp"><img src="https://allmcps.com/api/badge/terminal-mcp?style=directory" alt="Terminal MCP on AllMCPs" /></a>