terminal-mcp
Click on "Install 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., "@terminal-mcpSSH into the staging server and check logs"
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.
The Problem
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:
No SSH sessions - Can't connect to a remote server and run multiple commands
No REPLs - Can't use Python, Node, or Ruby interpreters interactively
No database CLIs - Can't maintain a psql, mysql, or redis-cli connection
No TUI apps - Can't navigate htop, vim, or fzf with arrow keys
No long-running processes - Can't monitor builds, watch logs, or run dev servers
Related MCP server: Interactive Terminal MCP Server
The Solution
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.
uvx terminal-mcpOne command. Works with Claude Code, Claude Desktop, VS Code, Cursor, and Windsurf.
Quick Start
1. Install (30 seconds)
# No install needed - run directly
uvx terminal-mcp
# Or install globally
pip install terminal-mcp2. Connect to Your AI Client
Add to ~/.claude.json or project .mcp.json:
{
"mcpServers": {
"terminal": {
"command": "uvx",
"args": ["terminal-mcp"]
}
}
}Add to claude_desktop_config.json:
{
"mcpServers": {
"terminal": {
"command": "uvx",
"args": ["terminal-mcp"]
}
}
}Click the one-click install badge above, or add to .vscode/mcp.json:
{
"servers": {
"terminal-mcp": {
"command": "uvx",
"args": ["terminal-mcp"]
}
}
}Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"terminal": {
"command": "uvx",
"args": ["terminal-mcp"]
}
}
}3. Verify
session_exec exec="echo hello from terminal-mcp"What Can You Do With It?
SSH Into Remote Servers
session_create command="ssh user@prod-server.com" label="prod"
session_interact session_id="a1b2c3d4" input="df -h" wait_for="\$"
session_interact session_id="a1b2c3d4" input="docker ps" wait_for="\$"
session_close session_id="a1b2c3d4"Run Interactive REPLs
session_create command="python3" label="python"
session_interact session_id="e5f6g7h8" input="import pandas as pd" wait_for=">>>"
session_interact session_id="e5f6g7h8" input="df = pd.read_csv('data.csv')" wait_for=">>>"
session_interact session_id="e5f6g7h8" input="df.describe()" wait_for=">>>"
session_close session_id="e5f6g7h8"Query Databases
session_create command="psql -U admin mydb" label="db"
session_interact session_id="x1y2z3w4" input="SELECT count(*) FROM users;" wait_for="row"
session_interact session_id="x1y2z3w4" input="\dt" wait_for="#"
session_close session_id="x1y2z3w4"Navigate TUI Apps
session_create command="htop" label="monitor"
session_read session_id="a1b2c3d4"
# Auto-detects TUI, returns screen snapshot
session_send session_id="a1b2c3d4" key="F6"
session_read session_id="a1b2c3d4" mode="diff"
# Returns only changed lines - saves tokens
session_send session_id="a1b2c3d4" key="F10"
session_close session_id="a1b2c3d4"Monitor Long-Running Builds
session_create command="bash" label="build"
session_send session_id="a1b2c3d4" input="npm run build"
session_wait_for session_id="a1b2c3d4" pattern="Build complete|ERROR" timeout=120Run One-Off Commands
session_exec exec="git log --oneline -10"
session_exec exec="docker compose ps" timeout=10Features at a Glance
Feature | What It Does |
Persistent Sessions | Real PTY sessions that survive across tool calls |
Send + Read in One Call |
|
Pattern-Based Reads |
|
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 |
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 |
Tools Reference
terminal-mcp exposes 9 MCP tools. Full details in docs/tools.md.
Tool | Purpose |
Spawn a persistent terminal session | |
Send text, keys, or control characters | |
Read output (stream, snapshot, auto, diff modes) | |
Send + read in one call | |
Wait for regex pattern in output | |
One-shot command execution | |
Close a session gracefully | |
Resize terminal dimensions | |
List active sessions |
Architecture
flowchart LR
Client[AI Client] -->|MCP JSON-RPC| Server[terminal-mcp]
Server --> SM[Session Manager]
SM --> S1[PTY 1: bash]
SM --> S2[PTY 2: python3]
SM --> S3[PTY 3: ssh user@host]
S1 & S2 & S3 -.->|PTY output| Reader[Reader Thread]
Reader -.->|buffer| ServerEach session is backed by a real PTY via pexpect.spawn (or PopenSpawn on Windows). For full architecture details, see docs/architecture.md.
Configuration
All settings configurable via TERMINAL_MCP_* environment variables. Full reference in docs/configuration.md.
Setting | Env Var | Default |
Max sessions |
|
|
Idle timeout |
|
|
Safety gate |
|
|
Buffer cap |
|
|
Truncation |
|
|
Example with custom settings:
{
"mcpServers": {
"terminal": {
"command": "uvx",
"args": ["terminal-mcp"],
"env": {
"TERMINAL_MCP_MAX_SESSIONS": "20",
"TERMINAL_MCP_IDLE_TIMEOUT": "3600",
"TERMINAL_MCP_TRUNCATION_MODE": "head_tail"
}
}
}
}Documentation
Document | Description |
Complete API for all 9 MCP tools | |
How terminal-mcp works under the hood | |
All settings and environment variables | |
Dangerous command detection and safety gate | |
Real-world recipes and patterns | |
Version history and release notes | |
How to contribute |
Supported Clients
Client | Status | Install |
Claude Code (CLI) | Supported |
|
Claude Desktop | Supported | |
VS Code (Copilot Chat) | Supported | One-click install or |
Cursor | Supported | One-click install or Settings |
Windsurf | Supported |
|
Running Tests
pip install -e ".[dev]"
pytest tests/ -vContributing
Contributions welcome! See docs/contributing.md for guidelines.
License
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceProvides 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.7
- Alicense-qualityCmaintenanceProvides AI agents with fully interactive terminal sessions, including TUI support, keyboard control, and screen capture across Windows, Linux, and Mac.MIT
- Alicense-qualityCmaintenanceEnables AI agents to have persistent, fully interactive SSH sessions into remote hosts, behaving like a local terminal.231MIT
- Alicense-qualityDmaintenanceEnables AI agents to spawn and interact with real terminal sessions, capturing screenshots of rendered TUI output and sharing live sessions for debugging.01MIT
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Run AI customer support from your terminal: conversations, knowledge base, and chat widget.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mkpvishnu/terminal-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server